saker.maven.classpath() task works on Maven artifacts and creates a classpath object that can be passed to tasks in the saker.java.compiler package and to others which handle classpath input similarly.
When used in an IDE, the task automatically downloads the associated source artifacts if available.
Classpath can be created and used for a given set of artifacts:
saker.java.compile( SourceDirectories: src, ClassPath: saker.maven.classpath([ "junit:junit:4.12", "org.slf4j:slf4j-api:1.7.19" ]) )
In the above we create a classpath that references the
org.slf4j:slf4j-api:1.7.19 artifacts. Note that the dependencies of the artifacts are not resolved.
If the build is invoked in an IDE, the source artifacts are also downloaded.
The task can accept resolved dependencies as its input. Extending the example from above:
saker.java.compile( SourceDirectories: src, ClassPath: saker.maven.classpath(saker.maven.resolve([ "junit:junit:4.12", "org.slf4j:slf4j-api:1.7.19" ])) )
We used the
saker.maven.resolve() task to resolve the dependencies of the specified artifacts before passing them to the classpath task. This results in the
org.hamcrest:hamcrest-core:1.3 artifact being included in the classpath as well (
junit depends on it). Usually this is the way you want to use the task.
More information here.