Skip to content

Commit

Permalink
[#1322] BUILD: switch from Bintray jcenter to Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Nov 4, 2021
1 parent f5ce235 commit bc68686
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 671 deletions.
370 changes: 14 additions & 356 deletions build.gradle

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ junitDepVersion = 4.11
junitVersion = 4.12
springBootVersion = 2.4.3

# projectPreviousReleaseVersion is non-SNAPSHOT, only published releases
projectPreviousReleaseVersion = 4\\.6\\.1
# projectPreviousPublishedVersion is non-SNAPSHOT, only published releases
projectPreviousPublishedVersion = 4\\.6\\.1
# projectPreviousVersionRegex may be a SNAPSHOT
projectPreviousVersionRegex = 4\\.6\\.1
projectVersion = 4.6.2-SNAPSHOT
projectPreviousVersionRegex = 4\\.6\\.1
projectVersion = 4.6.2-SNAPSHOT

releaseDate = 2021-01-03
releaseDatePreviousRegex = 2021\\-01\\-03
Expand Down
59 changes: 59 additions & 0 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apply plugin: 'java'
apply plugin: 'org.asciidoctor.jvm.convert'
pluginManager.withPlugin('org.asciidoctor.jvm.convert') { // if plugin applied, execute this action
configurations {
tabbedCodeExt
}
dependencies {
tabbedCodeExt "com.bmuschko:asciidoctorj-tabbed-code-extension:0.3"
}
}

Map<org.gradle.api.JavaVersion, String> linkMap = org.gradle.api.JavaVersion.values().collectEntries { version ->
[(version) : 'https://docs.oracle.com/javase/8/docs/api/']
}
linkMap.remove(org.gradle.api.JavaVersion.VERSION_HIGHER)
for (int i = 12; i < 20; i++) { try { linkMap.remove(org.gradle.api.JavaVersion.valueOf("VERSION_$i")); } catch (Exception ignored) {} }
linkMap << [(org.gradle.api.JavaVersion.VERSION_1_9) : 'https://docs.oracle.com/javase/9/docs/api/']
linkMap << [(org.gradle.api.JavaVersion.VERSION_1_10) : 'https://docs.oracle.com/javase/10/docs/api/']
linkMap << [(org.gradle.api.JavaVersion.VERSION_11) : 'https://docs.oracle.com/en/java/javase/11/docs/api/']

javadoc.options.overview = "src/main/java/overview.html"
javadoc.options.links += [
linkMap.get(org.gradle.api.JavaVersion.current(), 'https://docs.oracle.com/en/java/javase/12/docs/api/'),
]
//javadoc.options.linksOffline linkMap.get(org.gradle.api.JavaVersion.current(), 'https://docs.oracle.com/en/java/javase/12/docs/api/'), 'gradle/javadocs/jdk/9/'

javadoc {
options.encoding = 'UTF-8'
//logger.warn(sourceSets.main.allJava.sourceDirectories.files.toString())
File javadocExe = new File((String) System.getenv("JAVA_11_HOME@@@"), "bin/javadoc.exe")
if (javadocExe.exists()) {
executable = javadocExe
javadoc.options.links = [ 'https://docs.oracle.com/en/java/javase/11/docs/api/' ]
inputs.property("moduleName", moduleName)
options.addStringOption('-module', moduleName)
//source(sourceSets.main.java)
source = sourceSets.main.allJava
options.addStringsOption("-module-source-path", ";").setValue(["C:\\Users\\remko\\IdeaProjects\\picocli3\\src\\main\\java", "C:\\Users\\remko\\IdeaProjects\\picocli3\\src\\main\\java9"])
options.addStringOption('-module-path', classpath.asPath)
options.addBooleanOption('-frames')
}
}
javadoc.dependsOn(jar)
javadoc.dependsOn('asciidoctor')
asciidoctorj {
version = '2.4.3'
}
asciidoctor {
sourceDir = file('docs')
outputDir = file('build/docs')
logDocuments = true
configurations 'tabbedCodeExt'
baseDirFollowsSourceDir()
// backends 'pdf', 'html'
// attributes 'sourcedir': file('docs') //project.sourceSets.main.java.srcDirs[0]
//// attributes 'pdf-stylesdir': 'theme',
//// 'pdf-style': 'custom',
//// 'sourcedir': file('docs') //project.sourceSets.main.java.srcDirs[0]
}
132 changes: 132 additions & 0 deletions gradle/publish-mavencentral.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
apply plugin: 'java'
apply plugin: 'distribution'
apply plugin: 'maven-publish'
apply plugin: 'signing'


task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
archiveClassifier.set('javadoc')
}
task sourcesJar(type: Jar) {
from sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
}
task testJar(type: Jar, dependsOn: compileTestJava) {
from sourceSets.test.output
archiveClassifier.set('tests')
}
task testSourcesJar(type: Jar) {
from sourceSets.test.java.srcDirs
archiveClassifier.set('test-sources')
}

