Rewrite project() dep's as library/file deps in eclipse.classpath?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Rewrite project() dep's as library/file deps in eclipse.classpath?

Klash
This post has NOT been accepted by the mailing list yet.
Multi-project gradle build. I have dependencies that are a mix of maven-style
for public/external modules, and dependencies on other (internal) projects:

dependencies {
   compile "net.foo.com:bar:1.0"
   compile project("internalProj")
}

When doing 'gradle eclipse', the project() dependency gets written to
the .classpath with something like:

<classpathentry kind="src" path="/internalProj" exported="true"/>

There are certain times when I want to intercept that dependency, and make it
a dependency on the lib/jar that is generated for that project. That is, I want
to change it so that instead of above .classpath entry, I get something like:

<classpathentry \
   kind="lib"
   path="/my/hackspace/internalProj/build/libs/internalProj-1.0.1.jar"
   sourcepath="/my/hackspace/internalProj/build/libs/internalProj-1.0.1-sources.jar"
exported="true"/>   

Using the eclipse.classpath.file.whenMerged", I can find the project entries of interest, and remove them
from the eclipse.classpath.entries. Great, half-way there.

But I cannot figure out how to create/add suitable "lib" entries.

Based on reading some of the actual code that builds the classpath, I *think* I want to
create an instance of :

   org.gradle.plugins.ide.eclipse.model.Library

But my attempts to do so have failed miserably so far, I can't seem to find the groovy
DSL constructor that creates an instance of above class.

Should I just remove the entries, then use eclipse.classpath.xmlFile to generate
classpathentry nodes like above?