im using Ant to create a war for my web app. I have a script similar to this:
<target name="createWar" depends="init" description="Crea el war final">
<war destfile = "myapp.war" webxml = "${webApp}/WEB-INF/web.xml" >
<fileset dir = "${webApp}">
<include name = "**/*.*"/>
<exclude name="**/.git/"/>
<exclude name="WEB-INF/work/"/>
<exclude name="WEB-INF/tmp/"/>
<exclude name="build.properties"/>
<exclude name="build.properties.base"/>
<exclude name="build.xml"/>
<exclude name="**/.settings"/>
<exclude name=".proyect"/>
</fileset>
<lib dir = "${lib}"/>
<classes dir = "${src}">
<include name="src/**/*.java"/>
<include name="conf/**/*.java"/>
</classes>
</war>
</target>
The problem I have is that the resulting war has the source files (.java files) inside the "WEB-INF/classes/src" directory. Is there a way to not include the source files , and only the.class files? Thanks a lot.
If not done so already, change your project so that the javac
output is separate from the src
tree - say classes.dir=build\classes
- then the war can be copied from the generated code directory:
<!-- classes dir = "${src}" -->
<classes dir = "${classes.dir}">
<!-- include name="src/**/*.java"/ -->
<!-- include name="conf/**/*.java"/ -->
</classes>
However, I find it easier to package all the class files of a project as a JAR first:
<jar basedir="${classes.dir}" jarfile="${lib}/${ant.project.name}.jar" update="true" />
Then if the project is also a WAR project that single jar ${ant.project.name}.jar
can be copied inside ${ant.project.name}.war
in one step as the path WEB-INF\lib\${ant.project.name}.jar
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.