The Ant build below compiles successfully.
Unfortunately, it doesn't execute the run step despite the depends
attribute specifying execute the run target after compile step completed successfully.
It also doesn't create a jar file in the specified classpath.
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project default="run" name="My Project">
<target name="run" depends="compile">
<java classname="com.company.program.project">
<classpath path="staging\" location="C:\my_work\Eclipse\3.6-64\plugins\"/>
</java>
</target>
<target name="compile">
<javac includeantruntime="false" srcdir="./src" destdir="staging">
<classpath>
<fileset dir="C:\my_work\Eclipse\3.6-64\plugins">
<!-- <include name="**/*.jar" /> -->
<include name="org.eclipse.swt.*.jar" />
</fileset>
</classpath>
</javac>
</target>
<jar destfile="./build/jars/swtgui.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="org.swtgui.MainGui" />
<attribute name="Class-Path" value="." />
</manifest>
<fileset dir="./bin/com/company/program/project" includes="**/*.class" />
<fileset dir="C:\my_work\Eclipse\3.6-64\plugins\" includes="org.eclipse.swt.win32.win32.x86_64_3.6.0.v3650b.jar" />
</jar>
<record name="./project.log" loglevel="verbose" action="start"/>
EDIT: Got it to run. Did not edit the build.xml, but went to Project Explorer -> build.xml -> External Tool Configurations -> Build -> Targets
and for some reason the run target was unchecked.
I checked it and now the run
target runs, but produces the error log below.
run:
[java] running com.company.project.program with default permissions (exit forbidden)
[java] Running in same VM Executing 'com.company.project.program'
The ' characters around the executable and arguments are
not part of the command.
[java] Could not find com.company.project.program. Make sure you have it in your classpath
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:140)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:834)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:228)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:137)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:110)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:36)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:460)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:142)
[java] Java Result: -1
run: duration 0 seconds
BUILD SUCCESSFUL
BUILD SUCCESSFUL
Do I need to do anymore editing to the xml file to get this to run and create a jar?
ant -verbose -debug
and check/post the output. Absolute Windows paths are a pretty bad sign, but I'm not sure this is the problem. Generally your build file does not look good. – lexicore@username
in your comment to address a specific user you're replying to. – lexicore