Can I see which shell commands Eclipse executes?

I have a rather long project that I'm working on, which requires that the older JDK compile correctly, include various JARs, etc. I am building an entire project using a script package, and I would like to fully automate the whole process using a script. So I was wondering if I could look at the Eclipse shell commands to make a particular piece of code turned into a JAR (from compiling with the corresponding JDK that I specified to create the JAR), so I donโ€™t have to manually enter and spend a ton of time making sure that I do everything right in the shell. Thanks!

+4
source share
3 answers

Eclipse does not execute shell commands to compile. It uses its own built-in compiler.

You can let Eclipse generate ANT Script for you. This Script can compile your classes using the built-in Eclipse compiler. It will also configure the classpath to compile. This may be a good first step. To create a script, select your project and select "Export"> ANT Buildfiles in the context menu.

+5
source

As far as I know, Eclipse does not issue a shell command to compile or create a JAR file. Instead, it uses the appropriate Java API.

What I regularly use to do this work is ant ( http://ant.apache.org ).

Here is a very simple build.xml file that takes java sources in the "src" directory, compiles them using the libraries in the "lib" directory and puts the resulting classes in the "project.jar" file.

<?xml version="1.0" encoding="UTF-8"?> <project name="project"> <target name="package" description="builds the jar file from the compiled classes"> <mkdir dir="build" /> <javac srcdir="src" destdir="build"> <classpath> <fileset dir="lib" includes="**/*.jar" /> </classpath> </javac> <jar destfile="project.jar"> <fileset dir="build" includes="**/*.classes" /> </jar> </target> </project> 
+2
source

A really good option is to use Ant4Eclipse ( http://ant4eclipse.sourceforge.net/ )

This is a set of ant tasks that process the metadata of an eclipse project and can be used to determine the correct assembly order of the project, source and output directories, etc.

You can also display ant targets for eclipse developers (for example, if you have the ANTLR builder installed in eclipse, you can define an ant target that compiles the ANTLR code and maps it to the ANTLR constructor name to run)

At my last job, I wrote a generic compilation script using ant4eclipse. At some point, I will try to create a new generic script construct, but did not succeed.

0
source

All Articles