Skip to content

Commit

Permalink
Merge remote-tracking branch 'gradle-template/multi-project'
Browse files Browse the repository at this point in the history
Conflicts:
	build.gradle
	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information
benjchristensen committed Jul 26, 2013
2 parents aadec23 + 6df65bf commit 9009354
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 102 deletions.
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
ext.githubProjectName = rootProject.name

buildscript {
repositories { mavenCentral() }
repositories {
mavenLocal()
mavenCentral() // maven { url 'http://jcenter.bintray.com' }
}
apply from: file('gradle/buildscript.gradle'), to: buildscript
}

allprojects {
repositories { mavenCentral() }
repositories {
mavenCentral() // maven { url: 'http://jcenter.bintray.com' }
}
}

apply from: file('gradle/convention.gradle')
Expand Down
1 change: 0 additions & 1 deletion codequality/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!-- <module name="AvoidInlineConditionals"/> -->
<module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
Expand Down
10 changes: 4 additions & 6 deletions gradle/buildscript.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Executed in context of buildscript
repositories {
// Repo in addition to maven central
maven {
name 'build-repo'
url 'https://raw.github.com/Netflix-Skunkworks/build-repo/master/releases/' // gradle-release/gradle-release/1.0-SNAPSHOT/gradle-release-1.0-SNAPSHOT.jar
}
repositories { maven { url 'http://dl.bintray.com/content/netflixoss/external-gradle-plugins/' } } // For gradle-release
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.0'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.1'
classpath 'com.mapvine:gradle-cobertura-plugin:0.1'
classpath 'gradle-release:gradle-release:1.0-SNAPSHOT'
classpath 'gradle-release:gradle-release:1.1.5'
classpath 'org.ajoberstar:gradle-git:0.5.0'
}
41 changes: 21 additions & 20 deletions gradle/check.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
subprojects {
// Checkstyle
apply plugin: 'checkstyle'
tasks.withType(Checkstyle) { ignoreFailures = true }
checkstyle {
ignoreFailures = true // Waiting on GRADLE-2163
configFile = rootProject.file('codequality/checkstyle.xml')
}
// Checkstyle
apply plugin: 'checkstyle'
checkstyle {
ignoreFailures = true
configFile = rootProject.file('codequality/checkstyle.xml')
}

// FindBugs
apply plugin: 'findbugs'
//tasks.withType(Findbugs) { reports.html.enabled true }
// FindBugs
apply plugin: 'findbugs'
findbugs {
ignoreFailures = true
}

// PMD
apply plugin: 'pmd'
//tasks.withType(Pmd) { reports.html.enabled true }
// PMD
apply plugin: 'pmd'
//tasks.withType(Pmd) { reports.html.enabled true }

apply plugin: 'cobertura'
cobertura {
sourceDirs = sourceSets.main.java.srcDirs
format = 'html'
includes = ['**/*.java', '**/*.groovy']
excludes = []
}
apply plugin: 'cobertura'
cobertura {
sourceDirs = sourceSets.main.java.srcDirs
format = 'html'
includes = ['**/*.java', '**/*.groovy']
excludes = []
}
}
48 changes: 33 additions & 15 deletions gradle/convention.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@

// For Artifactory
rootProject.status = version.contains('-SNAPSHOT')?'snapshot':'release'
// GRADLE-2087 workaround, perform after java plugin
status = project.hasProperty('preferredStatus')?project.preferredStatus:(version.contains('SNAPSHOT')?'snapshot':'release')

