Fix ant build scripts and AptTask to build with new JDK and Ant

This commit is contained in:
moparisthebest 2014-04-21 08:56:24 -04:00
parent 69e0600052
commit 6ddf0ff69b
6 changed files with 316 additions and 247 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.idea/
**.iml
**/build
**/target
**~

View File

@ -162,6 +162,15 @@
<!-- Common Beehive Ant macros --> <!-- Common Beehive Ant macros -->
<!-- ======================================================================== --> <!-- ======================================================================== -->
<macrodef name="echo-fileset">
<attribute name="filesetref" />
<sequential>
<pathconvert pathsep="${line.separator}" property="@{filesetref}.echopath" refid="@{filesetref}"/>
<echo> ------- echoing fileset @{filesetref} -------</echo>
<echo>${@{filesetref}.echopath}</echo>
</sequential>
</macrodef>
<macrodef name="copy-junit"> <macrodef name="copy-junit">
<attribute name="todir"/> <attribute name="todir"/>
<sequential> <sequential>
@ -305,15 +314,19 @@
<!-- ======================================================================== --> <!-- ======================================================================== -->
<!-- Verify JDK version --> <!-- Verify JDK version -->
<!-- ======================================================================== --> <!-- ======================================================================== -->
<property name="required.jdk.version" value="1.5"/>
<condition property="jdk.version.okay"> <condition property="jdk.version.okay">
<contains string="${java.version}" substring="${required.jdk.version}"/> <or>
<contains string="${java.version}" substring="1.5"/>
<contains string="${java.version}" substring="1.6"/>
<contains string="${java.version}" substring="1.7"/>
<contains string="${java.version}" substring="1.8"/>
</or>
</condition> </condition>
<fail unless="jdk.version.okay"> <fail unless="jdk.version.okay">
Newer JDK required. Newer JDK required.
Building the project requires JDK ${required.jdk.version} Building the project requires JDK 1.5 or newer.
You are currently using the following JDK: You are currently using the following JDK:
@ -338,6 +351,7 @@ adjust your JAVA_HOME environment variable.
<!-- allow ant 1.7 for gump runs --> <!-- allow ant 1.7 for gump runs -->
<contains string="${ant.version}" substring="1.6"/> <contains string="${ant.version}" substring="1.6"/>
<contains string="${ant.version}" substring="1.7"/> <contains string="${ant.version}" substring="1.7"/>
<contains string="${ant.version}" substring="1.8"/>
</or> </or>
</condition> </condition>

View File

@ -108,6 +108,11 @@
<!-- Compiles the source code of the project. --> <!-- Compiles the source code of the project. -->
<!-- ==================================================================== --> <!-- ==================================================================== -->
<target name="classes" depends="dirs"> <target name="classes" depends="dirs">
<echo-fileset filesetref="api.classpath"/>
<echo-fileset filesetref="runtime.classpath"/>
<echo-fileset filesetref="test-container.classpath"/>
<!-- Build the API and SPI classes --> <!-- Build the API and SPI classes -->
<!-- These are built together because there are some cross-depencies --> <!-- These are built together because there are some cross-depencies -->
<!-- where API classes reference SPI interfaces --> <!-- where API classes reference SPI interfaces -->

View File

