Invoking JWS ant script with maven
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 12
- Joined: Wed Jan 11, 2012 7:46 pm
Invoking JWS ant script with maven
I am using maven and the maven ant plugin to invoke your JWS ant shell script that eventually executes the ant build.xml When I invoke the ant shell script from a unix terminal everything works fine without any changes needed. The problems creep up only when I invoke it through maven ant plugin.
There were several things I had to do to get it to work properly. Although the changes are relatively small, they took some time to figure out. I don't know if any other users have this same use-case but perhaps by informing you how I got it to finally work with maven, it may save some other people a lot of time.
Also if you have any suggestions on a better way to do this with maven, I would appreciate it. I have documented the steps below. Note, this was done on a Mac OS X machine, so I assume this would also work on any unix/linux clone.
1. Change the oxygen/tools/jwsPackager/ant shell script
From:
export ANT_EXEC=..\ant\bin\ant
sh $ANT_EXEC $@
To:
export ANT_EXEC=target/oxygen/oxygen/tools/ant/bin/ant
sh $ANT_EXEC $@ -buildfile target/oxygen/oxygen/tools/jwsPackager/build.xml
The buildfile path is relative to where the ant shell script file resides. If I didn't do this, I would get an error stating that antbinant is not a recognized command.
2. Change the build.xml java execution
From:
<java classname="ro.sync.jws.JwsPackager">
<sysproperty
key="javax.xml.parsers.DocumentBuilderFactory"
value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
<classpath>
<pathelement path="${home}/classes"/>
<pathelement location="${home}/lib/deployer.jar"/>
<pathelement location="${home}/lib/deployerUtils.jar"/>
<pathelement location="${home}/lib/log4j.jar"/>
<pathelement location="${home}/lib/serializer.jar"/>
</classpath>
<arg value="${propertyFile}"/>
</java>
</target>
To:
<java jar="lib/rackspace-oxygen.jar" fork="true">
<sysproperty
key="javax.xml.parsers.DocumentBuilderFactory"
value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
<arg value="packager.properties"/>
</java>
rackspace-oxygen.jar is created from extracting all the classes from deployer.jar, deployerUtils.jar, serializer.jar, and log4j.jar and jar'ing them into oxygen/tools/jwsPackager/lib/rackspace-oxygen.jar
Also, I had to include a META-INF/MANIFEST.MF file inside rackspace-oxygen.jar which had the entry:
Main-Class: ro.sync.jws.JwsPackager
3. Create oxygen/tools/jwsPackager/lib/rackspace-oxygen.jar as described in the previous step.
Once I did those 3 things I was able to create the oxygenJWS.zip by invoking the ant shell script via a maven's ant plugin. It seems like once you invoke the shell script or the ant build.xml in maven, the java class path specified in the build.xml is totally ignored. I tried so many different path variations and other ant command combinations but I could never get it to work. In the end, the steps I mentioned above was the only way I could get it to work. If you have any suggestions on a better way to do this with maven, your input would be appreciated.
There were several things I had to do to get it to work properly. Although the changes are relatively small, they took some time to figure out. I don't know if any other users have this same use-case but perhaps by informing you how I got it to finally work with maven, it may save some other people a lot of time.
Also if you have any suggestions on a better way to do this with maven, I would appreciate it. I have documented the steps below. Note, this was done on a Mac OS X machine, so I assume this would also work on any unix/linux clone.
1. Change the oxygen/tools/jwsPackager/ant shell script
From:
export ANT_EXEC=..\ant\bin\ant
sh $ANT_EXEC $@
To:
export ANT_EXEC=target/oxygen/oxygen/tools/ant/bin/ant
sh $ANT_EXEC $@ -buildfile target/oxygen/oxygen/tools/jwsPackager/build.xml
The buildfile path is relative to where the ant shell script file resides. If I didn't do this, I would get an error stating that antbinant is not a recognized command.
2. Change the build.xml java execution
From:
<java classname="ro.sync.jws.JwsPackager">
<sysproperty
key="javax.xml.parsers.DocumentBuilderFactory"
value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
<classpath>
<pathelement path="${home}/classes"/>
<pathelement location="${home}/lib/deployer.jar"/>
<pathelement location="${home}/lib/deployerUtils.jar"/>
<pathelement location="${home}/lib/log4j.jar"/>
<pathelement location="${home}/lib/serializer.jar"/>
</classpath>
<arg value="${propertyFile}"/>
</java>
</target>
To:
<java jar="lib/rackspace-oxygen.jar" fork="true">
<sysproperty
key="javax.xml.parsers.DocumentBuilderFactory"
value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
<arg value="packager.properties"/>
</java>
rackspace-oxygen.jar is created from extracting all the classes from deployer.jar, deployerUtils.jar, serializer.jar, and log4j.jar and jar'ing them into oxygen/tools/jwsPackager/lib/rackspace-oxygen.jar
Also, I had to include a META-INF/MANIFEST.MF file inside rackspace-oxygen.jar which had the entry:
Main-Class: ro.sync.jws.JwsPackager
3. Create oxygen/tools/jwsPackager/lib/rackspace-oxygen.jar as described in the previous step.
Once I did those 3 things I was able to create the oxygenJWS.zip by invoking the ant shell script via a maven's ant plugin. It seems like once you invoke the shell script or the ant build.xml in maven, the java class path specified in the build.xml is totally ignored. I tried so many different path variations and other ant command combinations but I could never get it to work. In the end, the steps I mentioned above was the only way I could get it to work. If you have any suggestions on a better way to do this with maven, your input would be appreciated.
-
- Posts: 9448
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Invoking JWS ant script with maven
Hi,
From what it seems the root cause of the problems is that when invoking the ant shell using Maven, the relative paths specified in the build.xml no longer resolve to the directory where the JWS build.xml is located.
This property defined in the JWS build.xml:
is used to resolve all relative references to the JAR libraries and "packager.properties" and in your case the relative location is no longer relative to the place where the "build.xml" is located but probably to the place where the Maven process was started.
Maybe you should have tried to set an absolute value to the "home" property or maybe even something like this might have worked:
I think setting a correct value to "home" would have avoided such fixes like re-packing the used JAR libraries into one.
Regards,
Radu
From what it seems the root cause of the problems is that when invoking the ant shell using Maven, the relative paths specified in the build.xml no longer resolve to the directory where the JWS build.xml is located.
This property defined in the JWS build.xml:
Code: Select all
<property name="home" value="."/>
Maybe you should have tried to set an absolute value to the "home" property or maybe even something like this might have worked:
Code: Select all
<property name="home" value="target/oxygen/oxygen/tools/jwsPackager/"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service