Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant script to generate Jar - Reference not found error

Tags:

java

ant

I have following ant script to generate the jar file

<project name="myProject" basedir="." default="jar">
<property name="src" value="Java Source"/>
<property name="output" value="bin"/>

<target name="compile" depends="create">
    <javac destdir="bin">
        <src path="${src}"/>
        <classpath refid="myProject.classpath"/>
    </javac>
</target>

<target name="jar" depends="compile">
    <jar destfile="myProject.jar">
        <fileset dir="bin"/>
    </jar>
</target>


<target name="clean">
    <delete dir="${output}"/>
</target>

<target name="create" depends="clean">
    <mkdir dir="${output}"/>
</target>

When I run ant script i get following error

Reference myProject.classpath not found.

I am not sure how to solve this error. It requires path of .classpath file ? I also tried with

refid="classpath"

and it didnt work.

Can anyone help please! Thanks

like image 218
Coder Avatar asked Oct 07 '22 23:10

Coder


1 Answers

You need to define first something like because right now MyProject.classpath is not defined:

<classpath>
  <pathelement path="${classpath}"/>
</classpath>

assuming that your classpath has what you need.

If it does not, create another entry under classpath element that has references to jars or whatever you need, or you need to custom specify path:

  <path id="MyProject.classpath">
   <pathelement location="lib/"/>
   <pathelement path="${classpath}/"/>
   <pathelement path="${additional.path}"/>
  </path>

http://ant.apache.org/manual/using.html#path

like image 167
Edmon Avatar answered Oct 13 '22 11:10

Edmon