Skip to content

Commit 4ee08cd

Browse files
committed
build configuration for publishing artifacts to Maven Central
1 parent 17cfa85 commit 4ee08cd

File tree

15 files changed

+254
-17
lines changed

15 files changed

+254
-17
lines changed

build.gradle

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ plugins {
2525
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
2626
id 'net.corda.plugins.cordapp' version '5.0.12'
2727
id 'net.corda.plugins.cordformation' version '5.0.12'
28+
id 'org.jetbrains.dokka' version "1.4.10.2"
29+
id 'maven-publish'
30+
id 'signing'
2831
}
2932

33+
def moduleProjects = subprojects.findAll { gradle.ext.moduleProjects.contains(it.name) }
34+
3035
allprojects {
3136
repositories {
3237
mavenLocal()
@@ -36,9 +41,8 @@ allprojects {
3641
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda' }
3742
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
3843

39-
flatDir {
40-
dirs "${rootProject.rootDir}/javax-json-shaded/build/libs"
41-
}
44+
// Cordaptor snapshots are published here
45+
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
4246
}
4347
}
4448

@@ -47,6 +51,8 @@ subprojects {
4751
version = getProperty("cordaptor_version")
4852

4953
apply plugin: 'org.jetbrains.kotlin.jvm'
54+
apply plugin: 'maven-publish'
55+
apply plugin: 'signing'
5056

5157
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
5258
kotlinOptions {
@@ -65,3 +71,72 @@ subprojects {
6571
archivesBaseName = "cordaptor-${project.name}"
6672
}
6773
}
74+
75+
// applying common configuration to modules that produce artifacts
76+
// which we publish to Maven Central
77+
configure(moduleProjects) {
78+
task sourcesJar(type: Jar) {
79+
classifier = 'sources'
80+
from sourceSets.main.allSource
81+
}
82+
83+
task javadocJar(type: Jar) {
84+
classifier = 'javadoc'
85+
from "${rootProject.projectDir}/etc/no-javadocs.txt"
86+
}
87+
88+
publishing {
89+
publications {
90+
maven(MavenPublication) {
91+
artifactId = "cordaptor-${project.name}"
92+
93+
from components.java
94+
95+
artifact sourcesJar
96+
artifact javadocJar
97+
98+
pom {
99+
url = "https://github.com/b180tech/cordaptor"
100+
licenses {
101+
license {
102+
name = "GNU Affero General Public License v3.0 or later"
103+
url = "https://spdx.org/licenses/AGPL-3.0-or-later"
104+
}
105+
}
106+
developers {
107+
developer {
108+
id = "bond180"
109+
name = "Bond180 Limited"
110+
111+
}
112+
}
113+
scm {
114+
connection = "scm:git:git://github.com/b180tech/cordaptor.git"
115+
developerConnection = "scm:git:ssh://github.com:b180tech/cordaptor.git"
116+
url = "https://github.com/b180tech/cordaptor"
117+
}
118+
}
119+
}
120+
}
121+
122+
repositories {
123+
maven {
124+
credentials {
125+
username project.sonatypeOssUsername
126+
password project.sonatypeOssPassword
127+
}
128+
129+
name = "central"
130+
131+
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
132+
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
133+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
134+
}
135+
}
136+
}
137+
138+
signing {
139+
required { version.endsWith('SNAPSHOT') }
140+
sign publishing.publications.maven
141+
}
142+
}

bundle-rest-embedded/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,15 @@ task bundleReferenceConf {
6262
}
6363
}
6464

65-
jar.dependsOn(bundleReferenceConf)
65+
jar.dependsOn(bundleReferenceConf)
66+
67+
publishing {
68+
publications {
69+
maven(MavenPublication) {
70+
pom {
71+
name = "Cordaptor embedded CorDapp bundle"
72+
description = "Single-file deployable CorDapp embedding Cordaptor into a Corda node"
73+
}
74+
}
75+
}
76+
}

corda-common/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ dependencies {
1313
testImplementation "net.corda:corda-core:$corda_core_release_version"
1414
testImplementation "com.google.guava:guava:$guava_version"
1515
}
16+
17+
publishing {
18+
publications {
19+
maven(MavenPublication) {
20+
artifactId = "cordaptor-${project.name}"
21+
22+
pom {
23+
name = "Cordaptor Corda Common"
24+
description = "Common definitions and helpers for integrating with Corda"
25+
}
26+
}
27+
}
28+
}

corda-rpc-client/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,14 @@ dependencies {
2020
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
2121
testImplementation "com.google.guava:guava:$guava_version"
2222
}
23+
24+
publishing {
25+
publications {
26+
maven(MavenPublication) {
27+
pom {
28+
name = "Cordaptor Corda RPC Client"
29+
description = "Entry point for standalone Cordaptor connecting to a Corda node via RPC"
30+
}
31+
}
32+
}
33+
}

corda-service/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ dependencies {
2222
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
2323
testImplementation "com.google.guava:guava:$guava_version"
2424
}
25+
26+
publishing {
27+
publications {
28+
maven(MavenPublication) {
29+
pom {
30+
name = "Cordaptor Corda Service"
31+
description = "Implementation of Corda service instantiating Cordaptor inside a Corda node"
32+
}
33+
}
34+
}
35+
}

etc/no-javadocs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Javadocs are not provided because the project is developed in Kotlin, a JVM language.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# build versions
2-
cordaptor_version = 0.1.0
1+
# build versions (-SNAPSHOT at the end triggers deployment to snapshots repo, as opposed to Maven Central)
2+
cordaptor_version = 0.1.0-SNAPSHOT
33

44
# versions of dependencies
55
koin_version=2.1.6

javax-json-shaded/build.gradle

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,92 @@ buildscript {
1010
plugins {
1111
id 'com.github.johnrengelman.shadow' version '6.1.0'
1212
id 'java'
13+
id 'maven-publish'
14+
id 'signing'
1315
}
1416

1517
apply plugin: 'com.github.johnrengelman.shadow'
1618
apply plugin: 'java'
19+
apply plugin: 'maven-publish'
20+
apply plugin: 'signing'
21+
22+
group = 'tech.b180.cordaptor'
23+
version = '1.1'
1724

1825
repositories {
1926
jcenter()
2027
}
2128

2229
shadowJar {
23-
archiveVersion = ""
24-
2530
relocate 'javax.json', 'tech.b180.cordaptor.shaded.javax.json'
2631
relocate 'org.glassfish.json', 'tech.b180.cordaptor.shaded.org.glassfish.json'
32+
33+
// do not append "-all", so the generated shadow jar replaces the existing jar
34+
classifier = ''
2735
}
2836

2937
dependencies {
3038
implementation "org.glassfish:javax.json:1.1"
3139
}
40+
41+
task sourcesJar(type: Jar) {
42+
classifier = 'sources'
43+
from "${projectDir}/etc/no-sources.txt"
44+
}
45+
46+
task javadocJar(type: Jar) {
47+
classifier = 'javadoc'
48+
from "${projectDir}/etc/no-javadocs.txt"
49+
}
50+
51+
publishing {
52+
publications {
53+
maven(MavenPublication) {
54+
artifact shadowJar
55+
artifact sourcesJar
56+
artifact javadocJar
57+
58+
pom {
59+
name = "Common Development and Distribution License 1.1"
60+
description = "Shaded implementation of javax.json 1.1 into Cordaptor package namespace"
61+
url = "https://github.com/b180tech/cordaptor"
62+
licenses {
63+
license {
64+
name = "CDDL 1.1"
65+
url = "https://spdx.org/licenses/CDDL-1.1.html"
66+
}
67+
}
68+
developers {
69+
developer {
70+
id = "bond180"
71+
name = "Bond180 Limited"
72+
73+
}
74+
}
75+
scm {
76+
connection = "https://github.com/b180tech/cordaptor.git"
77+
url = "https://github.com/b180tech/cordaptor"
78+
}
79+
}
80+
}
81+
}
82+
83+
repositories {
84+
maven {
85+
credentials {
86+
username project.sonatypeOssUsername
87+
password project.sonatypeOssPassword
88+
}
89+
90+
name = "central"
91+
92+
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
93+
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
94+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
95+
}
96+
}
97+
}
98+
99+
signing {
100+
sign publishing.publications.maven
101+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This archive contains classes shaded from javax.json and org.glassfish.json packages.
2+
There are no javadocs of its own.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This archive contains classes shaded from javax.json and org.glassfish.json packages.
2+
There are no sources of its own.

0 commit comments

Comments
 (0)