Skip to content

Commit

Permalink
GEODE-781: Update maven publishing to include signatures
Browse files Browse the repository at this point in the history
The maven-publish plugin does not grok signature nor sign pom
files.  These are needed for publishing release versions on Maven
Central.  Switching over to the nexus plugin simplified signing,
generation of javadoc / sources jars, and publishing.

To publish to the local maven repository (~/.m2/repository):
  gradle install

To publish to the snapshot / release repositories:
  gradle uploadArtifacts

Signatures will only be created if the following properties are set
in ~/.gradle.properties:
  signing.keyId
  signing.secretKeyRingFile
  signing.password

To upload the artifacts to Maven, you will need to set the following
properties in ~/.gradle/gradle.properties:
  nexusUsername
  nexusPassword
  • Loading branch information
metatype committed Jan 16, 2016
1 parent e2c35d7 commit e9bf253
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 141 deletions.
75 changes: 49 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
classpath "gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.0"
classpath "org.ajoberstar:gradle-git:1.3.2"
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
}
}

Expand Down Expand Up @@ -110,17 +111,6 @@ gradle.taskGraph.whenReady({ graph ->

subprojects {
apply plugin: 'java'
apply plugin: 'signing'

// set these properties in ~/.gradle/gradle.properties file:
// signing.keyId
// signing.password
// signing.secretKeyRingFile
if (isReleaseVersion) {
signing {
sign configurations.archives
}
}

// apply compiler options
gradle.taskGraph.whenReady( { graph ->
Expand Down Expand Up @@ -309,20 +299,8 @@ subprojects {
classifier 'test'
}

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

task javadocJar(type: Jar, dependsOn: javadoc) {
description 'Assembles a jar archive of javadocs.'
from javadoc.destinationDir
classifier = 'javadoc'
}

artifacts {
testOutput jarTest
archives sourcesJar, javadocJar
}

sourceSets {
Expand Down Expand Up @@ -495,6 +473,51 @@ subprojects {
}
})

// publishing configuration
apply plugin: 'com.bmuschko.nexus'
apply plugin: 'maven-publish-auth'

extraArchive {
sources = true
javadoc = true
tests = false
}

nexus {
sign = true
repositoryUrl = 'https://repository.apache.org/service/local/staging/deploy/maven2'
snapshotRepositoryUrl = 'https://repository.apache.org/content/repositories/snapshots'
}

modifyPom {
project {
name 'Apache Geode (incubating)'
description 'Apache Geode (incubating) provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing'
url 'http://geode.incubator.apache.org'

scm {
url 'https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;a=tree'
connection 'scm:https://git-wip-us.apache.org/repos/asf/incubator-geode.git'
developerConnection 'scm:https://git-wip-us.apache.org/repos/asf/incubator-geode.git'
}

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

repositories {
repository {
id 'libs-release'
name 'Spring Maven libs-release Repository'
url 'http://repo.spring.io/libs-release'
}
}
}
}

// Make precheckin task run all validation tests for checking in code.
task precheckin (dependsOn: [ build, integrationTest, distributedTest ]) {
description 'Run this task before checking in code to validate changes. This task combines the following tasks: build, integrationTest, and distributedTest'
Expand Down
119 changes: 19 additions & 100 deletions gemfire-assembly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
*/
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact;

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.hibernate.build.gradle', name: 'gradle-maven-publish-auth', version: project.'gradle-maven-publish-auth.version'
}
}

apply plugin: 'distribution'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'

jar.enabled = false
extraArchive {
sources = false
javadoc = false
tests = false
}

configurations {
archives
// We are not publishing anything from this project into maven and using two distributions seems
// to break the nexus plugin. So we delete the nexus tasks but we have to replace the upload task
// with an empty task of the same name...argh.
afterEvaluate {
tasks.remove(install)
tasks.remove(uploadArchives)
task uploadArchives << { }
}

// gradle doesn't automatically remove the jar artifact even though we disabled it
// this causes the signing plugin to fail
// Gradle doesn't automatically remove the jar artifact even though we disabled it
// this causes publishing to fail. So we nuke all the disabled artifacts from all configurations.
configurations.all {
artifacts.removeAll artifacts.findAll { it instanceof ArchivePublishArtifact && !it.archiveTask.enabled }
}
Expand Down Expand Up @@ -191,13 +191,6 @@ gradle.taskGraph.whenReady( { graph ->
archive.doLast {
ant.checksum file:"${archive.archivePath}", algorithm:"md5"
ant.checksum file:"${archive.archivePath}", algorithm:"sha-256"

if (isReleaseVersion) {
signing {
required { isReleaseVersion }
sign archive.archivePath
}
}
}
}
})
Expand Down Expand Up @@ -263,12 +256,15 @@ distributions {
include 'spring-data-gemfire-*'
}
from project(":gemfire-core").configurations.archives.allArtifacts.files

from project(":gemfire-core").webJar
from project(":gemfire-core").raJar
from project(":gemfire-core").jcaJar

from project(":gemfire-lucene").configurations.runtime
from project(":gemfire-lucene").configurations.archives.allArtifacts.files

// include this jar
from project(":gemfire-web-api").jar.outputs.files.getFiles()
from project(":gemfire-web-api").jar

// dependency jars
from depsJar
Expand All @@ -287,79 +283,6 @@ distributions {
}
}


// Repos to be added to POMs
def springReleaseRepo = [ id:'spring-release', name:'Spring Maven RELEASE Repository', url:'https://repo.spring.io/release' ]
def springMilestoneRepo = [ id:'spring-milestone', name:'Spring Maven MILESTONE Repository', url:'https://repo.spring.io/milestone' ]
def springSnapshotRepo = [ id:'spring-snapshot', name:'Spring Maven SNAPSHOT Repository', url:'https://repo.spring.io/snapshot' ]
def springLibsReleaseRepo = [ id:'libs-release', name:'Spring Maven libs-release Repository', url:'http://repo.spring.io/libs-release' ]
def springExtReleaseLocalRepo = [ id:'ext-release-local', name:'Spring Maven ext-release-local Repository', url:'http://repo.spring.io/ext-release-local' ]

def MavenRepos = [ springReleaseRepo, springSnapshotRepo, springLibsReleaseRepo, springExtReleaseLocalRepo ]

// Jars to be published via Maven
def commonJar = [publicationName:'commonJar', project:project(":gemfire-common").name]
def coreJar = [publicationName:'coreJar', project:project(":gemfire-core").name]
def jsonJar = [publicationName:'jsonJar', project:project(":gemfire-json").name]
def joptsimpleJar = [publicationName:'joptsimpleJar', project:project(":gemfire-joptsimple").name]
def luceneJar = [publicationName:'luceneJar', project:project(":gemfire-lucene").name]
def MavenJars = [ coreJar, jsonJar, joptsimpleJar, commonJar, luceneJar ]

afterEvaluate {
publishing {
publications {
MavenJars.each {
def publicationName = it.publicationName
def projectName = it.project
"$publicationName"(MavenPublication) {
artifactId projectName
artifact project(':' + projectName).jar
pom.withXml {
def repositoriesNode = asNode().appendNode('repositories')
MavenRepos.each {
def repositoryNode = repositoriesNode.appendNode('repository')
repositoryNode.appendNode('id', it.id)
repositoryNode.appendNode('name', it.name)
repositoryNode.appendNode('url', it.url)
}
def dependenciesNode = asNode().appendNode('dependencies')
//Iterate over the runtime dependencies
project(':' + projectName).configurations.runtime.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}

// The following is typically defined in a root ASF pom: org.apache:apache
// If anything breaks around publishing check that we're still synchronized
// with whatever Maven repo definitions are there. Pay special attention to
// the names of the repositories -- they need to be spelled exactly like
// the ones defined in root ASF pom
publishing {
repositories {
if (!isReleaseVersion) {
// Apache Development Snapshot Repository
maven {
name "apache.snapshots.https"
url "https://repository.apache.org/content/repositories/snapshots"
}
} else {
// Apache Release Distribution Repository
maven {
name "apache.releases.https"
url "https://repository.apache.org/service/local/staging/deploy/maven2"
}
}
}
}
}

// Create a configuration closure to configure test targets with the install directory
def dependOnInstalledProduct = {
dependsOn installDist
Expand All @@ -371,9 +294,5 @@ def dependOnInstalledProduct = {
test dependOnInstalledProduct
distributedTest dependOnInstalledProduct

artifacts {
archives depsJar, gfshDepsJar
}

// Make build final task to generate all test and product resources
build.dependsOn installDist
4 changes: 0 additions & 4 deletions gemfire-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ task jcaJar (type: Jar, dependsOn: raJar) {
from raJar.archivePath
}

artifacts {
archives webJar, raJar, jcaJar
}

configurations {
classesOutput {
extendsFrom compile
Expand Down
4 changes: 0 additions & 4 deletions gemfire-web-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ jar {
from sourceSets.main.output
}

artifacts {
archives jar
}

war {
classpath configurations.runtime
}
Expand Down
4 changes: 0 additions & 4 deletions gemfire-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ idea.module.iml {
}
}

artifacts {
archives jar
}

war {
classpath configurations.runtime
classpath project(':gemfire-core').webJar.archivePath
Expand Down
3 changes: 0 additions & 3 deletions gradle/dependency-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Buildscript Dependencies
gradle-maven-publish-auth.version = 2.0.1

# Dependency versions
activation.version = 1.1.1
annotations.version = 3.0.0
Expand Down

0 comments on commit e9bf253

Please sign in to comment.