Skip to content

Commit

Permalink
Migrate to the maven-publish plugin
Browse files Browse the repository at this point in the history
Previously releases were performed using the legacy 'maven' plugin. This
is hard to configure, so we used the 'nexus' plugin built on top of that.
Since then, that plugin inspired the official maven-publish plugin which
uses a similar configuration. In Gradle 6 the legacy plugin was deprecated.

The output is similar except it now includes a more succinct generated pom
(no test scope dependencies) and the new Gradle module metadata.

The simulator's application archives (zip and tar) are no longer attached,
as they were by default before. Since this is a development tool and there
isn't a known use-case for publishing those, until otherwise asked for they
are no longer provided.
  • Loading branch information
ben-manes committed Jan 14, 2020
1 parent 443bbb8 commit 8cb2b08
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Snapshots of the development version are available in
[jsr107]: https://github.com/ben-manes/caffeine/wiki/JCache
[maven]: https://maven-badges.herokuapp.com/maven-central/com.github.ben-manes.caffeine/caffeine
[releases]: https://github.com/ben-manes/caffeine/releases
[snapshots]: https://oss.sonatype.org/content/repositories/snapshots
[snapshots]: https://oss.sonatype.org/content/repositories/snapshots/com/github/ben-manes/caffeine
[efficiency]: https://github.com/ben-manes/caffeine/wiki/Efficiency
[tinylfu]: https://dl.acm.org/authorize?N41277
[adaptive-tinylfu]: https://dl.acm.org/authorize?N675830
Expand Down
11 changes: 0 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ subprojects {

configurations {
bundleCompile
testArtifacts
}

sourceSets {
Expand Down Expand Up @@ -111,16 +110,6 @@ subprojects {
binResultsDir = file("${buildDir}/reports/${name}/results/binary/${name}")
}

task testJar(type: Jar, group: 'Build') {
description = 'Assembles a jar archive containing the test classes.'
archiveBaseName = "${archivesBaseName}-test"
from sourceSets.test.output
}

artifacts {
testArtifacts testJar
}

if (project != project(':caffeine')) {
javadoc.options.linksOffline(
"https://static.javadoc.io/${group}/caffeine/${version}/",
Expand Down
1 change: 1 addition & 0 deletions checksum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<trusted-key id='a50569c7ca7fa1f0' group='com.jcraft' />
<trusted-key id='52931f4b72b4f54c' group='com.koloboke' />
<trusted-key id='1063fe98bcecb758' group='com.puppycrawl.tools' />
<trusted-key id='685c46769dbb5e5d' group='com.squareup' />
<trusted-key id='80c08b1c29100955' group='com.squareup' />
<trusted-key id='8671a8df71296252' group='com.squareup' />
<trusted-key id='0315bfb7970a144f' group='com.sun.istack' />
Expand Down
4 changes: 1 addition & 3 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ext {
jackrabbit: '1.20.0',
jamm: '0.3.3',
javaObjectLayout: '0.9',
javapoet: '1.11.1',
javapoet: '1.12.0',
jcache: '1.1.1',
jcommander: '1.78',
jmh: '1.22',
Expand Down Expand Up @@ -83,7 +83,6 @@ ext {
jacoco: '0.8.4',
jmh: '0.5.0',
jmhReport: '0.9.0',
nexus: '2.3.1',
nullaway: '1.0.1',
pmd: '6.20.0',
semanticVersioning: '1.1.0',
Expand Down Expand Up @@ -185,7 +184,6 @@ ext {
"org.openjdk.jmh:jmh-core:${versions.jmh}",
],
jmhReport: "gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:${pluginVersions.jmhReport}",
nexus: "com.bmuschko:gradle-nexus-plugin:${pluginVersions.nexus}",
nullaway: "net.ltgt.gradle:gradle-nullaway-plugin:${pluginVersions.nullaway}",
semanticVersioning: "io.ehdev:gradle-semantic-versioning:${pluginVersions.semanticVersioning}",
shadow: "com.github.jengelman.gradle.plugins:shadow:${pluginVersions.shadow}",
Expand Down
105 changes: 74 additions & 31 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -1,46 +1,89 @@
/**
* Configuration for publishing to Maven Central
*/
apply plugin: 'com.bmuschko.nexus'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'signing'

if (System.env.'nexusUsername') {
project.nexusUsername = System.env.'nexusUsername'
project.nexusPassword = System.env.'nexusPassword'
configurations {
testArtifacts
}

extraArchive.tests = true
java {
withJavadocJar()
withSourcesJar()
}

modifyPom {
project {
name 'Caffeine cache'
description 'A high performance caching library for Java 8+'
url 'https://github.com/ben-manes/caffeine'
inceptionYear '2014'
task testJar(type: Jar, group: 'Build') {
description = 'Assembles a jar archive containing the test classes.'
from sourceSets.test.output
archiveClassifier = 'test'
}

scm {
url 'https://github.com/ben-manes/caffeine'
connection 'scm:https://[email protected]/ben-manes/caffeine.git'
developerConnection 'scm:git://github.com/ben-manes/caffeine.git'
}
artifacts {
testArtifacts testJar
}

licenses {
license {
name 'Apache License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact testJar

pom {
name = 'Caffeine cache'
description = 'A high performance caching library'
url = 'https://github.com/ben-manes/caffeine'
inceptionYear = '2014'

developers {
developer {
id 'ben-manes'
name 'Ben Manes'
email '[email protected]'
roles {
role 'owner'
role 'developer'
scm {
url = 'https://github.com/ben-manes/caffeine'
connection = 'scm:https://[email protected]/ben-manes/caffeine.git'
developerConnection = 'scm:git://github.com/ben-manes/caffeine.git'
}

licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}

developers {
developer {
id = 'ben-manes'
name = 'Ben Manes'
email = '[email protected]'
roles = [ 'owner', 'developer' ]
}
}
}
repositories {
maven {
def releasesUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url = project.version.releaseBuild ? releasesUrl : snapshotsUrl
credentials {
username = project.properties['nexusUsername'] ?: null
password = project.properties['nexusPassword'] ?: null
}
}
}
}
}
}

signing {
// https://github.com/gradle/gradle/issues/11387
required { false }
if (version.releaseBuild) {
sign publishing.publications.mavenJava
}
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}

0 comments on commit 8cb2b08

Please sign in to comment.