artifacts {
archives jar
archives javadocJar
archives sourcesJar
archives testJar
archives testSourcesJar
}
tasks.withType(GenerateModuleMetadata) {
enabled = false // fix for https://github.com/remkop/picocli/issues/1152
}
distributions {
main {
distributionBaseName = "$archivesBaseName-all"
contents {
from jar
from javadocJar
from sourcesJar
from testJar
from testSourcesJar
from ('LICENSE')
from ("$rootDir/RELEASE-NOTES.md")
}
}
}

// different for each module
group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
p.load(new FileInputStream(secretPropsFile))
p.each { name, value ->
ext[name] = value
}
} else {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["ossrhUsername"] = System.getenv('MAVEN_OSS_USER')
ext["ossrhPassword"] = System.getenv('MAVEN_OSS_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}

publishing {
publications {
release(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar
artifact testJar
artifact testSourcesJar
groupId group
artifactId project.name
version PUBLISH_VERSION
//version "$projectVersion"
// pom configuration for MavenPublication, as per https://docs.gradle.org/current/userguide/publishing_maven.html#sec:modifying_the_generated_pom
pom {
packaging = 'jar'
name = project.name
description = project.description
url = 'http://picocli.info'
inceptionYear = '2018'
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 = "rpopma"
name = "Remko Popma"
email = "rpopma@apache.org"
}
}
scm {
url = "https://github.com/remkop/picocli/tree/master"
connection = 'scm:git:https://github.com/remkop/picocli.git'
developerConnection = 'scm:git:ssh://github.com:remkop/picocli.git'
}
}
}
}
repositories {
maven {
name = "sonatype"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"

credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}

signing {
sign publishing.publications
}
149 changes: 149 additions & 0 deletions gradle/release-tasks.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
task bumpReadmeVersion {
doLast {
// README.md
ant.replaceregexp(match: "$projectPreviousPublishedVersion", replace: "$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: '.', includes: 'README.md')
fileset(dir: './picocli-codegen/', includes: 'README.adoc')
fileset(dir: './picocli-groovy/', includes: 'README.md')
fileset(dir: './picocli-shell-jline2/', includes: 'README.md')
fileset(dir: './picocli-shell-jline3/', includes: 'README.md')
fileset(dir: './picocli-spring-boot-starter/', includes: 'README.md')
fileset(dir: './picocli-examples/annotation-processing/') {
include(name: '**/pom.xml')
include(name: '**/build.gradle')
}
fileset(dir: './picocli-examples/generate-man-pages/') {
include(name: '**/pom.xml')
include(name: '**/build.gradle')
}
//fileset(dir: './picocli-examples/src/main/groovy/', includes: '**/*.groovy')
}
}
}
task bumpVersion {
doLast {
ant.replaceregexp(match: "$projectPreviousVersionRegex", replace: "$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'src/main/java/picocli', includes: 'CommandLine.java')
fileset(dir: 'src/test/java/picocli', includes: 'CommandLineTest.java')
fileset(dir: 'src/main/java/picocli', includes: 'AutoComplete.java')
fileset(dir: 'src/test/java/picocli', includes: 'AutoCompleteTest.java')
fileset(dir: 'picocli-codegen/src/main/java/picocli/codegen/aot/graalvm', includes: 'DynamicProxyConfigGenerator.java')
fileset(dir: 'picocli-codegen/src/main/java/picocli/codegen/aot/graalvm', includes: 'JniConfigGenerator.java')
fileset(dir: 'picocli-codegen/src/main/java/picocli/codegen/aot/graalvm', includes: 'ReflectionConfigGenerator.java')
fileset(dir: 'picocli-codegen/src/main/java/picocli/codegen/aot/graalvm', includes: 'ResourceConfigGenerator.java')
fileset(dir: 'picocli-codegen/src/main/java/picocli/codegen/docgen/manpage', includes: 'ManPageGenerator.java')
}
ant.replaceregexp(match: "version $projectPreviousVersionRegex", replace: "version $version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'src/test/java/picocli', includes: 'AutoCompleteTest.java')
}
// Doc header
ant.replaceregexp(match: ":revnumber: $projectPreviousVersionRegex", replace: ":revnumber: $version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
fileset(dir: 'docs', includes: 'quick-guide.adoc')
fileset(dir: 'docs', includes: 'autocomplete.adoc')
fileset(dir: 'docs', includes: 'picocli-programmatic-api.adoc')
}
// Annotation Processor section
ant.replaceregexp(match: ":picocli-codegen:$projectPreviousVersionRegex", replace: ":picocli-codegen:$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Groovy section
ant.replaceregexp(match: ":picocli-groovy:$projectPreviousVersionRegex", replace: ":picocli-groovy:$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Spring Boot section
ant.replaceregexp(match: ":picocli-spring-boot-starter:$projectPreviousVersionRegex", replace: ":picocli-spring-boot-starter:$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Gradle
ant.replaceregexp(match: ":picocli:$projectPreviousVersionRegex", replace: ":picocli:$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Maven
ant.replaceregexp(match: "<version>$projectPreviousVersionRegex</version>", replace: "<version>$version</version>", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, SBT
ant.replaceregexp(match: "\"picocli\" % \"$projectPreviousVersionRegex\"", replace: "\\\"picocli\\\" % \\\"$version\\\"", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Ivy
ant.replaceregexp(match: "rev=\"$projectPreviousVersionRegex\"", replace: "rev=\\\"$version\\\"", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Grape
ant.replaceregexp(match: "module='picocli', version=\'$projectPreviousVersionRegex\'\\)", replace: "module='picocli', version=\'$version\')", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Leiningen
ant.replaceregexp(match: "info.picocli/picocli \"$projectPreviousVersionRegex\"", replace: "info.picocli/picocli \"$version\"", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Buildr
ant.replaceregexp(match: "info.picocli:picocli:jar:$projectPreviousVersionRegex", replace: "info.picocli:picocli:jar:$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Running the Application and Packaging sections
ant.replaceregexp(match: "picocli-${projectPreviousVersionRegex}.jar", replace: "picocli-${version}.jar", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
fileset(dir: 'docs', includes: 'quick-guide.adoc')
}
ant.replaceregexp(match: releaseDatePreviousRegex, replace: releaseDate, flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
fileset(dir: 'docs', includes: 'quick-guide.adoc')
fileset(dir: 'docs', includes: 'autocomplete.adoc')
fileset(dir: 'docs', includes: 'picocli-programmatic-api.adoc')
fileset(dir: 'picocli-codegen', includes: 'README.adoc')
}
}
}
task copyCodeGenDocs(type: Copy) {
from('build/docs/man/') { include 'index.html' }
from('picocli-codegen/build/docs/html5/') { include '*.html' }
into 'docs/man'
}
task copyDocs(type: Copy) {
dependsOn(copyCodeGenDocs)
from('build/docs/')
into 'docs'
}


/*
Release procedure:
1. edit version numbers: remove -SNAPSHOT classifier; edit releaseDate
2. gradlew bumpVersion
3. check modified files
4. gradlew clean build
5. gradlew copyDocs
6. update RELEASE-NOTES.md
7. gradlew bumpReadmeVersion
7a update README.md (latest version, release notes)
8. commit -m "Release picocli version ..."
9. tag v$version
10. gradlew bintrayUpload - to publish to bintray.com
11. edit version numbers: increase minor version and add -SNAPSHOT classifier
12. gradlew bumpVersion
13. check modified files
14. commit -m "Prepare for next development cycle"
15. push (make sure that Push Tags is checked)
16. Log in to GitHub, go to https://github.com/remkop/picocli/releases
17. Click the new tag, click Edit button, update title and release notes (copy from RELEASE-NOTES.md)
18. Upload picocli-$version.jar and picocli-all$version.zip to GitHub
19. Log in to Bintray
20. Navigate to the page for the new version
21. Edit version: Publication Date, Description, VCS tag, GitHub release notes file (RELEASE-NOTES.md)
22. On the version page, Release Notes tab, select GitHub File
23. Publish artifacts to JCenter
24. On the version page, Maven Central tab, sync to Maven (takes several minutes)
(When releasing from branch)
25. Switch to master
26. cherry-pick the "Release picocli version ..." commit
27. gradlew bumpVersion
28. check modified files
29. commit -m "Update master for next development cycle after release x.x (from branch x.x)"
*/
Loading

0 comments on commit bc68686

Please sign in to comment.