I have a very big problem. I just created with ant a jar file and everything works, but in the jar file the src folder is ommited, but I need it because I'm referrencing a file from the application.
Ie I have the following structure in my project ProjectName/src/org/nexLevel/nextLevel/Main.java. I also have ProjectName/config/settings.properties.
When I know build a jar file with ant I get only the folders org/nexLevel/nextLevel/Main.java but not the src folder. How can I get the src folder in my .jar?
Here is my ant script:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="complete build" name="Create runnable jar file">
<property name="src.dir" location="src" />
<property name="lib.dir" location="lib" />
<property name="build.dir" location="bin" />
<property name="dist.dir" location="dist" />
<property name="docs.dir" location="docs" />
<property name="config.dir" location="config" />
<property name="build.sysclasspath" value="last" />
<path id="project-classpath">
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<target name="remove release">
<delete dir="${dist.dir}" />
</target>
<target name="clean build">
<delete dir="${build.dir}" />
</target>
<target name="clean docs">
<delete dir="${docs.dir}" />
</target>
<target name="compile" depends="clean build">
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="on" target="1.8" source="1.8">
<classpath refid="project-classpath" />
<compilerarg value="-Xlint:none" />
</javac>
</target>
<target name="docs" depends="clean docs, compile">
<mkdir dir="${docs.dir}" />
<javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
<fileset dir="${src.dir}">
<include name="**" />
</fileset>
</javadoc>
</target>
<target name="build jar" depends="remove release, compile">
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/myApp.jar">
<manifest>
<attribute name="Main-Class" value="org.nextLevel.nextLevel.Main" />
<attribute name="Class-Path" value="." />
</manifest>
<fileset dir="${build.dir}" />
<zipfileset dir="config" prefix="config" />
<zipfileset excludes="META-INF/**" src="lib/postgresql-9.3-1102.jdbc41.jar" />
</jar>
<antcall target="clean build" />
</target>
<target name="complete build" depends="docs, build jar, clean build" />
</project>
Your jar task only includes build.dir, try adding src.dir to the jar as well
<fileset dir="${build.dir}" />
<fileset dir="." includes="**/*.java"/>
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.