Link to home
Create AccountLog in
Avatar of BrianMc1958
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\Total\classes" />
      <property name="sourceDir" value="C:\FTG\Projects\Total\src" />
      <property name="libsDir" value="C:\FTG\Projects\Total_Libraries" />
     <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\j2re1.4.1_03\bin">
        <fileset dir=".\classes"/>
      </copy>
      <copy todir="C:\Program Files\MyCompany\Total\j2re1.4.1_03\bin">
    <fileset dir=".\classes"/>
  </copy>
    </target>
</project>


Thanks,
BrianMc1958
Avatar of Mick Barry
Mick Barry
Flag of Australia image

no :)

are you running build from eclipse or command line
Avatar of BrianMc1958
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
ASKER CERTIFIED SOLUTION
Avatar of radarsh
radarsh

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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
Dear radarsh:

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