Skip to content

Instantly share code, notes, and snippets.

@csiebler
Last active January 3, 2016 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csiebler/8402830 to your computer and use it in GitHub Desktop.
Save csiebler/8402830 to your computer and use it in GitHub Desktop.
Gradle snippets
// print compileClasspath before compiling the code
compileJava.doFirst {
sourceSets.main.compileClasspath.each { println it }
}
// include classes from main into other sourceset, e.g. for integration tests, etc.
sourceSets {
anotherSet {
java.srcDir file('src/another/java')
resources.srcDir file('src/another/resources')
compileClasspath = sourceSets.main.output + configurations.anotherSet
// runtimeClasspath is automatically set to output + compileClasspath
}
}
// make a task depend on a set of tasks in subprojects
taskWithDependencies.dependsOn {
subprojects.collect { project ->
project.something
}
}
// set main class for jar file
jar {
manifest {
attributes(
"Main-Class": "my.main.foo.bar",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment