Last active
January 3, 2016 03:29
-
-
Save csiebler/8402830 to your computer and use it in GitHub Desktop.
Gradle snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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