subprojects { project ->
apply plugin: 'java' // Plugin as major conventions

version = rootProject.version

sourceCompatibility = 1.6

// GRADLE-2087 workaround, perform after java plugin
// Restore status after Java plugin
status = rootProject.status

task sourcesJar(type: Jar, dependsOn:classes) {
Expand Down Expand Up @@ -51,9 +48,6 @@ subprojects { project ->
}
}

// Ensure output is on a new line
javadoc.doFirst { println "" }

configurations {
provided {
description = 'much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive.'
Expand All @@ -70,14 +64,38 @@ subprojects { project ->
}
}

task aggregateJavadoc(type: Javadoc) {
description = 'Aggregate all subproject docs into a single docs directory'
source subprojects.collect {project -> project.sourceSets.main.allJava }
classpath = files(subprojects.collect {project -> project.sourceSets.main.compileClasspath})
destinationDir = new File(projectDir, 'doc')
apply plugin: 'github-pages' // Used to create publishGhPages task

def docTasks = [:]
[Javadoc,ScalaDoc,Groovydoc].each{ Class docClass ->
def allSources = allprojects.tasks*.withType(docClass).flatten()*.source
if (allSources) {
def shortName = docClass.simpleName.toLowerCase()
def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") {
source = allSources
destinationDir = file("${project.buildDir}/docs/${shortName}")
doFirst {
def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { it.sourceSets.main.compileClasspath }
classpath = files(classpaths)
}
}
docTasks[shortName] = docTask
processGhPages.dependsOn(docTask)
}
}

githubPages {
repoUri = "[email protected]:Netflix/${rootProject.githubProjectName}.git"
pages {
docTasks.each { shortName, docTask ->
from(docTask.outputs.files) {
into "docs/${shortName}"
}
}
}
}

// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle
task createWrapper(type: Wrapper) {
gradleVersion = '1.1'
gradleVersion = '1.5'
}
1 change: 1 addition & 0 deletions gradle/license.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin
license {
header rootProject.file('codequality/HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
skipExistingHeaders true
}
}
28 changes: 18 additions & 10 deletions gradle/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,29 @@ subprojects {
sign configurations.archives
}

/**
* Publishing to Maven Central example provided from http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html
*/
task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
configuration = configurations.archives
doFirst {
repositories.mavenDeployer {
beforeDeployment { org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) }
/**
* Publishing to Maven Central example provided from http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html
* artifactory will execute uploadArchives to force generation of ivy.xml, and we don't want that to trigger an upload to maven
* central, so using custom upload task.
*/
task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
configuration = configurations.archives
onlyIf { ['release', 'snapshot'].contains(project.status) }
repositories.mavenDeployer {
beforeDeployment { signing.signPom(it) }

// To test deployment locally, use the following instead of oss.sonatype.org
//repository(url: "file://localhost/${rootProject.rootDir}/repo")

def sonatypeUsername = rootProject.hasProperty('sonatypeUsername')?rootProject.sonatypeUsername:''
def sonatypePassword = rootProject.hasProperty('sonatypePassword')?rootProject.sonatypePassword:''

repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
authentication(userName: rootProject.sonatypeUsername, password: rootProject.sonatypePassword)
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

// Prevent datastamp from being appending to artifacts during deployment
Expand Down Expand Up @@ -58,5 +67,4 @@ subprojects {
}
}
}
}
}
82 changes: 39 additions & 43 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -1,65 +1,61 @@
apply plugin: 'release'

// Ignore release plugin's task because it calls out via GradleBuild. This is a good place to put an email to send out
task release(overwrite: true, dependsOn: commitNewVersion) << {
// This is a good place to put an email to send out
}
commitNewVersion.dependsOn updateVersion
updateVersion.dependsOn createReleaseTag
createReleaseTag.dependsOn preTagCommit
def buildTasks = tasks.matching { it.name =~ /:build/ }
preTagCommit.dependsOn buildTasks
preTagCommit.dependsOn checkSnapshotDependencies
//checkSnapshotDependencies.dependsOn confirmReleaseVersion // Introduced in 1.0, forces readLine
//confirmReleaseVersion.dependsOn unSnapshotVersion
checkSnapshotDependencies.dependsOn unSnapshotVersion // Remove once above is fixed
unSnapshotVersion.dependsOn checkUpdateNeeded
checkUpdateNeeded.dependsOn checkCommitNeeded
checkCommitNeeded.dependsOn initScmPlugin

