Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Ant script to export User Library/Libraries for project

I am new to Java programming. I initially started with NetBeans but have moved to Eclipse given the advice from a friend.

In NetBeans, a pre-written ant build script for the project would generate a Project.jar file and place all required libraries/jars in a lib/ folder.

However, in Eclipse it appears that I need to write my own ant script. I have written a few lines to generate the jar file:

<target name="compile"> <mkdir dir="${build.dir}"/> <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="jars" debug="on"/> </target>

How do I write a command to copy all of the jars in my User Library to a ${build.dir}/lib/ folder?

Thanks.

like image 638
kmccoy Avatar asked Oct 25 '25 20:10

kmccoy


1 Answers

Use the copy task

like so, with the appropriate include or exclude pattern

  <copy todir="${build.dir}/lib/">
    <fileset dir="src_dir">
      <include name="**/*.jar"/>
    </fileset>
  </copy>



 <copy todir="${build.dir}/lib/">
    <fileset dir="src_dir" excludes="**/*.java"/>
  </copy>
like image 149
JoseK Avatar answered Oct 27 '25 11:10

JoseK