I am trying to compile jasperreports templates together with my java code. To do this I use a private fork of this plugin that is adjusted to work with gradle properties. Now I am trying to find a way to have this plugin provide resources that will be put in the resulting jar file and that are created using the compile and runtime classpaths of the current project.
apply plugin: 'com.github.gmazelier.jasperreports'
compileAllReports {
addClasspath(project.sourceSets.main.compileClasspath)
addClasspath(project.sourceSets.main.runtimeClasspath)
}
sourceSets.main.resources.srcDir compileAllReports
addClasspath is implemented as follows:
public void addClasspath(FileCollection fileCollection) {
Provider<List<File>> provider = fileCollection.getElements()
.map(files -> files.stream().map(FileSystemLocation::getAsFile).collect(Collectors.toList()));
classpath.addAll(provider);
}
where classpath is the following property in the task called compileAllReports
private final ListProperty<File> classpath;
@InputFiles
public ListProperty<File> getClasspath() {
return classpath;
}
My problem is that doing it like that causes the following task dependency cycle:
:classes
\--- :processResources
\--- :compileAllReports
\--- :classes (*)
Is there any way to access the compile and runtime classpaths without depending on :classes (why does a dependeny to :compileJava not suffice? The classpaths should already exist a this time) or to add a new resource directory without adding a dependency to :processResources (bad idea, because all resources are copied in this task)