diff options
author | Shevek <[email protected]> | 2013-12-27 05:49:13 -0800 |
---|---|---|
committer | Shevek <[email protected]> | 2013-12-27 05:49:13 -0800 |
commit | bdc6c852f418c3e042aa41469d84544e5f60a526 (patch) | |
tree | 7866346f0fa48ad46a6a427d016dd4b83451dbbe /gradle | |
parent | 39264fd6d2a6646e49f83b5b2b3512c1663a1c9b (diff) |
Version bump to 1.4.0-SNAPSHOT.
Rewrite build system to use gradle.
Clean up source for the new generation.
Diffstat (limited to 'gradle')
-rw-r--r-- | gradle/buildscript.gradle | 11 | ||||
-rw-r--r-- | gradle/check.gradle | 25 | ||||
-rw-r--r-- | gradle/convention.gradle | 88 | ||||
-rw-r--r-- | gradle/license.gradle | 8 | ||||
-rw-r--r-- | gradle/maven.gradle | 69 | ||||
-rw-r--r-- | gradle/netflix-oss.gradle | 1 | ||||
-rw-r--r-- | gradle/release.gradle | 60 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.jar | bin | 0 -> 50557 bytes | |||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 6 |
9 files changed, 268 insertions, 0 deletions
diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle new file mode 100644 index 0000000..3163aa9 --- /dev/null +++ b/gradle/buildscript.gradle @@ -0,0 +1,11 @@ +// Executed in context of buildscript +repositories { + // Repo in addition to maven central + 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.1' + classpath 'com.mapvine:gradle-cobertura-plugin:0.1' + // 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 new file mode 100644 index 0000000..78f8180 --- /dev/null +++ b/gradle/check.gradle @@ -0,0 +1,25 @@ +// Checkstyle +// apply plugin: 'checkstyle' +// checkstyle { +// ignoreFailures = true +// configFile = rootProject.file('codequality/checkstyle.xml') +// } + +// FindBugs +apply plugin: 'findbugs' +findbugs { + ignoreFailures = true +} +findbugsTest.enabled = false + +// 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 = [] +} diff --git a/gradle/convention.gradle b/gradle/convention.gradle new file mode 100644 index 0000000..22023ea --- /dev/null +++ b/gradle/convention.gradle @@ -0,0 +1,88 @@ +apply plugin: 'java' // Plugin as major conventions, overwrites status + +sourceCompatibility = 1.5 + +// GRADLE-2087 workaround, perform after java plugin +status = project.hasProperty('preferredStatus')?project.preferredStatus:(version.contains('SNAPSHOT')?'snapshot':'release') + +// Indenting to align with multi-project branch + task sourcesJar(type: Jar, dependsOn:classes) { + from sourceSets.main.allSource + classifier 'sources' + extension 'jar' + } + + task javadocJar(type: Jar, dependsOn:javadoc) { + from javadoc.destinationDir + classifier 'javadoc' + extension 'jar' + } + + configurations.add('sources') + configurations.add('javadoc') + configurations.archives { + extendsFrom configurations.sources + extendsFrom configurations.javadoc + } + + // When outputing to an Ivy repo, we want to use the proper type field + gradle.taskGraph.whenReady { + def isNotMaven = !it.hasTask(project.uploadMavenCentral) + if (isNotMaven) { + def artifacts = project.configurations.sources.artifacts + def sourceArtifact = artifacts.iterator().next() + sourceArtifact.type = 'sources' + } + } + + artifacts { + sources(sourcesJar) { + // Weird Gradle quirk where type will be used for the extension, but only for sources + type 'jar' + } + javadoc(javadocJar) { + type 'javadoc' + } + } + + 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.' + transitive = true + visible = true + } + } + + project.sourceSets { + main.compileClasspath += project.configurations.provided + main.runtimeClasspath -= project.configurations.provided + test.compileClasspath += project.configurations.provided + 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 = "[email protected]:Netflix/${rootProject.githubProjectName}.git" + pages { + docTasks.each { shortName, docTask -> + from(docTask.outputs.files) { + into "docs/${shortName}" + } + } + } +} +*/ + +wrapper { + gradleVersion = '1.10' +} diff --git a/gradle/license.gradle b/gradle/license.gradle new file mode 100644 index 0000000..59b75b3 --- /dev/null +++ b/gradle/license.gradle @@ -0,0 +1,8 @@ +// Dependency for plugin was set in buildscript.gradle + +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 new file mode 100644 index 0000000..0513719 --- /dev/null +++ b/gradle/maven.gradle @@ -0,0 +1,69 @@ +// Maven side of things +apply plugin: 'maven' // Java plugin has to have been already applied for the conf2scope mappings to work +apply plugin: 'signing' + +signing { + required { gradle.taskGraph.hasTask(uploadMavenCentral) } + sign configurations.archives +} + +/** + * 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: 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}" + description "Java C Preprocessor" + developers { + developer { + id 'shevek' + name 'Shevek' + email '[email protected]' + } + } + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' + } + } + url "https://github.com/shevek/${rootProject.githubProjectName}" + scm { + connection "scm:git:[email protected]:shevek/${rootProject.githubProjectName}.git" + url "scm:git:[email protected]:shevek/${rootProject.githubProjectName}.git" + developerConnection "scm:git:[email protected]:shevek/${rootProject.githubProjectName}.git" + } + issueManagement { + system 'github' + url "https://github.com/shevek/${rootProject.githubProjectName}/issues" + } + } + } +} + diff --git a/gradle/netflix-oss.gradle b/gradle/netflix-oss.gradle new file mode 100644 index 0000000..a87bc54 --- /dev/null +++ b/gradle/netflix-oss.gradle @@ -0,0 +1 @@ +apply from: 'http://artifacts.netflix.com/gradle-netflix-local/artifactory.gradle' diff --git a/gradle/release.gradle b/gradle/release.gradle new file mode 100644 index 0000000..6e3c20e --- /dev/null +++ b/gradle/release.gradle @@ -0,0 +1,60 @@ +apply plugin: 'release' + +[ 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 ] + } +} + +// 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]) + + +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 { + git.requireBranch = null +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..5838598 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..40aa5f8 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Dec 27 05:48:20 PST 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip |