Reputation: 2294
Is there any way to access Gradle groovy plugin sourceSets dirs from my Groovy project built by Gradle? I am looking for default gradle src and resources directories.
I need it to avoid hardcoding a resources directory in my project but use the default Groovy plugin resource directory (resources/main).
Upvotes: 1
Views: 1408
Reputation: 28653
You shouldn't mix up your production code with your test sources and your test resources. I would suggest the following layout (the default of the groovy plugin) of your src directories in your project:
Now you can reference the .groovy dsl test files from your tests via
URL url = this.getClass().getResource("/testDsl.groovy");
File testDslFile = new File(url.getFile());
Upvotes: 1
Reputation: 28653
Can you explain the use case for that? within your gradle build you can access the groovy sourceSets dirs introduced by Gradles groovy plugin like this:
apply plugin:'groovy'
task printGroovySourceDirs << {
sourceSets.main.groovy.srcDirs.each{
println it.absolutePath
}
}
Upvotes: 1