diff --git a/build.gradle b/build.gradle index 5ae8a67c..666dae29 100644 --- a/build.gradle +++ b/build.gradle @@ -4,12 +4,18 @@ group = "com.netflix.${project.name}" apply plugin:'eclipse-wtp' buildscript { - repositories { mavenCentral() } + repositories { + mavenLocal() + mavenCentral() // maven { url 'http://jcenter.bintray.com' } + } apply from: file('gradle/buildscript.gradle'), to: buildscript } allprojects { - repositories { mavenCentral() } + repositories { + mavenLocal() + mavenCentral() // maven { url: 'http://jcenter.bintray.com' } + } } apply from: file('gradle/convention.gradle') @@ -69,7 +75,6 @@ tasks.withType(Compile) { artifacts { archives tasks.jar } - import nl.javadude.gradle.plugins.license.License tasks.withType(License).each { licenseTask -> licenseTask.exclude '**/*.json' diff --git a/codequality/checkstyle.xml b/codequality/checkstyle.xml index 1f0e4873..ed976f9f 100644 --- a/codequality/checkstyle.xml +++ b/codequality/checkstyle.xml @@ -128,8 +128,6 @@ - - diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle index 4d6a29aa..0b6da7ce 100644 --- a/gradle/buildscript.gradle +++ b/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' } diff --git a/gradle/check.gradle b/gradle/check.gradle index 799a6232..5b87a40e 100644 --- a/gradle/check.gradle +++ b/gradle/check.gradle @@ -1,14 +1,15 @@ // Checkstyle apply plugin: 'checkstyle' -tasks.withType(Checkstyle) { ignoreFailures = true } checkstyle { - ignoreFailures = true // Waiting on GRADLE-2163 + ignoreFailures = true configFile = rootProject.file('codequality/checkstyle.xml') } // FindBugs apply plugin: 'findbugs' -//tasks.withType(Findbugs) { reports.html.enabled true } +findbugs { + ignoreFailures = true +} // PMD apply plugin: 'pmd' diff --git a/gradle/convention.gradle b/gradle/convention.gradle index a686afff..11f02c9a 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -1,9 +1,9 @@ -apply plugin: 'java' // Plugin as major conventions +apply plugin: 'java' // Plugin as major conventions, overwrites status sourceCompatibility = 1.6 // GRADLE-2087 workaround, perform after java plugin -status = version.contains('-SNAPSHOT')?'snapshot':'release' +status = project.hasProperty('preferredStatus')?project.preferredStatus:(version.contains('SNAPSHOT')?'snapshot':'release') // Indenting to align with multi-project branch task sourcesJar(type: Jar, dependsOn:classes) { @@ -45,9 +45,6 @@ status = version.contains('-SNAPSHOT')?'snapshot':'release' } } - // 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.' @@ -63,7 +60,28 @@ status = version.contains('-SNAPSHOT')?'snapshot':'release' test.runtimeClasspath += project.configurations.provided } +apply plugin: 'github-pages' // Used to create publishGhPages task + +def docTasks = [:] +[Javadoc,ScalaDoc,Groovydoc].each{ Class docClass -> + tasks.withType(docClass).each { docTask -> + docTasks[docTask.name] = 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' } diff --git a/gradle/license.gradle b/gradle/license.gradle index b0602a09..59b75b39 100644 --- a/gradle/license.gradle +++ b/gradle/license.gradle @@ -4,4 +4,5 @@ apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin license { header rootProject.file('codequality/HEADER') ext.year = Calendar.getInstance().get(Calendar.YEAR) + skipExistingHeaders true } diff --git a/gradle/maven.gradle b/gradle/maven.gradle index 55234218..c850da32 100644 --- a/gradle/maven.gradle +++ b/gradle/maven.gradle @@ -14,20 +14,27 @@ signing { */ task uploadMavenCentral(type:Upload, dependsOn: signArchives) { configuration = configurations.archives - doFirst { + onlyIf { ['release', 'snapshot'].contains(project.status) } repositories.mavenDeployer { - beforeDeployment { org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) } + beforeDeployment { signing.signPom(it) } // To test deployment locally, use the following instead of oss.sonatype.org //repository(url: "file://localhost/${rootProject.rootDir}/repo") - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') { - authentication(userName: rootProject.sonatypeUsername, password: rootProject.sonatypePassword) - } + def sonatypeUsername = rootProject.hasProperty('sonatypeUsername')?rootProject.sonatypeUsername:'' + def sonatypePassword = rootProject.hasProperty('sonatypePassword')?rootProject.sonatypePassword:'' - // Prevent datastamp from being appending to artifacts during deployment - uniqueVersion = false + repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') { + 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 + uniqueVersion = false + // Closure to configure all the POM with extra info, common to all projects pom.project { name "${project.name}" @@ -58,6 +65,5 @@ task uploadMavenCentral(type:Upload, dependsOn: signArchives) { } } } - } } diff --git a/gradle/release.gradle b/gradle/release.gradle index f008515a..6e3c20e8 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -1,50 +1,54 @@ 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 -preTagCommit.dependsOn build -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 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") } } +uploadArtifactory.dependsOn(verifyStatus) +uploadMavenCentral.dependsOn(verifyStatus) + +// Ensure upload happens before taggging, hence upload failures will leave repo in a revertable state +preTagCommit.dependsOn([uploadArtifactory, uploadMavenCentral]) + -project.uploadMavenCentral.dependsOn rootProject.checkSnapshotDependencies -rootProject.createReleaseTag.dependsOn project.uploadMavenCentral 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') + 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' } } @@ -52,11 +56,5 @@ gradle.taskGraph.whenReady { taskGraph -> 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 } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f1e239c..faa569a9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9829a99a..061b536b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#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.1-bin.zip +distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip diff --git a/gradlew b/gradlew index e61422d0..91a7e269 100755 --- a/gradlew +++ b/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