Reemo,
Can you post this somewhere? I'd like to try it.
reemo wrote:
I have written a custom ant task that does the following:
- Allows multiple jar/war files to be included during JIBX class instrumentation.
- Re-packages the jar/war files so the build can later pick up the re-created archives (for instance for including in a deployment unit (war/ear).
- Uses standard out-of-the-box JIBX compilation ANT task inside this ANT task.
What all this allows in my opinion is for code that jibx needs to instrument to live outside of the main project, as well as the usage of 3rdParty API's during JIBX instrumentation. This is necessary because the compiler needs the .class files to be available in the classpath (not in a packaged JAR).
You could put all your packages in the same code base but depending on how you are building your projects you may not want to put code in a project where it doesn't make sense.
<!-- custom task def -->
<taskdef classpathref="task.path" name="jibxJARCompile"
classname="com.edmunds.common.ant.tasks.CompileJarsJibxTask">
<classpath>
<path refid="jibx.compile.path"/>
</classpath>
</taskdef>
<!-- Use custom task -->
<jibxJARCompile dependencyOuputDir="${jibx.dependencies.destination}" recreatedJarsDir="${generated.java.dir}"
bindingFile="${jibx.binding.xml}" verbose="false" load="true">
<fileset dir="${dependencies.destination}" includes="${jibx.jar.dependencies}"/>
<classpathset>
<pathelement path="${build.classes}"/>
<pathelement location="${root.dir}/shared/3rdParty/jibx/lib/jibx-bind.jar"/>
</classpathset>
</jibxJARCompile>
Task attributes:
-------------------
dependencyOuputDir - This is the directory where the unpacked JAR/WAR files will be extracted to and instrumented.
recreatedJarsDir - The directory where the re-packaged (post-instrumentation) JAR/WAR files will be placed.
bindingFile - The JIBX binding file. Passed directly to the out of the box JIBX compile ANT Task.
verbose - Verbosity level. Passed directly to the out of the box JIBX compile ANT Task.
The <fileset> just needs to be setup to be able to find the JAR/WAR files JIBX is dependent up during instrumentation.
The <classpathset> in my custom task only allows path or location declarations as using "refid"'s will break the task as I append the exploded JAR/WAR file directories to this classpath (path) object.
If this task sounds like the right approach for the current release of JIBX I'd be willing to submit it (as I'm already using it in our builds). Let me know your thoughts/comments?
Reemo