@ -100,6 +100,14 @@ public class AptTask extends Javac
_compileByExt = compileByExt; _compileByExt = compileByExt;
} }
public void setFactory(String factory) {
_factory = factory;
}
public void setFactorypath(String factorypath) {
_factorypath = factorypath;
}
/** /**
* Override the implementation of scanDir, to look for additional files based upon any * Override the implementation of scanDir, to look for additional files based upon any
* specified source extensions * specified source extensions
@ -112,9 +120,7 @@ public class AptTask extends Javac
{ {
Path srcPath = new Path(getProject()); Path srcPath = new Path(getProject());
srcPath.setLocation(srcDir); srcPath.setLocation(srcDir);
Path sp = getSourcepath(); setSourcepath(srcPath);
sp.append(srcPath);
setSourcepath(sp);
} }
GlobPatternMapper m = new GlobPatternMapper(); GlobPatternMapper m = new GlobPatternMapper();
@ -207,30 +213,24 @@ public class AptTask extends Javac
} }
} }
//
// Select the executable (apt) and set fork = true // Select the executable (apt) and set fork = true
//
setExecutable("apt"); setExecutable("apt");
setFork(true); setFork(true);
//
// Specify the code generation output directory to APT // Specify the code generation output directory to APT
//
Commandline.Argument arg = createCompilerArg(); Commandline.Argument arg = createCompilerArg();
arg.setValue("-s"); arg.setValue("-s");
arg = createCompilerArg(); arg = createCompilerArg();
arg.setFile(_genDir); arg.setFile(_genDir);
//add the -nocompile flag if set to true // Add the -nocompile flag if set to true
if(_nocompile) if(_nocompile)
{ {
Commandline.Argument ncarg = createCompilerArg(); Commandline.Argument ncarg = createCompilerArg();
ncarg.setValue("-nocompile"); ncarg.setValue("-nocompile");
} }
//
// Add processor options. // Add processor options.
//
for (Object i : _processorOptions) for (Object i : _processorOptions)
{ {
Commandline.Argument optionArg = createCompilerArg(); Commandline.Argument optionArg = createCompilerArg();
@ -240,8 +240,46 @@ public class AptTask extends Javac
checkParameters(); checkParameters();
resetFileLists(); resetFileLists();
// Iterate through the list of input extensions, matching/dependency checking based //
// upon the input list. // Allow user to define apt specific options for the name of an
// annotation processor (AP) factory to use or the factory path
// for finding the AP factories. This allows apt to bypass the
// default discovery process or specify where to find AP factories.
//
// This can help resolve build issues users may experience when
// multiple annotation processors conflict. For example,...
// A project may contain JAX-RPC 1.1 Web Services annotations.
// Starting with JDK1.6, JDK bundles the JAX-WS 2.0 AP in its
// tool jar. JAX-RPC and JAX-WS use the same JSR 181 annotations
// but the JAX-WS 2.0 AP doesn't support the earlier JAX-RPC use
// of the RPC/ENCODED soapbinding annotation on an endpoint.
// A user running the build through the Beehive AptTask and using
// Java 6, would see APT fail on JAX-RPC services thinking they are
// invalid JAX-WS services.
//
// In this example, using the -factorypath option does not disable the
// built-in annotation processor because tools.jar is always in APT's
// class path. However, exposing the option to use a specific factory
// can solve this problem. There can only be one factory name when
// invoking APT, so a user of this task may want to pass a wrapper
// factory that is an aggregated annotation processor factory.
//
if (_factorypath != null && _factorypath.trim().length() > 0) {
Commandline.Argument factoryArg = createCompilerArg();
factoryArg.setValue("-factorypath");
factoryArg = createCompilerArg();
factoryArg.setValue(_factorypath);
}
if (_factory != null && _factory.trim().length() > 0) {
Commandline.Argument factoryArg = createCompilerArg();
factoryArg.setValue("-factory");
factoryArg = createCompilerArg();
factoryArg.setValue(_factory);
}
// Iterate through the list of input extensions, matching/dependency
// checking based upon the input list.
for (int j = 0; j < _srcExts.size(); j++) for (int j = 0; j < _srcExts.size(); j++)
{ {
String ext = (String)_srcExts.get(j); String ext = (String)_srcExts.get(j);
@ -313,4 +351,6 @@ public class AptTask extends Javac
protected File _genDir; protected File _genDir;
protected Vector/*<String>*/ _srcExts = new Vector/*<String>*/(); protected Vector/*<String>*/ _srcExts = new Vector/*<String>*/();
protected Vector/*<String>*/ _processorOptions = new Vector/*<String>*/(); protected Vector/*<String>*/ _processorOptions = new Vector/*<String>*/();
protected String _factory = null;
protected String _factorypath = null;
} }

View File

@ -60,6 +60,7 @@
</copy> </copy>
<echo>Generate TLD</echo> <echo>Generate TLD</echo>
<echo-fileset filesetref="webdoclet.dependency.path"/>
<taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask" classpathref="webdoclet.dependency.path"/> <taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask" classpathref="webdoclet.dependency.path"/>
<webdoclet <webdoclet
destdir="${jars.dir}" destdir="${jars.dir}"

View File

@ -34,6 +34,10 @@
<target name="build" description="Builds the JMS control."> <target name="build" description="Builds the JMS control.">
<echo>compile module: ${module.name}</echo>
<property name="classpath" refid="module.classpath"/>
<echo>module classpath: ${classpath}</echo>
<mkdir dir="${classes.dir}/${module.name}"/> <mkdir dir="${classes.dir}/${module.name}"/>
<mkdir dir="${gen.src.dir}/${module.name}"/> <mkdir dir="${gen.src.dir}/${module.name}"/>