We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Ant NEWBIE: Can Ant save (open) source automatically before build?

BrianMc1958
BrianMc1958 asked
on
Medium Priority
264 Views
Last Modified: 2010-03-31
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
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
no :)

are you running build from eclipse or command line

Author

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?

--BrianMc1958
Commented:
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!!


________
radarsh

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Top Expert 2016

Commented:
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

Author

Commented:
Dear radarsh:

Thanks! It works!  I'm HAPPY NOW!

--BrianMc1958

Commented:
:)

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

________
radarsh
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.