Skip to content
Browse files

Merge remote-tracking branch 'gradle-template/multi-project'

Conflicts:
	build.gradle
	gradle/wrapper/gradle-wrapper.properties
  • Loading branch information...
2 parents aadec23 + 6df65bf commit 90093540e11321a46454cb5c8ddae4aa22f42485 Ben Christensen committed Jul 26, 2013
View
9 build.gradle
@@ -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')
View
1 codequality/checkstyle.xml
@@ -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">
View
10 gradle/buildscript.gradle
@@ -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'
}
View
41 gradle/check.gradle
@@ -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 = []
+}
}
View
48 gradle/convention.gradle
@@ -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) {
@@ -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.'
@@ -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 = "git@github.com: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'
}
View
1 gradle/license.gradle
@@ -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
}
}
View
28 gradle/maven.gradle
@@ -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
@@ -58,5 +67,4 @@ subprojects {
}
}
}
- }
}
View
82 gradle/release.gradle
@@ -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
}
View
BIN gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
View
5 gradle/wrapper/gradle-wrapper.properties
@@ -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
+
View
6 gradlew
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
##############################################################################
##
@@ -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

0 comments on commit 9009354

Please sign in to comment.
Something went wrong with that request. Please try again.