Hi all,
I have a Gradle plugin to generate a properties file and I want to register the parent directory as a resource folder (to be recognized by Gradle so the file will be packaged into the final jar file).
Here is the groovy code (from my plugin) which does not work (the folder is not added to classpath and is not recognized as classpath entry when imported to Eclipse using Buildship)
// File: GitPropertiesPlugin.groovy
class GitPropertiesPlugin implements Plugin<Project> {
void apply(Project project) {
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
public void execute(JavaPlugin javaPlugin) {
...
project.sourceSets.main.resources.srcDir "${project.buildDir}/generated-resources/main" // DOES NOT WORK!
}
})
}
}
The similar logic will work in a build.gradle (but I don’t want the users to do it for every build.gradle file)
// File: build.gradle
sourceSets.main.resources.srcDir "$buildDir/generated-resources/main" // WORK!