This is gradle plugin for automating idiomatic part of multi-project gradle builds.
All versions of Rooty are available in maven central under the group 'org.akhikhl.rooty'.
Content
- Why rooty?
- Gradle plugin
- Multi-project structure
- Root project tasks
- Library project tasks
- Injected properties
- Injected dependencies
- Copyright and License
Rooty takes opinionated view on how to organize multi-project gradle configuration. Purpose is to reduce the amount of boilerplate code and make things work "out of the box", without programming or with minimal programming.
Add the following to "build.gradle":
apply from: 'https://raw.github.com/akhikhl/rooty/master/pluginScripts/rooty.plugin'
then do "gradle build" from command-line.
Alternatively, you can download the script from https://raw.github.com/akhikhl/rooty/master/pluginScripts/rooty.plugin to the project folder and include it like this:
apply from: 'rooty.plugin'
or feel free copying (and modifying) the declarations from this script to your "build.gradle".
Rooty assumes the following multi-project structure (all parts are optional):
"buildSrc" is a standard build script folder, described in official gradle documentation.
"libs" contains java/groovy/scala libraries listed in "settings.gradle" of the root project. Rooty ensures that these libraries are installed into local maven repository ($HOME/.m2/repository) upon successful compilation.
"examples" contains example java/groovy/scala programs listed in "examples/settings.gradle". Rooty ensures that examples are compiled only after successful compilation and installation of "libs".
"apps" contains java/groovy/scala applications listed in "apps/settings.gradle". Rooty ensures that apps are compiled only after successful compilation and installation of "libs".
Rooty adds the following tasks to the root project:
Does nothing by default. Finalized by buildApps and buildExamples tasks.
Runs "build" task against "apps" folder (if such folder exists).
Runs "build" task against "examples" folder (if such folder exists).
Deletes "build" folder of the root project (if such folder exists). Depends on "cleanApps", "cleanExamples" and "buildSrc_clean" tasks.
Runs "clean" task against "apps" folder (if such folder exists). "clean" task of the root project depends on "cleanApps".
Runs "clean" task against "examples" folder (if such folder exists). "clean" task of the root project depends on "cleanExamples".
Runs "clean" task against "buildSrc" folder (if such folder exists). "clean" task of the root project depends on "buildSrc_clean".
Runs "uploadArchives" task against "buildSrc" folder (if such folder exists). "uploadArchives" task of the root project depends on "buildSrc_uploadArchives".
Rooty adds the following tasks to every project within "libs":
Creates sources jar from the source code of the given library. "assemble" task of library project depends on "sourcesJar".
Creates javadoc jar from the source code of the given library. "assemble" task of library project depends on "javadocJar".
Rooty injects the following properties into root project:
ext {
generateSources = true
generateJavadoc = true
groovy_version = '2.2.2'
junit_version = '4.11'
spock_version = '0.7-groovy-2.0'
logback_version = '1.1.1'
slf4j_version = '1.7.6'
logback = "ch.qos.logback:logback-classic:$logback_version"
slf4j_api = "org.slf4j:slf4j-api:$slf4j_version"
}
By default all library projects inherit these properties.
You can override any of these properties either by redefining them in the root project or in any (or every) library project, for example, like this:
ext {
generateSources = false
}
Rooty injects the following dependencies into library projects:
dependencies {
// injected if project has groovy nature
compile "org.codehaus.groovy:groovy-all:${project.groovy_version}"
// the following 3 dependencies are injected if project has "test" task
testCompile "junit:junit:${project.junit_version}"
testCompile "org.codehaus.groovy:groovy-all:${project.groovy_version}"
testCompile "org.spockframework:spock-core:${project.spock_version}"
}
Please note that neither logback nor slf4j-api are injected. However, the relevant injected properties somewhat simplify corresponding declarations:
dependencies {
compile logback
compile slf4j_api
}
Copyright 2014 (c) Andrey Hihlovskiy
All versions, present and past, of rooty are licensed under MIT license.