I have a common problem and there are probably countless ways to solve it. I\'m looking for an elegant, simple solution to this typical scenario:
I have a project in Ec
See Window -> Preferences -> Ant -> Runtime -> Properties to define custom ant properties that should be available to any ant script invoked from Eclipse. The simply set the same property manually when invoking script from command-line.
Your build.properties file can exist wherever you like. Use normal Ant facilities to import it into your script.
You can set eclipse relative properties for your ANT Build from eclipse
Go to your ANT Builder properties and in arguments section you can set properties using -D as below
-Dworkspace="${workspace_loc}" -Dproject_dir="${project_loc}"
(here workspace_loc and project_loc are eclipse variables). These properties can be accessed in your ANT build script like regular properties, for example:
<echo message="${workspace}" />
<echo message="${project_dir}" />
For my project archieve.
ProjectName <dir>
|_ ant <dir>
|_ ant.xml
Your case can just simply change the ant xml file, the <project default="main" basedir="../"/>
Then I can get the project root using variable of
e.g. <echo message= "Project Root: ${basedir}" />
I think what I'm looking for is to add the following to the build.properties file:
project.root = ${basedir}
alternatively, I can just use the basedir property whenever project.root is needed.
I happened to be looking at the source code for ivy.properties and I saw the basedir property being used. I just tested and verified that this property works on different machines both from inside eclipse and from the command line as well as when making a call to ant from a different directory such as:
ant -f /path/to/eclipse/workspace/projectName/build.xml
When I get a minute, I will verify that this also works when importing the property file in different locations (such as inside src/main/resources/config/ivy/ivysettings.xml).
if you need more than the trivial basedir stuff =
Ant4Eclipse - a bunch of ant tasks for access to eclipse configurations from within ant -
may help you. Just use it as is or grep the code and pick the relevant parts..