Suppose I have a build.gradle
thus:
dependencies {
compile 'com.group:some-app:1.0.1'
compile 'com.group:some-app:1.0.1:sources'
}
sourceSets {
main {
other {
srcDir 'src/main/other'
}
}
}
So some-app-1.0.1-sources.jar
has source files in it - not Java files, but files from which Java can be generated.
How do I include those files in sourceSets
?
Gradle has the concept of source sets for where your code and test sources live. Some Gradle plugins come with default source sets, for example the Java plugin has a "main" source set where the default location is src/main/java .
Dependencies with the same coordinates that can occur multiple times in the graph are omitted and indicated by an asterisk(*).
You can extract the files from the source jar on the fly into a directory, and add the directory to a source set.
configurations {
sourceJar
}
dependencies {
compile 'com.group:some-app:1.0.1'
sourceJar 'com.group:some-app:1.0.1:sources'
}
def generatedDir = "$build/other"
task extractFiles(type: Copy) {
from (zipTree(configurations.sourceJar.singleFile))
into generatedDir
}
sourceSets {
main {
resources {
srcDir generatedDir
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With