Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to migrate to com.vanniktech.maven.publish #2236

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ repositories {
mavenCentral()
}

apply from: rootProject.file('gradle/java-publish.gradle')
apply from: rootProject.file('gradle/changelog.gradle')
allprojects {
if (findProject('POM_ARTIFACT_ID') != null) {
group = getProperty('GROUP')
description = getProperty('POM_DESCRIPTION')
ext.artifactId = getProperty('POM_ARTIFACT_ID')
}

apply from: rootProject.file('gradle/spotless.gradle')
}
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
Expand Down
26 changes: 16 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true

name=spotless
description=Spotless - keep your code spotless with Gradle
org=diffplug
GROUP=com.diffplug.spotless

group=com.diffplug.spotless
SONATYPE_AUTOMATIC_RELEASE=true
SONATYPE_HOST=DEFAULT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the possible values are, but I think we are on the s01 host, not the default.

  • s01.oss.sonatype.org

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, forgot updating.

RELEASE_SIGNING_ENABLED=true

artifactIdLib=spotless-lib
artifactIdLibExtra=spotless-lib-extra
artifactIdTestLib=spotless-testlib
POM_URL=https://github.com/diffplug/spotless

# naming convention '-maven-plugin' allows mvn 'spotless:check' instead of 'spotless-plugin-maven:check'
artifactIdMaven=spotless-maven-plugin
POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/diffplug/spotless
POM_SCM_CONNECTION=scm:git:git://github.com/diffplug/spotless.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/diffplug/spotless.git

POM_DEVELOPER_ID=diffplug
POM_DEVELOPER_NAME=DiffPlug developers
POM_DEVELOPER_URL=https://github.com/diffplug

artifactIdGradle=spotless-plugin-gradle

# Build requirements
VER_JAVA=11
Expand Down
8 changes: 1 addition & 7 deletions gradle/changelog.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ spotlessChangelog {
tagMessage "${kind} v{{version}}\n\n{{changes}}"
runAfterPush "gh release create ${kind}/{{version}} --title '${releaseTitle} v{{version}}' --notes-from-tag"

if (kind == 'gradle') {
forceNextVersion '7.0.0.BETA2'
} else if (kind == 'maven') {
forceNextVersion '2.44.0.BETA2'
} else {
forceNextVersion '3.0.0.BETA2'
}
forceNextVersion getProperty('VERSION_NAME')
}

if (project == rootProject) {
Expand Down
155 changes: 3 additions & 152 deletions gradle/java-publish.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
import java.nio.charset.StandardCharsets

def decode64(String varName) {
String envValue = System.env[varName]
if (envValue == null) {
return ""
} else {
return new String(envValue.decodeBase64(), "UTF-8")
}
}

if (project.parent == null) {
group = 'com.diffplug.spotless'
def pass = System.env['ORG_GRADLE_PROJECT_nexus_pass64']
if (pass != null) {
pass = pass.decodeBase64()
}
// it's the root project
apply plugin: 'io.github.gradle-nexus.publish-plugin'
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = System.env['ORG_GRADLE_PROJECT_nexus_user']
password = decode64('ORG_GRADLE_PROJECT_nexus_pass64')
}
}
}
def initTask = tasks.named('initializeSonatypeStagingRepository')
allprojects {
initTask.configure {
shouldRunAfter(tasks.withType(Sign))
}
}
return
}
apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'java'

///////////
// MAVEN //
Expand All @@ -48,9 +13,6 @@ tasks.named('sourcesJar') {
dependsOn 'jar'
}

apply plugin: 'maven-publish'
apply plugin: 'signing'

