Skip to content

Commit

Permalink
[build] Switch publication to maven-publish+artifactory
Browse files Browse the repository at this point in the history
Reviewed-in: reactor#1943
  • Loading branch information
simonbasle committed Nov 6, 2019
1 parent 2c621b6 commit 3d8d226
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 129 deletions.
55 changes: 27 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ buildscript {
}

plugins {
id 'org.asciidoctor.convert' version '1.5.9.2'
id "me.champeau.gradle.jmh" version "0.4.7" apply false
id "org.jetbrains.dokka" version "0.9.18" apply false
id "me.champeau.gradle.japicmp" version "0.2.6"
id "de.undercouch.download" version "3.4.3"
id 'org.asciidoctor.convert' version '1.5.9.2'
id "me.champeau.gradle.jmh" version "0.4.7" apply false
id "org.jetbrains.dokka" version "0.9.18" apply false
id "me.champeau.gradle.japicmp" version "0.2.6"
id "de.undercouch.download" version "3.4.3"
id "com.jfrog.artifactory" version "4.9.8" apply false
}

apply from: "gradle/doc.gradle"
apply from: "gradle/setup.gradle"


ext {
//also set up the special version at root, for refguide
Expand Down Expand Up @@ -81,28 +80,28 @@ ext {
}

configure(subprojects) { p ->
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'jacoco'
apply plugin: 'propdeps'
apply plugin: 'osgi'

description = 'Non-Blocking Reactive Foundation for the JVM'
group = 'io.projectreactor'

ext {
//set up special version per sub-project
//(the root level configuration doesn't seem to propagate)
if (project.hasProperty('versionBranch') && version.toString().endsWith(".BUILD-SNAPSHOT")) {
versionBranch = versionBranch.replaceAll("\"", "").trim()
if (!versionBranch.isEmpty()) {
realVersion = p.version.toString().replace("BUILD-SNAPSHOT", versionBranch + ".BUILD-SNAPSHOT")
p.version = realVersion
println "Building special ${project} snapshot ${p.version}"
println "OSGI version would be: ${new OsgiHelper().getVersion(p.version.toString())}"
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'jacoco'
apply plugin: 'osgi'
apply from: "${rootDir}/gradle/setup.gradle"

description = 'Non-Blocking Reactive Foundation for the JVM'
group = 'io.projectreactor'

ext {
//set up special version per sub-project
//(the root level configuration doesn't seem to propagate)
if (project.hasProperty('versionBranch') && version.toString().endsWith(".BUILD-SNAPSHOT")) {
versionBranch = versionBranch.replaceAll("\"", "").trim()
if (!versionBranch.isEmpty()) {
realVersion = p.version.toString().replace("BUILD-SNAPSHOT", versionBranch + ".BUILD-SNAPSHOT")
p.version = realVersion
println "Building special ${project} snapshot ${p.version}"
println "OSGI version would be: ${new OsgiHelper().getVersion(p.version.toString())}"
}
}
}
}

repositories {
mavenLocal()
Expand Down
184 changes: 97 additions & 87 deletions gradle/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,107 +14,117 @@
* limitations under the License.
*/

wrapper {
group = 'Project Setup'
gradleVersion = "4.10.2"
}

configure(subprojects) { p ->
apply plugin: 'propdeps-maven'
apply plugin: 'maven'

install {
repositories.mavenInstaller {
customizePom(pom, project)
}
}

jar {
manifest.attributes["Created-By"] = "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
manifest.attributes["Implementation-Title"] = project.name
manifest.attributes["Implementation-Version"] = project.version
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
apply plugin: 'propdeps-maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
jar {
manifest.attributes["Created-By"] = "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
manifest.attributes["Implementation-Title"] = project.name
manifest.attributes["Implementation-Version"] = project.version
}

artifacts {
archives sourcesJar
archives javadocJar
}
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

def customizePom(pom, gradleProject) {
pom.whenConfigured { generatedPom ->
// eliminate test-scoped dependencies (no need in maven central poms)
generatedPom.dependencies.removeAll { dep ->
dep.scope == "test"
}
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

// sort to make pom dependencies order consistent to ease comparison of older poms
generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
"$dep.scope:$dep.groupId:$dep.artifactId"
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
//other project-specific artifacts are added in each project's builds

// add all items necessary for maven central publication
generatedPom.project {
name = gradleProject.description
description = gradleProject.description
url = 'https://github.com/reactor/reactor-core'
organization {
name = 'reactor'
url = 'https://github.com/reactor'
}
licenses {
license {
name 'Apache License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
pom {
afterEvaluate {
name = project.description
description = project.description
}
}
scm {
packaging = 'jar' //if not explicitly set, end up as `pom` in output. omitted in output if set as `jar`...
url = 'https://github.com/reactor/reactor-core'
connection = 'scm:git:git://github.com/reactor/reactor-core'
developerConnection = 'scm:git:git://github.com/reactor/reactor-core'
}
developers {
developer {
id = 'smaldini'
name = 'Stephane Maldini'
email = 'smaldini@pivotal.io'
organization {
name = 'reactor'
url = 'https://github.com/reactor'
}
developer {
id = 'akarnokd'
name = 'David Karnok'
email = 'akarnokd@gmail.com'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developer {
id = 'simonbasle'
name = 'Simon Baslé'
email = 'sbasle@pivotal.io'
scm {
url = 'https://github.com/reactor/reactor-core'
connection = 'scm:git:git://github.com/reactor/reactor-core'
developerConnection = 'scm:git:git://github.com/reactor/reactor-core'
}
developer {
id = 'rsivaram'
name = 'Rajini Sivaram'
email = 'rsivaram@pivotal.io'
developers {
developer {
id = 'smaldini'
name = 'Stephane Maldini'
email = 'smaldini@pivotal.io'
}
developer {
id = 'akarnokd'
name = 'David Karnok'
email = 'akarnokd@gmail.com'
}
developer {
id = 'simonbasle'
name = 'Simon Baslé'
email = 'sbasle@pivotal.io'
}
developer {
id = 'bsideup'
name = 'Sergei Egorov'
email = 'segorov@pivotal.io'
}
developer {
id = 'sdeleuze'
name = 'Sébastien Deleuze'
email = 'sdeleuze@pivotal.io'
}
}
developer {
id = 'sdeleuze'
name = 'Sébastien Deleuze'
email = 'sdeleuze@pivotal.io'
issueManagement {
system = "GitHub Issues"
url = "https://github.com/reactor/reactor-core/issues"
}

withXml {
//set optional true for compileOnly dependencies, which are not in there by default
asNode().dependencies[0].each { node ->
def group = node.groupId.text()
def artifact = node.artifactId.text()
def version = node.version.text()
def isOptional = project.configurations.optional.allDependencies.any { dep -> dep.group == group && dep.name == artifact }
if (isOptional) {
node.appendNode('optional', true)
println "$group:$artifact:$version has been marked as optional in generated pom"
}
}
//groovy magic incantation to sort dependencies alphabetically (scope/group/name..)
def sorted = asNode().dependencies[0].children().collect().sort { it.scope.text() + it.groupId.text() + it.artifactId.text() }
asNode().dependencies[0].children().with { deps ->
deps.clear()
sorted.each { deps.add(it) }
}
}
}
issueManagement {
system = "GitHub Issues"
url = "https://github.com/reactor/reactor-core/issues"
}
}
}
}

artifactory {
publish {
defaults {
publications(publishing.publications.mavenJava)
}
}
}
15 changes: 6 additions & 9 deletions reactor-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ dokka {

task kdocZip(type: Zip, dependsOn: dokka) {
//ends up similar to javadoc jar: reactor-core-xxxx.RELEASE-kdoc.zip
classifier = 'kdoc'
archiveClassifier.set('kdoc')
from("${project.buildDir}/docs/kdoc")
}

Expand Down Expand Up @@ -262,13 +262,6 @@ jar {
}
}

artifacts {
archives sourcesJar
archives javadocJar
archives rootProject.tasks.docsZip
archives kdocZip
}

jacocoTestReport.dependsOn test
check.dependsOn jacocoTestReport
jar.finalizedBy(downloadBaseline)
Expand Down Expand Up @@ -316,4 +309,8 @@ else {
dependencies {
compileOnly sourceSets.java9stubs.output
}
}
}

//add kdoc and docs.zip to the publication
publishing.publications.mavenJava.artifact(kdocZip)
publishing.publications.mavenJava.artifact(rootProject.tasks.docsZip)
9 changes: 4 additions & 5 deletions reactor-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ dokka {

task kdocZip(type: Zip, dependsOn: dokka) {
//ends up similar to javadoc jar: reactor-test-xxx.RELEASE-kdoc.zip
classifier = 'kdoc'
archiveClassifier.set('kdoc')
from("${project.buildDir}/docs/kdoc")
}

artifacts {
archives kdocZip
}
jar.finalizedBy(downloadBaseline)

jar.finalizedBy(downloadBaseline)
//add kdoc to the publication
publishing.publications.mavenJava.artifact(kdocZip)

0 comments on commit 3d8d226

Please sign in to comment.