Skip to content

Commit

Permalink
Merge remote-tracking branch 'build/multi-project'
Browse files Browse the repository at this point in the history
Conflicts:
	build.gradle
	gradle/check.gradle
	gradle/convention.gradle
	gradle/maven.gradle
	settings.gradle
  • Loading branch information
Justin Ryan committed Dec 29, 2012
2 parents 4978d78 + 36e5b8f commit e9642f7
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 177 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Thumbs.db
# Editor Files #
################
*~
*.swp

# Gradle Files #
################
Expand All @@ -44,8 +45,8 @@ Thumbs.db
*/target
/build
*/build
#
# # IntelliJ specific files/directories

# IntelliJ specific files/directories
out
.idea
*.ipr
Expand Down
38 changes: 7 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,50 +1,26 @@
// Establish version and status
ext.releaseVersion = '0.5.2'
ext.githubProjectName = 'archaius'
//group = 'com.netflix.archaius'
ext.githubProjectName = rootProject.name // Change if github project name is not the same as the root project's name

buildscript {
repositories { mavenCentral() }
apply from: file('gradle/buildscript.gradle'), to: buildscript
}

allprojects {
repositories { mavenCentral() }
}

//apply from: file('gradle/release.gradle') // Not fully tested
apply from: file('gradle/convention.gradle')
apply from: file('gradle/maven.gradle')
apply from: file('gradle/check.gradle')
//apply from: file('gradle/license.gradle') // Waiting for re-release
apply from: file('gradle/license.gradle')
apply from: file('gradle/release.gradle')

subprojects {
// Closure to configure all the POM with extra info, common to all projects
pom {
project {
url "https://github.com/Netflix/${githubProjectName}"
scm {
connection "scm:git:[email protected]:Netflix/${githubProjectName}.git"
url "scm:git:[email protected]:Netflix/${githubProjectName}.git"
developerConnection "scm:git:[email protected]:Netflix/${githubProjectName}.git"
}
issueManagement {
system 'github'
url "https://github.com/Netflix/${githubProjectName}/issues"
}
}
}
group = "com.netflix.${githubProjectName}" // TEMPLATE: Set to organization of project
}
group = "com.netflix.${githubProjectName}"

task javadoc(type: Javadoc) {
source subprojects.collect { project ->
project.sourceSets.main.allJava
}
destinationDir = new File(buildDir, 'javadoc')
// Might need a classpath
classpath = files(subprojects.collect { project ->
project.sourceSets.main.compileClasspath
})
apply plugin: 'java'
tasks.withType(Test) { forkEvery = 1 }
}

project(':archaius-core') {
Expand Down
2 changes: 1 addition & 1 deletion codequality/HEADER
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2012 Netflix, Inc.
Copyright ${year} Netflix, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=0.5.2-SNAPSHOT
13 changes: 13 additions & 0 deletions gradle/buildscript.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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
}
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.0'
classpath 'com.mapvine:gradle-cobertura-plugin:0.1'
classpath 'gradle-release:gradle-release:1.0-SNAPSHOT'
}
15 changes: 11 additions & 4 deletions gradle/check.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
subprojects {
/*
// Checkstyle
apply plugin: 'checkstyle'
tasks.withType(Checkstyle) { ignoreFailures = true }
checkstyle {
ignoreFailures = true // Waiting on GRADLE-2163
configFile = rootProject.file('codequality/checkstyle.xml')
}*/
}
*/

// FindBugs
apply plugin: 'findbugs'
tasks.withType(FindBugs) {
reports.html.enabled true
reports.html.enabled true
reports.xml.enabled false
}

// PMD
// apply plugin: 'pmd'
// tasks.withType(Pmd) { ignoreFailures = true }

apply plugin: 'java'
tasks.withType(Test) { forkEvery = 1 }
apply plugin: 'cobertura'
cobertura {
sourceDirs = sourceSets.main.java.srcDirs
format = 'html'
includes = ['**/*.java', '**/*.groovy']
excludes = []
}
}
76 changes: 55 additions & 21 deletions gradle/convention.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