// Where it's possible to name parameters and methods clearly enough
// that javadoc is not necessary, why make the code bigger?
//
Expand All @@ -66,7 +28,7 @@ tasks.named('check') {

// use markdown in javadoc
def makeLink = { url, text -> "<a href=\"${url}\" style=\"text-transform: none;\">${text}</a>" }
def javadocInfo = '<h2>' + makeLink("https://github.com/${org}/${name}", "${group}:${project.ext.artifactId}:${version}") +
def javadocInfo = '<h2>' + makeLink("https://github.com/diffplug/spotless", "${group}:${project.ext.artifactId}:${version}") +
' by ' + makeLink('https://www.diffplug.com', 'DiffPlug') + '</h2>'

String dotdotGradle = project.name.startsWith('eclipse-') ? '../../gradle' : '../gradle'
Expand All @@ -88,117 +50,6 @@ javadoc {
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib-extra")
}

////////////////
// PUBLISHING //
////////////////
final MAVEN_PLUGIN_ARTIFACT_NAME = 'spotless-maven-plugin'
boolean isExt = project.name.startsWith('eclipse-')
boolean isPluginMaven = project.ext.artifactId == 'spotless-maven-plugin'

model {
publishing {
publications {
pluginMaven(MavenPublication) {
if (project.ext.artifactId != 'spotless-plugin-gradle') {
from components.java
}

groupId project.group
artifactId project.ext.artifactId
version project.version

pom.withXml {
// add MavenCentral requirements to the POM
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.ext.artifactId
description project.description
url "https://github.com/${project.org}/${rootProject.name}"
scm {
url "https://github.com/${project.org}/${rootProject.name}"
connection "scm:git:https://github.com/${project.org}/${rootProject.name}.git"
developerConnection "scm:git:ssh:[email protected]/${project.org}/${rootProject.name}.git"
}
licenses {
if (isExt) {
license {
name 'Eclipse Public License - v 1.0'
url 'https://www.eclipse.org/legal/epl-v10.html'
distribution 'repo'
}
} else {
license {
name 'The Apache Software License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
if (isPluginMaven) {
// Maven plugin required Maven 3.1.0+ to run
prerequisites { maven '3.1.0' }
}
developers {
if (isExt) {
project.ext.developers.each { extId, extValues ->
developer {
id extId
name extValues['name']
email extValues['email']
}
}
} else {
if (isPluginMaven) {
developer {
id 'lutovich'
name 'Konstantin Lutovich'
email '[email protected]'
}
}
developer {
id 'nedtwigg'
name 'Ned Twigg'
email '[email protected]'
}
}
}
}
}
}
}
}
}

if (System.env['JITPACK'] == 'true' || version.endsWith('-SNAPSHOT')) {
signing {
setRequired(false)
}
} else {
signing {
String gpg_key = decode64('ORG_GRADLE_PROJECT_gpg_key64')
useInMemoryPgpKeys(gpg_key, System.env['ORG_GRADLE_PROJECT_gpg_passphrase'])
sign(publishing.publications)
}

// find the project with the changelog (this project for plugins, root project for libs)
def changelogTasks = (tasks.names.contains('changelogBump') ? project : rootProject).tasks

// ensures that nothing will be built if changelogPush will end up failing
tasks.named('jar').configure {
dependsOn changelogTasks.named('changelogCheck')
}
// ensures that changelog bump and push only happens if the publish was successful
def thisProj = project
changelogTasks.named('changelogBump').configure {
dependsOn ":${thisProj.path}:publishPluginMavenPublicationToSonatypeRepository"
dependsOn ":closeAndReleaseSonatypeStagingRepository"
// if we have a Gradle plugin, we need to push it up to the plugin portal too
if (thisProj.tasks.names.contains('publishPlugins')) {
dependsOn thisProj.tasks.named('publishPlugins')
}
}
}

tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
Expand Down
1 change: 1 addition & 0 deletions gradle/spotless-freshmark.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.diffplug.spotless-changelog'

import com.diffplug.gradle.spotless.FreshMarkExtension

Expand Down
3 changes: 1 addition & 2 deletions lib-extra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ plugins {
id 'java-library'
id 'dev.equo.p2deps'
}
ext.artifactId = project.artifactIdLibExtra
version = rootProject.spotlessChangelog.versionNext

apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')

Expand Down
4 changes: 4 additions & 0 deletions lib-extra/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=spotless-lib-extra
POM_NAME=Spotless Lib Extra
POM_DESCRIPTION=Spotless shared lib extra for Gradle plugin and Maven plugin.
VERSION_NAME=3.0.0.BETA3-SNAPSHOT
3 changes: 1 addition & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ plugins {
id 'java-library'
id 'io.github.davidburstrom.version-compatibility'
}
ext.artifactId = project.artifactIdLib
version = rootProject.spotlessChangelog.versionNext

apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')

Expand Down
4 changes: 4 additions & 0 deletions lib/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=spotless-lib
POM_NAME=Spotless Lib
POM_DESCRIPTION=Spotless shared lib for Gradle plugin and Maven plugin.
VERSION_NAME=3.0.0.BETA3-SNAPSHOT
14 changes: 4 additions & 10 deletions plugin-gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
apply from: rootProject.file('gradle/changelog.gradle')
ext.artifactId = project.artifactIdGradle
version = spotlessChangelog.versionNext
apply plugin: 'java-library'
apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'java-gradle-plugin'
apply from: rootProject.file('gradle/changelog.gradle')
apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/spotless-freshmark.gradle')


dependencies {
if (version.endsWith('-SNAPSHOT') || (rootProject.spotlessChangelog.versionNext == rootProject.spotlessChangelog.versionLast)) {
api projects.lib
api projects.libExtra
} else {
api "com.diffplug.spotless:spotless-lib:${rootProject.spotlessChangelog.versionLast}"
api "com.diffplug.spotless:spotless-lib-extra:${rootProject.spotlessChangelog.versionLast}"
}
api projects.lib
api projects.libExtra

implementation "com.diffplug.durian:durian-core:${VER_DURIAN}"
implementation "com.diffplug.durian:durian-io:${VER_DURIAN}"
implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}"
Expand Down
4 changes: 4 additions & 0 deletions plugin-gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POM_ARTIFACT_ID=spotless-plugin-gradle
POM_NAME=Spotless Gradle Plugin
POM_DESCRIPTION=Spotless - keep your code spotless with Gradle.
VERSION_NAME=7.0.0.BETA3-SNAPSHOT
3 changes: 0 additions & 3 deletions plugin-maven/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ plugins {
}

apply from: rootProject.file('gradle/changelog.gradle')
ext.artifactId = project.artifactIdMaven
version = spotlessChangelog.versionNext

apply from: rootProject.file("gradle/java-setup.gradle")
apply from: rootProject.file('gradle/spotless-freshmark.gradle')

Expand Down
6 changes: 6 additions & 0 deletions plugin-maven/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POM_ARTIFACT_ID=spotless-maven-plugin
POM_DEVELOPER_ID=lutovich
POM_DEVELOPER_NAME=Konstantin Lutovich
POM_NAME=Spotless Maven Plugin
POM_DESCRIPTION=Spotless - keep your code spotless with Maven.
VERSION_NAME=2.44.0.BETA3-SNAPSHOT
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ plugins {
id 'com.diffplug.spotless' version '7.0.0.BETA2' apply false
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
id 'com.gradle.plugin-publish' version '1.2.1' apply false
// https://github.com/gradle-nexus/publish-plugin/releases
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' apply false
// https://github.com/vanniktech/gradle-maven-publish-plugin/releases
id 'com.vanniktech.maven.publish' version '0.29.0' apply false
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
id 'com.github.spotbugs' version '6.0.20' apply false
// https://github.com/diffplug/spotless-changelog/blob/main/CHANGELOG.md
Expand Down
3 changes: 1 addition & 2 deletions testlib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
id 'java-library'
}
ext.artifactId = project.artifactIdTestLib
version = rootProject.spotlessChangelog.versionNext

apply from: rootProject.file('gradle/java-setup.gradle')

dependencies {
Expand Down
Loading