On Oct 13, 2008, at 8:13 PM, snesbitt wrote:


All:

My project requires rmic compilation after compilation. This was fairly straightforward to add by creating a new rmic method and adding that method
via doLast to the compile and testCompile tasks.

The one thing that was rather awkward was getting the classpath used by the compile and testCompile tasks respectively. After going through the source I
ended up with the following call:
List classpath =
GUtil.addLists(<task>.classpathConverter.createFileClasspath (project.rootDir, <task>.unmanagedClasspath),compile.dependencyManager.resolveTask (<task>.name)
)

Gradle has a decoupling here. We have the configurations 'compile', 'testCompile', etc.. You can assign dependencies to them and retrieve those dependencies with:

dependencies.resolve(<confName>) to get a list of files or, as Peter has pointed out, dependencies.antpath(<confName>).

Additionally a task can be associated with one or more configurations. This is by default the case for a subset of the tasks introduces by the JavaPlugin (e.g. compile, test). Usually you steer the classpath used by those tasks via assigning dependencies to the configurations. But those tasks have also a property unmanagedClasspath. Via this property you can assign dependencies directly to a task. Those dependencies are not managed by Ivy and must be file objects pointing to a jar or dir. This is property is used internally in some scenarios (e.g. when compiling the build sources).

But to me it looks that for your purpose you are perfectly fine by using for example rmic(classpath: dependencies.resolve('compile')). The unmanaged classpath of the compile and testCompile task is empty by default.

Referring to the your other mail: I think the biggest gap in the user's guide is the coverage of the use cases on how to use the tasks introduced by the Java Plugin


Is there a simpler call? If not, is there a technical reason why not? It seems to me that grabbing the classpath is likely to be a common need and
should be supported by a simple call => compile.getClasspath()

To be honest. I have been surprised that this is not possible. And of course it should be possible.


I'll be glad to add a Jira item if this sounds like a reasonable idea.

Please.


I'd offer to provide a patch, but I'm not sure I'm familiar enough with the architecture/implementation yet to do it right. If someone would point me in
the right direction, I will be glad to come up with a patch.

That would be great. As this is would be a derived property you just have to do an 'extract method' for the snippet you have already found in the code. And then you would just have to add a unit test for this method. If you don't mind you could do this also for the Test task :)

Thanks

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to