Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reference a classpath from Gradle 0.6

I have a project using Gradle as the build tool and I have to make use of the Ant Java task. One of the sub elements in this task is a reference to a classpath and I would like to use refid. The build script uses Gradle's WAR plugin. Since the compile task works without any problem I know that the classpath is set up correctly:

dependencies {
  compile 'commons-beanutils:commons-beanutils:1.8.0'
  compile group: 'commons-lang', name: 'commons-lang', version: '2.4'
  ...
}

No I would like to reference this classpath in my Gradle build script.

I've tried the following:

Using classpathId (built in?) Searched the Gradle mailinglists and found a suggestion:

project.dependencies.antpath('compile')

This results in an error. Also tried some variants of this, but no luck so far. Any suggestions are appreciated.

like image 650
tronda Avatar asked Dec 29 '22 22:12

tronda


1 Answers

The following will access the configured depedencies:

configurations.compile.asPath

If you have defined your own configuration you can utilize this also:

configurations {
    gwtCompile
}
....
ant.java(classname:'com.google.gwt.dev.Compiler', fork:'true', failOnError: 'true') {
    jvmarg(value: '-Xmx184M')
    arg(line: '-war ' + gwtBuildDir)
    arg(value: 'com.yoobits.ocs.WebApp')
    classpath {
        pathElement(location: srcRootName + '/' + srcDirNames[0])
        pathElement(path: configurations.compile.asPath)
        pathElement(path: configurations.gwtCompile.asPath)
    }
}

In the example above I've accessed the compile path and my own configuration which is only interesting during a special phase during the build - compiling with the GWT compiler.

like image 125
tronda Avatar answered Jan 09 '23 15:01

tronda