Hi,

I'm trying to add a list of JARs, extracted from a downloaded WAR, to a
generated Eclipse project's classpath.
Previously I've succeeded to add them to compileJava task's classpath, but
for Eclipse plugin it does not work.
The code looks as the following:

def createClassPath() {
    libDir = new File( some_task.outputs.files.singleFile, 'lib' )
    FileCollection cp = fileTree( libDir ).matching { include '**/*.jar' }
    cp = cp.plus( configurations.compile ) // need this plus() call, since
all file collections are read-only
    return cp
}

compileJava.dependsOn some_task
eclipseClasspath.dependsOn some_task

// Add extracted JARs to the classpath
compileJava.doFirst {
    setClasspath createClassPath()
}

eclipseClasspath {
    beforeConfigured { classpath ->
        classpath.configure( [createClassPath().asPath] )
        //classpath.entries.each { entry -> println "CPENTRY =========
${entry}" }
    }
}

The error looks like:

Execution failed for task ':mymodule:eclipseClasspath'.
Cause: No signature of method:
org.gradle.plugins.eclipse.model.Classpath.isDependency() is applicable for
argument types: (java.lang.String) values

In JavaDocs it is said that classpath.configure method accepts regular List,
but obviously, it isn't a List<String>, and there is no any mention of
isDependency method in Gradle docs, so there is no clue what to do with it.

In Gradle manual, the samples only suggest how to iterate over the classpath
entries, and how to remove some entries.
I've tried iterating over the entries, but the collection is empty.
Adding throws an exception too.
Using plusConfigurations also throws an exception.

Any ideas? Suggestions?

May be it can be done in some other way, so that all plugins - compileJava,
eclipseClasspath, ideaModule (or whatever) receive a proper classpath?

Regards,

Andrew

-- 
--
Andrew Schetinin

Reply via email to