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" />
          <javac srcdir="${sourceDir}" destdir="classes" classpathref="mypath" includes="*.java">
    <target name="copy" depends="build" >
          <copy todir="\\Ftgds\Program Files\MyCompany\Total\j2re1.4.1_03\bin">
        <fileset dir=".\classes"/>
      <copy todir="C:\Program Files\MyCompany\Total\j2re1.4.1_03\bin">
    <fileset dir=".\classes"/>

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

no :)

are you running build from eclipse or command line
BrianMc1958Author Commented:
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?

Hi BrianMc1958,

There is a preference in eclipse which you can set for that.
It will automatically save all dirty editors (unsaved editors) before running.

Go to Window -> Preferences -> Run/Debug -> Launching

There, you can see a radio button "Save dirty editors before launching"
Set that option to always and it will never again ask you for saving!!


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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
BrianMc1958Author Commented:
Dear radarsh:

Thanks! It works!  I'm HAPPY NOW!


I have posted a comment at one of your previous questions regarding same topic.
Please check that too.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.