Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336814 - Make project classpath avaliable as variable
Summary: Make project classpath avaliable as variable
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT Core Triaged CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-10 08:19 EST by arne anka CLA
Modified: 2016-07-01 05:06 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description arne anka CLA 2011-02-10 08:19:03 EST
We develop with JDT and finally create the WARs and JARs to distribute with ANT inside Eclipse.
Thus we have two independent Classpaths to keep in sync: the one in the Eclipse Project and the one in the ANT build file -- that's rather tedious and annoying.

It should be trivial to make the classpath of the project available a s a variable, so that we would only need to export that variable to ANT and include in our build-files. 

Looking for  a solution i couldn't help to notice, that the demand is overwhelming and hardly covered by insufficient and unsatisfying attempts like antclipse or ant4eclipse (which both don't work, at least here with galileo).


-- Configuration Details --
Product: Eclipse 1.3.1.20100913-1228 (org.eclipse.epp.package.jee.product)
Installed Features:
 org.eclipse.jdt 3.6.2.r362_v20100929-7z8XFUUFLFlmgNd019WRcD5LVkHD
Comment 1 Walter Harley CLA 2011-02-10 13:37:25 EST
Please feel free to contribute "trivial" enhancements yourself!  Patches are always welcome.  

The Java build classpath (which is not always the same as the runtime classpath) is available through APIs such as JavaProject.getClasspath(); I am not sure what you mean by "as a variable" - surely you don't mean an environment variable, since there would have to be a different one for every project.  Can you be more specific about exactly where and how you think the functionality should be exposed?  Thanks!
Comment 2 Ayushman Jain CLA 2011-02-11 00:53:57 EST
Jay, please follow up. Thanks!
Comment 3 arne anka CLA 2011-02-14 04:44:12 EST
my past attempts to improve eclipse weren't successful. i don't fully understand the ideas behind many concepts and eclipse is rather complex.

to make the issue more clear:

i got several projects which eventually are build via ant buil files.
eg

<task name="build">
	...
	<path id="build.classpath">
		<pathelement path="${build.classesdir}" />
		<pathelement path="../foo/bar.jar />
		<pathelement path="../bar/foo.jar />
		...
	</path>
	...
	<javac ...>
		<classpath refid="build.classpath" />
	</javac>
</task>

these path-element is basically a duplicate of the <classpath>-element in .classpath of the project.
if the classpath of the project is changed within eclipse (Properties->Java build Path) it has to be changed in the build.xml as well to be synchron.

it would be much easier if eclipse's ant plugin (or whatever part integrates ant) would expose the project's classpath to be used in the build.xml, something like

<task name="build">
	...
	<javac ...>
		<classpath refid="eclipse.project.classpath" />
	</javac>


</task>

eclipse exposes project specific information to ant anyway, why not the classpath -- be it as a variable or a dedicated task? (and not to speak of eclipse's "Variable Classpath Entries" which aren't available to ant at all)
Comment 4 arne anka CLA 2016-07-01 05:06:09 EDT
in case somebody stumbles over this.
the fix is:
- preferences -> ant -> runtime -> properties
- add property project_classpath with value ${project_classpath} (which is an eclipse variable)
- new property project_classpath can be used in ANT build file 
<path id="build.classpath">
    <pathelement path="${build.classesdir}" />
    <pathelement path="${project_classpath}" />
    ...
<path>

you can do the same with any eclipse variable (project_loc or workspace_loc may be helpful)