From 439fa4421f2ba4cbf4836981f12998d1ae9682b9 Mon Sep 17 00:00:00 2001 From: dgelessus <dgelessus@users.noreply.github.com> Date: Tue, 28 Apr 2020 14:05:31 +0200 Subject: [PATCH] Migrate to Gradle maven-publish plugin from deprecated maven plugin --- build.gradle | 90 +++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/build.gradle b/build.gradle index e438599..17fba94 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,8 @@ apply plugin: 'application' apply plugin: 'java' apply plugin: 'eclipse' -apply plugin: 'maven' +apply plugin: 'maven-publish' +apply plugin: 'signing' project.version = '3.2.14-SNAPSHOT' @@ -13,6 +14,8 @@ wrapper { distributionType = Wrapper.DistributionType.ALL } +final isSnapshot = project.version.endsWith("-SNAPSHOT") + sourceCompatibility = 7 targetCompatibility = 7 @@ -64,56 +67,57 @@ compileJava { dependsOn = ['writeVersion'] } -if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { - - apply plugin: 'signing' - - signing { - sign configurations.archives - } - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: ossrhUsername, password: ossrhPassword) +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + + pom { + name = 'SableCC - Stups fork' + description = 'This version of SableCC enriches the abstract syntax tree with information about tokens.' + url = 'https://github.com/bendisposto/sablecc-stups' + + licenses { + license { + name = 'GNU Lesser General Public License, Version 2.1' + url = 'http://www.gnu.org/licenses/lgpl-2.1.html' + } } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: ossrhUsername, password: ossrhPassword) + scm { + connection = 'scm:git:git://github.com/bendisposto/sablecc-stups.git' + developerConnection = 'scm:git:git@github.com:bendisposto/sablecc-stups.git' + url = 'https://github.com/bendisposto/sablecc-stups' } - pom.project { - name 'SableCC - Stups fork' - packaging 'jar' - // optionally artifactId can be defined here - description 'This version of SableCC enriches the abstract syntax tree with information about tokens.' - url 'https://github.com/bendisposto/sablecc-stups' - - licenses { - license { - name 'GNU Lesser General Public License, Version 2.1' - url 'http://www.gnu.org/licenses/lgpl-2.1.html' - } - } - - scm { - connection 'scm:git:git://github.com/bendisposto/sablecc-stups.git' - developerConnection 'scm:git:git@github.com:bendisposto/sablecc-stups.git' - url 'https://github.com/bendisposto/sablecc-stups' + developers { + developer { + id = 'bendisposto' + name = 'Jens Bendisposto' + email = 'jens@bendisposto.de' } + } + } + } + } - - developers { - developer { - id 'bendisposto' - name 'Jens Bendisposto' - email 'jens@bendisposto.de' - } - } + repositories { + maven { + final releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" + final snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" + url isSnapshot ? snapshotsRepoUrl : releasesRepoUrl + if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { + credentials { + username project.ossrhUsername + password project.ossrhPassword } } } } } + +signing { + sign publishing.publications.mavenJava +} -- GitLab