ext.performingRelease = project.hasProperty('release') && Boolean.parseBoolean(project.release)
def versionPostfix = performingRelease?'':'-SNAPSHOT'
version = "${releaseVersion}${versionPostfix}"
status = performingRelease?'release':'snapshot'
// For Artifactory
rootProject.status = version.contains('-SNAPSHOT')?'snapshot':'release'

subprojects {
subprojects { project ->
apply plugin: 'java' // Plugin as major conventions
tasks.withType(Test) { forkEvery = 1 }
version = rootProject.version
Expand All @@ -15,35 +13,71 @@ subprojects {
status = rootProject.status

task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
classifier 'sources'
extension 'jar'
}

task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
classifier 'javadoc'
extension 'jar'
}

configurations {
sources
javadoc
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 {
add('sources', sourcesJar) {
classifier 'sources'
type 'sources'
}
archives sourcesJar
archives javadocJar
/*
add('javadoc',javadocJar) {
classifier 'javadoc'
sources(sourcesJar) {
// Weird Gradle quirk where type will be used for the extension, but only for sources
type 'jar'
}
javadoc(javadocJar) {
type 'javadoc'
} */
}
}

// 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.'
transitive = false
visible = false
}
}

project.sourceSets {
main.compileClasspath += project.configurations.provided
main.runtimeClasspath -= project.configurations.provided
test.compileClasspath += project.configurations.provided
test.runtimeClasspath += project.configurations.provided
}
}

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')
}

// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle
task createWrapper(type: Wrapper) {
gradleVersion = '1.0-rc-3'
gradleVersion = '1.1'
}
12 changes: 8 additions & 4 deletions gradle/license.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
buildscript {
dependencies { classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.5' }
}
// Dependency for plugin was set in buildscript.gradle

apply plugin: nl.javadude.gradle.plugins.license.LicensePlugin
subprojects {
apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin
license {
header rootProject.file('codequality/HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
}
39 changes: 23 additions & 16 deletions gradle/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,24 @@ subprojects {
apply plugin: 'maven' // Java plugin has to have been already applied for the conf2scope mappings to work
apply plugin: 'signing'

if (gradle.startParameter.taskNames.contains("uploadMavenCentral")) {
signing {
required true
sign configurations.archives
}
} else {
task signArchives {
// do nothing
}
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
*/
task uploadMavenCentral(type:Upload) {
task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
configuration = configurations.archives
dependsOn 'signArchives'
doFirst {
repositories.mavenDeployer {
beforeDeployment { org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) }

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

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

Expand All @@ -36,10 +29,14 @@ subprojects {

// Closure to configure all the POM with extra info, common to all projects
pom.project {
parent {
groupId 'org.sonatype.oss'
artifactId 'oss-parent'
version '7'
name "${project.name}"
description "${project.name} developed by Netflix"
developers {
developer {
id 'netflixgithub'
name 'Netflix Open Source Development'
email '[email protected]'
}
}
licenses {
license {
Expand All @@ -48,6 +45,16 @@ subprojects {
distribution 'repo'
}
}
url "https://github.com/Netflix/${rootProject.githubProjectName}"
scm {
connection "scm:git:[email protected]:Netflix/${rootProject.githubProjectName}.git"
url "scm:git:[email protected]:Netflix/${rootProject.githubProjectName}.git"
developerConnection "scm:git:[email protected]:Netflix/${rootProject.githubProjectName}.git"
}
issueManagement {
system 'github'
url "https://github.com/Netflix/${rootProject.githubProjectName}/issues"
}
}
}
}
Expand Down
65 changes: 62 additions & 3 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,65 @@
buildscript {
dependencies { classpath group: 'no.entitas.gradle', name: 'gradle-release-plugin', version: '1.11' }
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 ->
// Call out to compile against internal repository
task "${key}"(type: GradleBuild) {
startParameter = project.gradle.startParameter.newInstance()
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')
}
}
subprojects.each { project ->
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')
}
}
}

apply plugin: no.entitas.gradle.git.GitReleasePlugin // 'gitrelease'
// 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
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit e9642f7

Please sign in to comment.