BrianMc1958
asked on
Ant NEWBIE: Can Ant save (open) source automatically before build?
Dear Ant Experts,
In Eclipse, I have a build.xml. Each time I run it, I'm prompted to save the (Java) source I'm currently editing. (I always want to save it.) I have not been able to get Eclipse to save it automatically. Can I add something to my build.xml that will save all changed files in my ...src directory before building (even if I currently have them open in Eclipse?)
Here is my build.xml:
<?xml version="1.0"?>
<project name="project" default="copy">
<property name="outputDir" value="C:\FTG\Projects\Tot al\classes " />
<property name="sourceDir" value="C:\FTG\Projects\Tot al\src" />
<property name="libsDir" value="C:\FTG\Projects\Tot al_Librari es" />
<target name="build">
<path id="mypath">
<fileset dir="C:\FTG\Projects\Total _Libraries " id="id">
<include name="**/*.jar" />
</fileset>
</path>
<javac srcdir="${sourceDir}" destdir="classes" classpathref="mypath" includes="*.java">
</javac>
</target>
<target name="copy" depends="build" >
<copy todir="\\Ftgds\Program Files\MyCompany\Total\j2re 1.4.1_03\b in">
<fileset dir=".\classes"/>
</copy>
<copy todir="C:\Program Files\MyCompany\Total\j2re 1.4.1_03\b in">
<fileset dir=".\classes"/>
</copy>
</target>
</project>
Thanks,
BrianMc1958
In Eclipse, I have a build.xml. Each time I run it, I'm prompted to save the (Java) source I'm currently editing. (I always want to save it.) I have not been able to get Eclipse to save it automatically. Can I add something to my build.xml that will save all changed files in my ...src directory before building (even if I currently have them open in Eclipse?)
Here is my build.xml:
<?xml version="1.0"?>
<project name="project" default="copy">
<property name="outputDir" value="C:\FTG\Projects\Tot
<property name="sourceDir" value="C:\FTG\Projects\Tot
<property name="libsDir" value="C:\FTG\Projects\Tot
<target name="build">
<path id="mypath">
<fileset dir="C:\FTG\Projects\Total
<include name="**/*.jar" />
</fileset>
</path>
<javac srcdir="${sourceDir}" destdir="classes" classpathref="mypath" includes="*.java">
</javac>
</target>
<target name="copy" depends="build" >
<copy todir="\\Ftgds\Program Files\MyCompany\Total\j2re
<fileset dir=".\classes"/>
</copy>
<copy todir="C:\Program Files\MyCompany\Total\j2re
<fileset dir=".\classes"/>
</copy>
</target>
</project>
Thanks,
BrianMc1958
ASKER
I'm running from Eclipse.
Specifically, I hit the "Run MyProject build.xml" button (green arrow with little red thing), which then does run my build.xml.
I posted this because a previous post failed (at least for me) to get Eclipse to save automatically. (Someone told me an obvious solution: Preferences > WorkSpace > Save automatically. Duh. But for some reason, it doesn't work for me).
Is there a work-around?
--BrianMc1958
Specifically, I hit the "Run MyProject build.xml" button (green arrow with little red thing), which then does run my build.xml.
I posted this because a previous post failed (at least for me) to get Eclipse to save automatically. (Someone told me an obvious solution: Preferences > WorkSpace > Save automatically. Duh. But for some reason, it doesn't work for me).
Is there a work-around?
--BrianMc1958
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Just open up the command prompt, and, making sure the classpath and libraries are set in accordance with Eclipse, run it from the command line
ASKER
Dear radarsh:
Thanks! It works! I'm HAPPY NOW!
--BrianMc1958
Thanks! It works! I'm HAPPY NOW!
--BrianMc1958
:)
I have posted a comment at one of your previous questions regarding same topic.
Please check that too.
________
radarsh
I have posted a comment at one of your previous questions regarding same topic.
Please check that too.
________
radarsh
are you running build from eclipse or command line