How do you use variables on the Eclipse plugin to generate the .classpath


(richard murray) #1

Hi, I’m trying out the Eclipse plug-in to generate my .project and .classpath files.

I’m using a local Ivy repository and currently use the Eclipse IvyDE plugin. As Gradle doesn’t directly support the ivy.xml files I thought I’d use the Gradle script to generate the Eclipse classpath.

The .classpath file get’s produced correcly, however it has hard-coded references to my gradle cache directory. I’d like to check-in the .classpath file to our source control system so it can be shared my other team members. Would the variables method on the Eclipse plugin allow me to replace the hard-coded path with a variable? If so are there any examples?

I notice a couple of issue raised around this: GRADLE-1079 and GRADLE-1074. One of the issues is closed and the other Open but marked as a duplicate. Can anyone confirm If what I’m trying to do it possible in gradle-1.0-milestone-3.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
 <classpathentry kind="output" path="bin"/>
 <classpathentry kind="src" path="src"/>
 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
 <classpathentry sourcepath="C:/Users/richardm/.gradle/cache/log4j/log4j/sources/log4j-1.2.16-sources.jar" kind="lib" path="C:/Users/richardm/.gradle/cache/log4j/log4j/bundles/log4j-1.2.16.jar" exported="true"/>
 <classpathentry kind="lib" path="C:/Users/richardm/.gradle/cache/net.sf.jsr107cache/jsr107cache/jars/jsr107cache-1.0.jar" exported="true"/>
 <classpathentry sourcepath="C:/Users/richardm/.gradle/cache/net.sf.ehcache/ehcache/sources/ehcache-1.6.0-beta2-sources.jar" kind="lib" path="C:/Users/richardm/.gradle/cache/net.sf.ehcache/ehcache/jars/ehcache-1.6.0-beta2.jar" exported="true"/>
</classpath>

Thanks.


(Szczepan Faber) #2

You should be able to do it with M3 and other releases too. Here’s the link to the DSL reference on that particular subject. It shows how to do it with the latest version. If you need to stick to M3, browse for the DSL reference for M3 (although it will contain less examples).

Take a look at the example in the DSL reference: http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseClasspath.html