I am trying to use spring webservice with ant. spring webservice requires spring-ws-servlet.xml and sample.xsd file to be put in war file parallel to web.xml.
I am trying this war command and it is putting parallele to web-inf folder instead inside of it. Please let me know what should i modify to put it inside web-inf folder.
<copy file="config/ws/spring-ws-servlet.xml" tofile="lps/WEB-INF/spring-ws-servlet.xml" />
<war warfile="dist/ODG.war" webxml="config/web.xml">
<lib dir="lps/WEB-INF/lib" />
<classes dir="lps/WEB-INF/classes" />
<fileset dir="lps/ws"/>
</war>
As the ant manual states, add a webinf element to the war task to add files into the WEB-INF directory.
<war warfile="dist/ODG.war" webxml="config/web.xml">
...
<webinf>
<fileset dir="config/ws" includes="spring-ws-servlet.xml"/>
</webinf>
</war>
Related
I'm using ANT to build a Java project that has dependency jars during compile time. The dependency jars are nested inside a directory. What this means is, the directory contains sub-directories (which might contain sub-directories) and jars as well.
I want to create an ANT element to include all the jars inside the directory. Below is my code but doesn't work. I'm wondering if this can't be done in ANT or I'm doing something wrong:
<path id="javaee.classpath">
<fileset dir="${javaee.modules.dir}">
<patternset>
<include name="**/*.jar" />
</patternset>
</fileset>
</path>
I am trying to scp my local ear to a remote server by using ant scp task. When I am trying to scp one single file this is working fine.
But when I am trying to scp ear it just displaying "[scp] Connecting to 192.168.1.44:22" But no response at all.
These are my 2 ant targets,
1.)
<target name="copy_to_remote_folder">
<scp todir="krish#192.168.1.44:/test/jboss-4.0.3SP1/server/default/deploy" password="123456" port="22">
<fileset dir="${ant.local.ear.dir}/testPro.war"/>
</scp>
<target>
2.)
<target name="copy_to_remote_file">
<scp file="${ant.local.ear.dir}/test.xml" todir="krish#192.168.1.44:/test/jboss-4.0.3SP1/server/default/deploy" password="123456"/>
</target>
copy_to_remote_file target is working fine and the copy_to_remote_folder is not working.
What could be the reason for this?
A WAR or EAR is a single file. This line...
<fileset dir="${ant.local.ear.dir}/testPro.war"/>
... doesn't make sense. The dir attribute should be used to specify a path, the base path that contains the files you are including in the set. Instead you are pointing it to a specific file. Try this...
<target name="copy_to_remote_folder">
<scp todir="krish#192.168.1.44:/test/jboss-4.0.3SP1/server/default/deploy" password="123456" port="22">
<fileset dir="${ant.local.ear.dir}">
<include name="*.war" />
</fileset>
</scp>
<target>
... or just use your copy_to_remote_file target.
I'm trying to use Ant bndwrap task to wrap non-OSGi jars in a directory. My current Ant configuration for this is:
<target name="wrap-jars" description="Wrap non-OSGi jars">
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${biz.aQute:bnd:jar}"/>
<bndwrap output="${dist.dir}/app-modules">
<fileset dir="${dist.dir}/app-modules" includes="*.jar" />
</bndwrap>
<move overwrite="true" todir="${dist.dir}/app-modules" >
<fileset dir="${dist.dir}/app-modules" includes="*.bar" />
<mapper type="glob" from="*.bar" to="*.jar" />
</move>
</target>
This works fine, but the problem is that it also wraps existing OSGi jar, which causes problems. For instance, I noticed it changes Bundle-SymbolicName header to some default value. It might be changing something else, which I don't want. I only want it to operate on jars that have no OSGi info at all.
Is there some way to tell BND to ignore existing OSGi headers in manifest, or complete jars that are already OSGi-fied?
I would store non-OSGi jars in a separate folder and modify the fileset to process only that folder.
I've noticed that recent bnd versions (for example, 2.1.0) now honour the Bundle-SymbolicName when rewrapping OSGi jars.
just change your fileset to exclude that jar
I already made a running program which is calculator in IntelliJ IDEA and make a test and it goes fine. My problem is that how to setup an ANT file to create a JAVA JAR that is calculator.
Hoping for your answers..
tnx.
This is an example of an ant target that does jar creation.
<!-- roll up everyting into a single jar file -->
<target name="dist" depends="clean, compile" description="Generate the distribution file.">
<!--
Copy the library .jars to the directory where the distribution will be located
-->
<copy todir="${dist}">
<fileset dir="${lib}"/>
</copy>
<!-- TODO: Generate the MANIFEST.MF file on the fly -->
<jar jarfile="${dist}/myCalculator.jar" basedir="${build}" manifest="tools/MANIFEST.MF"/>
<!-- dump to web server -->
<copy todir="${web-files}">
<fileset dir="${dist}"/>
</copy>
</target>
Take a look at the Ant manual page for the Jar task. There are lots of examples there.
I am trying to create a war file out of an eclipse project using ant
The responsible ant target looks like this
<target name="jar" depends="build" description="Erzeugt das WAR File">
<war destfile="${project.dir.dist}/xyz.jar" webxml="${basedir}/WebRoot/WEB-INF/web.xml" duplicate="fail" basedir="${basedir}">
<lib dir="${project.dir.dist}" excludesfile="${project.dir.dist}/xyz.jar" />
<classes dir="${project.dir.bin}" />
<webinf dir="${basedir}/WebRoot/WEB-INF" excludes="*.class" />
<metainf dir="${basedir}/WebRoot/META-INF" />
</war>
</target>
And it fails with the following error:
F:\eclipse_workspaces\skyeye\railWeb\build.xml:35: Syntax error in property: ??? ???i8?
Google search turned up only this: http://209.85.135.132/search?q=cache:OrmNOY9EJd0J:teamcity.jetbrains.com/viewLog.html%3Bjsessionid%3D114D52086BAE423B2F69A99B4CFACACD%3FbuildId%3D29573%26tab%3DbuildChangesDiv%26buildTypeId%3Dbt134+ant+war+task+%22Syntax+error+in+property%22&cd=1&hl=en&ct=clnk&client=firefox-a
Can anybody explain, what the heck is going on?
The propblem was that I used 'excludesFile' assuming it would exclude a single file. Instead ANT tried to parse it as an property file which gets difficult since it actually was a jar file.
The correct way to exclude a jar file is given in the documentation. If anyone face same issue, they can refer to this link.
This example is taken from the documentation, here we are removing jdbc1.jar from lib
Assume the following structure in the project's base directory:
thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<fileset dir="src/jsp/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
<zipfileset dir="src/graphics/images/gifs"
prefix="images"/>
</war>
will consist of
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif