From e286096796ddc39f1b24c9c00834978536247656 Mon Sep 17 00:00:00 2001 From: Evan Tatarka Date: Sun, 21 Apr 2019 14:55:49 -0400 Subject: [PATCH] Update gradle publishing --- build.gradle | 4 +- gradle-retrolambda/build.gradle | 160 +++++++++++++++----------------- 2 files changed, 76 insertions(+), 88 deletions(-) diff --git a/build.gradle b/build.gradle index fbdcdee..d9b0893 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,8 @@ task install { dependsOn gradle.includedBuild('gradle-retrolambda').task(':install') } -task uploadArchives { - dependsOn gradle.includedBuild('gradle-retrolambda').task(':uploadArchives') +task publish { + dependsOn gradle.includedBuild('gradle-retrolambda').task(':publish') } task publishPlugins { diff --git a/gradle-retrolambda/build.gradle b/gradle-retrolambda/build.gradle index b16cb36..a37e193 100644 --- a/gradle-retrolambda/build.gradle +++ b/gradle-retrolambda/build.gradle @@ -10,13 +10,13 @@ buildscript { dependencies { classpath 'org.ajoberstar:gradle-git:0.11.2' - classpath "com.gradle.publish:plugin-publish-plugin:0.9.7" + classpath "com.gradle.publish:plugin-publish-plugin:0.10.0" } } apply plugin: "com.gradle.plugin-publish" +apply plugin: 'maven-publish' apply plugin: 'groovy' -apply plugin: 'maven' apply plugin: 'signing' apply plugin: 'idea' @@ -91,12 +91,6 @@ task sourcesJar(type: Jar) { classifier = 'sources' } -artifacts { - archives jar - archives javadocJar - archives sourcesJar -} - pluginBundle { website = 'https://github.com/evant/gradle-retrolambda' vcsUrl = 'https://github.com/evant/gradle-retrolambda.git' @@ -111,96 +105,90 @@ pluginBundle { } } -signing { - sign configurations.archives -} - -if (project.hasProperty('sonatype.username') && project.hasProperty('sonatype.password')) { - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { deployment -> signing.signPom(deployment) } - - def repoUrl - if (project.version.endsWith("SNAPSHOT")) { - repoUrl = "https://oss.sonatype.org/content/repositories/snapshots" - } else { - repoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" +publishing { + publications { + lib(MavenPublication) { + artifact jar + artifact sourcesJar + artifact javadocJar + pom { + name = 'gradle-retrolambda' + description = 'A gradle plugin for getting java lambda support in java 6, 7 and android' + url = 'https://github.com/evant/gradle-retrolambda' + scm { + url = 'git@github.com:evant/gradle-retrolambda.git' + connection = 'scm:git:git@github.com:evant/gradle-retrolambda.git' + developerConnection = 'scm:git:git@github.com:evant/gradle-retrolambda.git' } - - repository(url: repoUrl) { - authentication( - userName: project.getProperty('sonatype.username'), - password: project.getProperty('sonatype.password')) - } - - pom.project { - name 'gradle-retrolambda' - packaging 'jar' - description 'A gradle plugin for getting java lambda support in java 6, 7 and android' - url 'https://github.com/evant/gradle-retrolambda' - - scm { - url 'git@github.com:evant/gradle-retrolambda.git' - connection 'scm:git:git@github.com:evant/gradle-retrolambda.git' - developerConnection 'scm:git:git@github.com:evant/gradle-retrolambda.git' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = 'repo' } - - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - - developers { - developer { - id 'evant' - name 'Evan Tatarka' - } + } + developers { + developer { + id = 'evant' + name = 'Evan Tatarka' } } } } } + repositories { + maven { + def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots' + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + credentials { + username project.findProperty('sonatype.username') + password project.findProperty('sonatype.password') + } + } + } +} - def grgit = Grgit.open("$projectDir/..") +signing { + sign publishing.publications.lib +} - task checkRelease { doLast { - def readmeVersion = file("$project.rootProject.projectDir/../README.md").readLines().find { it.contains('me.tatarka:gradle-retrolambda:') }?.trim() - - if (readmeVersion == null) { - throw new ProjectConfigurationException("Missing README version string", null) - } - if (!readmeVersion.contains(":$version")) { - throw new ProjectConfigurationException("README version string: $readmeVersion must match release version: $version", null) - } - - def changelogVersion = file("$project.rootProject.projectDir/../CHANGELOG.md").readLines().find { it.contains("### $version") } - if (changelogVersion == null) { - throw new ProjectConfigurationException("CHANGELOG does not contain changes for release version: $version", null) - } +def grgit = Grgit.open("$projectDir/..") - def branchName = grgit.branch.current.name - if (branchName == 'beta') { - if (!version.contains('beta')) { - throw new ProjectConfigurationException("Beta branch must contain 'beta' in the version name", null) - } - } else if (branchName != 'master') { - throw new ProjectConfigurationException("Branch: $branchName must be master", null) - } - } } +task checkRelease { doLast { + def readmeVersion = file("$project.rootProject.projectDir/../README.md").readLines().find { it.contains('me.tatarka:gradle-retrolambda:') }?.trim() + + if (readmeVersion == null) { + throw new ProjectConfigurationException("Missing README version string", null) + } + + if (!readmeVersion.contains(":$version")) { + throw new ProjectConfigurationException("README version string: $readmeVersion must match release version: $version", null) + } + + def changelogVersion = file("$project.rootProject.projectDir/../CHANGELOG.md").readLines().find { it.contains("### $version") } + if (changelogVersion == null) { + throw new ProjectConfigurationException("CHANGELOG does not contain changes for release version: $version", null) + } - task tagRelease(dependsOn: [checkRelease]) { doLast { - grgit.tag.add { - name = "v$version" - message = "Release of $version" + def branchName = grgit.branch.current.name + if (branchName == 'beta') { + if (!version.contains('beta')) { + throw new ProjectConfigurationException("Beta branch must contain 'beta' in the version name", null) } - } } - - if (!version.endsWith('SNAPSHOT')) { - uploadArchives.dependsOn(tagRelease) + } else if (branchName != 'master') { + throw new ProjectConfigurationException("Branch: $branchName must be master", null) + } +} } + +task tagRelease(dependsOn: [checkRelease]) { doLast { + grgit.tag.add { + name = "v$version" + message = "Release of $version" } +} } + +if (!version.endsWith('SNAPSHOT')) { + uploadArchives.dependsOn(tagRelease) }