[
uploadIvyLocal: 'uploadLocal',
uploadArtifactory: 'artifactoryPublish', // Call out to compile against internal repository
buildWithArtifactory: 'build' // Build against internal repository
].each { key, value ->
[ uploadIvyLocal: 'uploadLocal', uploadArtifactory: 'artifactoryPublish', buildWithArtifactory: 'build' ].each { key, value ->
// Call out to compile against internal repository
task "${key}"(type: GradleBuild) {
startParameter = project.gradle.startParameter.newInstance()
doFirst {
startParameter.projectProperties = [status: project.status, preferredStatus: project.status]
}
startParameter.addInitScript( file('gradle/netflix-oss.gradle') )
startParameter.getExcludedTaskNames().add('check')
tasks = [ 'build', value ]
}
}
task releaseArtifactory(dependsOn: [checkSnapshotDependencies, uploadArtifactory])

// Ensure upload happens before taggging but after all pre-checks
releaseArtifactory.dependsOn checkSnapshotDependencies
createReleaseTag.dependsOn releaseArtifactory
gradle.taskGraph.whenReady { taskGraph ->
if ( taskGraph.hasTask(uploadArtifactory) && rootProject.status == 'release' && !taskGraph.hasTask(':release') ) {
throw new GradleException('"release" task has to be run before uploading a release to Artifactory')
// Marker task for following code to key in on
task releaseCandidate(dependsOn: release)
task forceCandidate {
onlyIf { gradle.taskGraph.hasTask(releaseCandidate) }
doFirst { project.status = 'candidate' }
}
task forceRelease {
onlyIf { !gradle.taskGraph.hasTask(releaseCandidate) }
doFirst { project.status = 'release' }
}
release.dependsOn([forceCandidate, forceRelease])

task uploadMavenCentral(dependsOn: subprojects.tasks.uploadMavenCentral)
task releaseSnapshot(dependsOn: [uploadArtifactory, uploadMavenCentral])

// Ensure our versions look like the project status before publishing
task verifyStatus << {
def hasSnapshot = version.contains('-SNAPSHOT')
if (project.status == 'snapshot' && !hasSnapshot) {
throw new GradleException("Version (${version}) needs -SNAPSHOT if publishing snapshot")
}
}
subprojects.each { project ->
project.uploadMavenCentral.dependsOn rootProject.checkSnapshotDependencies
rootProject.createReleaseTag.dependsOn project.uploadMavenCentral
uploadArtifactory.dependsOn(verifyStatus)
uploadMavenCentral.dependsOn(verifyStatus)

gradle.taskGraph.whenReady { taskGraph ->
if ( taskGraph.hasTask(project.uploadMavenCentral) && !taskGraph.hasTask(':release') ) {
throw new GradleException('"release" task has to be run before uploading to Maven Central')
}
// Ensure upload happens before taggging, hence upload failures will leave repo in a revertable state
preTagCommit.dependsOn([uploadArtifactory, uploadMavenCentral])


gradle.taskGraph.whenReady { taskGraph ->
def hasRelease = taskGraph.hasTask('commitNewVersion')
def indexOf = { return taskGraph.allTasks.indexOf(it) }

if (hasRelease) {
assert indexOf(build) < indexOf(unSnapshotVersion), 'build target has to be after unSnapshotVersion'
assert indexOf(uploadMavenCentral) < indexOf(preTagCommit), 'preTagCommit has to be after uploadMavenCentral'
assert indexOf(uploadArtifactory) < indexOf(preTagCommit), 'preTagCommit has to be after uploadArtifactory'
}
}

// Prevent plugin from asking for a version number interactively
ext.'gradle.release.useAutomaticVersion' = "true"

release {
// http://tellurianring.com/wiki/gradle/release
failOnCommitNeeded=true
failOnPublishNeeded=true
failOnUnversionedFiles=true
failOnUpdateNeeded=true
includeProjectNameInTag=true
requireBranch = null
git.requireBranch = null
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Tue Aug 14 16:28:54 PDT 2012
#Tue Apr 02 11:45:56 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.3-bin.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip

6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

##############################################################################
##
Expand Down Expand Up @@ -61,9 +61,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down

0 comments on commit 9009354

Please sign in to comment.