Skip to content

Commit

Permalink
Use maven-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
joeha480 committed Mar 15, 2019
1 parent e9ea0e9 commit 7605fd6
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 58 deletions.
105 changes: 55 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {

plugins {
id 'java'
id 'maven'
id 'maven-publish'
id 'signing'
//id 'jacoco'
}
Expand Down Expand Up @@ -58,18 +58,18 @@ dependencies {
exclude module: 'Saxon-HE'
}

runtime 'com.fasterxml.woodstox:woodstox-core:5.1.0'
runtimeOnly 'com.fasterxml.woodstox:woodstox-core:5.1.0'

testCompileOnly 'org.osgi:org.osgi.service.component.annotations:1.3.0'
testCompile group: "junit", name: "junit", version: "4.12"
testCompile ('org.daisy.braille:braille-utils.pef-tools:5.0.0') {
testImplementation group: "junit", name: "junit", version: "4.12"
testImplementation ('org.daisy.braille:braille-utils.pef-tools:5.0.0') {
exclude module: 'Saxon-HE'
}
testCompile "org.mockito:mockito-core:1.10.19"
testImplementation "org.mockito:mockito-core:1.10.19"

testRuntime group: group, name:'dotify.hyphenator.impl', version:'4.0.0'
testRuntime group: group, name:'dotify.text.impl', version:'4.0.0'
testRuntime group: group, name:'dotify.translator.impl', version:'4.0.0'
testRuntimeOnly group: group, name:'dotify.hyphenator.impl', version:'4.0.0'
testRuntimeOnly group: group, name:'dotify.text.impl', version:'4.0.0'
testRuntimeOnly group: group, name:'dotify.translator.impl', version:'4.0.0'
}

ext.writeTestsOverviewFile = { folderPath, fileName ->
Expand Down Expand Up @@ -161,56 +161,61 @@ task sourcesJar(type: Jar) {
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
}

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
required { isReleaseVersion }
sign publishing.publications
}

uploadArchives {
publishing {
//Only upload if a git hash is supplied. On Travis only upload snapshots.
enabled = repoRevision.size()==40 && System.getenv("TRAVIS_BUILD_ID")!=null
repositories {
mavenDeployer {
//enabled = repoRevision.size()==40 && System.getenv("TRAVIS_BUILD_ID")!=null
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
/*
if (isReleaseVersion) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
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)
}
pom.project {
name 'dotify.formatter.impl'
packaging 'jar'
description 'Dotify Formatter'
url "$repositoryURL"
scm {
connection "$repositorySCM"
developerConnection "$repositorySCM"
url "$repositoryURL"
}
licenses {
license {
name 'LGPL'
url 'http://www.gnu.org/licenses/lgpl.html'
}
}
developers {
developer {
id 'joel'
name 'Joel Håkansson'
}
}
}
}
}
}*/
pom {
name = 'dotify.formatter.impl'
packaging = 'jar'
description = 'Dotify Formatter'
url = "$repositoryURL"
scm {
connection = "$repositorySCM"
developerConnection = "$repositorySCM"
url = "$repositoryURL"
}
licenses {
license {
name = 'LGPL'
url = 'http://www.gnu.org/licenses/lgpl.html'
}
}
developers {
developer {
id = 'joel'
name = 'Joel Håkansson'
}
}
}
}
}
repositories {
maven {
def stagingRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : stagingRepoUrl
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
}

wrapper {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name ='dotify.formatter.impl'
13 changes: 5 additions & 8 deletions upload.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#version: 2016-05-27
#version: 2019-03-13 (use maven publish)

branch=$TRAVIS_BRANCH
if [ -z "$branch" ]; then
Expand Down Expand Up @@ -37,12 +37,12 @@ if [ "$prop_change" = "false" ]; then
fi

if [ "$pullrequest" = "false" ]; then
if [ $branch = "master" ]; then
echo "On master branch."
if [ $branch = "master" -o "$is_release" = "false" ]; then
echo "On master branch or snapshot version."
if [ -n "$SONATYPE_USER" ]; then
if [ -n "$SONATYPE_PASSWORD" ]; then
echo "Starting upload..."
./gradlew uploadArchives -PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PASSWORD -PrepositoryRevision=$revision -Psigning.keyId=$SIGNING_KEY -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=secring.gpg
./gradlew publishMavenPublicationToMavenRepository -PsonatypeUsername=$SONATYPE_USER -PsonatypePassword=$SONATYPE_PASSWORD -PrepositoryRevision=$revision -Psigning.keyId=$SIGNING_KEY -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=secring.gpg
else
echo "SONATYPE_PASSWORD not set. Skipping upload."
fi
Expand All @@ -54,7 +54,4 @@ if [ "$pullrequest" = "false" ]; then
fi
else
echo "Pull request. Skipping upload."
fi



fi

0 comments on commit 7605fd6

Please sign in to comment.