You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/24 09:07:58 UTC
svn commit: r818384 - in /commons/sandbox/runtime/trunk: build.xml
src/main/java/org/apache/commons/runtime/Library.java
src/main/java/org/apache/commons/runtime/Loader.java
src/main/java/org/apache/commons/runtime/Main.java
Author: mturk
Date: Thu Sep 24 07:07:58 2009
New Revision: 818384
URL: http://svn.apache.org/viewvc?rev=818384&view=rev
Log:
Add Java5/Java6 ant code filter
Modified:
commons/sandbox/runtime/trunk/build.xml
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=818384&r1=818383&r2=818384&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Thu Sep 24 07:07:58 2009
@@ -94,7 +94,28 @@
</target>
<target name="prepare" depends="env">
- <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.dir}"/>
+ <condition property="java7.code.start" value="///*"
+ else="/* Section commented by Ant.">
+ <equals arg1="${compile.source}" arg2="1.7"/>
+ </condition>
+ <condition property="java7.code.end" value="//*/" else="*/">
+ <equals arg1="${compile.source}" arg2="1.7"/>
+ </condition>
+ <condition property="java6.code.start" value="///*"
+ else="/* Section commented by Ant.">
+ <equals arg1="${compile.source}" arg2="1.6"/>
+ </condition>
+ <condition property="java6.code.end" value="//*/" else="*/">
+ <equals arg1="${compile.source}" arg2="1.6"/>
+ </condition>
+ <condition property="java5.code.start" value="///*"
+ else="/* Section commented by Ant.">
+ <equals arg1="${compile.source}" arg2="1.5"/>
+ </condition>
+ <condition property="java5.code.end" value="//*/" else="*/">
+ <equals arg1="${compile.source}" arg2="1.5"/>
+ </condition>
</target>
<!-- =================================================================== -->
@@ -178,13 +199,19 @@
</tstamp>
<!-- Copy static resource files -->
<filter token="VERSION" value="${version}"/>
- <filter token="VERSION_MAJOR" value="${version.major}"/>
- <filter token="VERSION_MINOR" value="${version.minor}"/>
- <filter token="VERSION_PATCH" value="${version.patch}"/>
+ <filter token="VERSION_MAJOR" value="${version.major}"/>
+ <filter token="VERSION_MINOR" value="${version.minor}"/>
+ <filter token="VERSION_PATCH" value="${version.patch}"/>
<filter token="VERSION_NUMBER" value="${version.number}"/>
- <filter token="VERSION_PNAME" value="${final.name}"/>
- <filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
- <filter token="VERSION_UUID" value="${build.uuid}"/>
+ <filter token="VERSION_PNAME" value="${final.name}"/>
+ <filter token="VERSION_BUILT" value="${TODAY} ${TSTAMP}"/>
+ <filter token="VERSION_UUID" value="${build.uuid}"/>
+ <filter token="JAVA7_CODE[[" value="${java7.code.start}"/>
+ <filter token="]]JAVA7_CODE" value="${java7.code.end}"/>
+ <filter token="JAVA6_CODE[[" value="${java6.code.start}"/>
+ <filter token="]]JAVA6_CODE" value="${java6.code.end}"/>
+ <filter token="JAVA5_CODE[[" value="${java5.code.start}"/>
+ <filter token="]]JAVA5_CODE" value="${java5.code.end}"/>
<copy todir="${build.src}/java" filtering="yes">
<fileset dir="${src.dir}/main/java">
<include name="**/*.java"/>
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java?rev=818384&r1=818383&r2=818384&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Library.java Thu Sep 24 07:07:58 2009
@@ -74,6 +74,10 @@
*/
private static void setExecutable(File file)
{
+ @JAVA6_CODE[[@
+ file.setExecutable(true);
+ @]]JAVA6_CODE@
+ @JAVA5_CODE[[@
try {
Class<?> paramTypes[] = new Class[1];
Object paramValues[] = new Object[1];
@@ -85,6 +89,7 @@
} catch (Throwable t) {
// Java < 6
}
+ @]]JAVA5_CODE@
}
private static File extractResource(InputStream is, String name)
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java?rev=818384&r1=818383&r2=818384&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java Thu Sep 24 07:07:58 2009
@@ -20,6 +20,7 @@
import org.apache.commons.runtime.util.Utils;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.HashMap;
/**
@@ -47,6 +48,40 @@
}
/**
+ * Return the location of the {@code Jar} file from
+ * which this class is loaded.
+ *
+ * @return Abstract pathname to the jar file this class was
+ * loaded from or {@code null} in case it was not loaded
+ * from {@code Jar}.
+ */
+ public static File getLocation()
+ {
+ URL url = null;
+ Class cls = Loader.class;
+ try {
+ if (cls.getProtectionDomain() == null ||
+ cls.getProtectionDomain().getCodeSource() == null) {
+ // Can this happen for non System class?
+ return null;
+ }
+ url = cls.getProtectionDomain().getCodeSource().getLocation();
+ } catch (SecurityException ex) {
+ // Someone limited the RuntimePermission("getProtectionDomain")
+ }
+ if (url == null)
+ return null;
+ else {
+ File jar = new File(url.getFile());
+ if (jar.isDirectory()) {
+ return null;
+ }
+ else
+ return jar;
+ }
+ }
+
+ /**
* Get the path to temporary location for extracting the
* libraries from resource.
*/
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java?rev=818384&r1=818383&r2=818384&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java Thu Sep 24 07:07:58 2009
@@ -17,7 +17,7 @@
package org.apache.commons.runtime;
import org.apache.commons.runtime.exception.*;
-
+import java.io.File;
/**
* Main class.
*
@@ -57,6 +57,7 @@
System.out.println("Package id : " +
Properties.VERSION_UUID + " (" +
Properties.VERSION_BUILT + ")");
+ System.out.println("Location : " + Loader.getLocation());
}
} catch (Throwable ex) {
ex.printStackTrace();