I’m trying to write a plugin to stuff all dependencies (unzipped) into the same jar. This is what I’ve tried:
apply plugin: CustomZipPlugin
class CustomZipPlugin implements Plugin<Project>{
void apply(Project project) {
project.configurations.add('include');
project.tasks.add(
name:'customZipTask', type: Zip)
{
from {project.configurations.include.collect{zipTree(it)}}
};
}
}
repositories{mavenCentral()}
dependencies{
include 'net.sourceforge.cobertura:cobertura:1.9.4.1'
}
This leads to: Cannot determine the dependencies of task ‘:customZipTask’
I also tried:
..
from project.configurations.include.collect{zipTree(it)}
..
This led to a: You can’t change a configuration which is not in unresolved state!
However … writing a custom task directly in my build script (instead of a build script) works .. i.e.:
task customZipTask(type: Zip){
from {project.configurations.include.collect{zipTree(it)}}
}
Any suggestions on how to implement this zip code in a plugin instead ? (preferably a non-hacky solution)
Aha!! I needed to prepend zipTree with ‘project’ .. that solved the problem. The error messages listed above were a bit misleading.
How about println’ing all configurations ??
How would I fix the following? ( get a can’t change configuration which is not resolved exception )