diff --git a/build.gradle b/build.gradle index 8f5a30f4..ee1fc5b8 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { plugins { id 'java' - id 'maven' + id 'maven-publish' id 'signing' //id 'jacoco' } @@ -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 -> @@ -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 { diff --git a/settings.gradle b/settings.gradle index e69de29b..2292480d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name ='dotify.formatter.impl' \ No newline at end of file diff --git a/upload.sh b/upload.sh index 586fd8d2..bdbc18a4 100755 --- a/upload.sh +++ b/upload.sh @@ -1,5 +1,5 @@ #!/bin/bash -#version: 2016-05-27 +#version: 2019-03-13 (use maven publish) branch=$TRAVIS_BRANCH if [ -z "$branch" ]; then @@ -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 @@ -54,7 +54,4 @@ if [ "$pullrequest" = "false" ]; then fi else echo "Pull request. Skipping upload." -fi - - - +fi \ No newline at end of file