Skip to content

Commit

Permalink
Bump dgraph4j and Gradle versions (#139)
Browse files Browse the repository at this point in the history
Revised build.gradle according to https://central.sonatype.org/pages/gradle.html
to fix Maven Central deployment issues.
  • Loading branch information
aakside authored Apr 1, 2020
1 parent 2b82ed4 commit b4325e2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 83 deletions.
3 changes: 1 addition & 2 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ ossrhPassword=<…password…>
### Deploying
* Build and test the code that needs to be published.
* Bump version by modifying the `version` variable in `build.gradle` file.
* Test the publish process locally by running `./gradlew publishMavenJavaPublicationToMavenLocal`
* Run `./gradlew publish`.
* Run `./gradlew uploadArchives`.
* Release the deployment by following the steps on the page _Releasing the Deployment_ (link in references below).

### References
Expand Down
106 changes: 26 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ apply plugin: 'java'
apply plugin: 'com.google.protobuf'
apply plugin: 'idea'
apply plugin: 'com.github.sherter.google-java-format'
apply plugin: 'maven-publish'
apply plugin: 'maven'
apply plugin: 'signing'

group = 'io.dgraph'
archivesBaseName = 'dgraph4j'
version = '2.1.0'
version = '20.03.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8

Expand Down Expand Up @@ -196,83 +196,37 @@ if(project.hasProperty("ossrhUsername")) {
sign configurations.archives
}

publishing {
publications {
mavenJava(MavenPublication) {
customizePom(pom)
groupId 'io.dgraph'
artifactId 'dgraph4j'
version "${dgraph4jVersion}"

from components.java

pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

artifact(sourceJar) {
classifier = 'sources'
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

artifact(javadocJar) {
classifier = 'javadoc'
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

// create the signed artifacts
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
}
}
}
}
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
}

def customizePom(pom) {
pom.withXml {
def root = asNode()

// add all items necessary for maven central publication
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST

description 'Dgraph Java Client'
name 'dgraph4'
url 'https://github.com/dgraph-io/dgraph4'
licenses {
license {
name 'Apache License 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
pom.project {
name 'dgraph4j'
packaging 'jar'
artifactId 'dgraph4j'
description 'Dgraph Java Client'
url 'https://github.com/dgraph-io/dgraph4j'

scm {
connection 'https://github.com/dgraph-io/dgraph4j.git'
url 'https://github.com/dgraph-io/dgraph4j'
url 'https://github.com/dgraph-io/dgraph4j'
}

licenses {
license {
name 'Apache License 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}

developers {
Expand All @@ -281,20 +235,12 @@ def customizePom(pom) {
}
}
}
}
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}
tasks.publishMavenJavaPublicationToMavenLocal {
dependsOn project.tasks.signArchives
}
tasks.publishMavenJavaPublicationToMavenRepository {
dependsOn project.tasks.signArchives
}
}
}
}


task version() {
doLast {
println dgraph4jVersion
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

0 comments on commit b4325e2

Please sign in to comment.