Skip to content

Commit a6beabe

Browse files
committed
Move publishing logic to conventions
1 parent 0a2b7a0 commit a6beabe

File tree

3 files changed

+126
-177
lines changed

3 files changed

+126
-177
lines changed

build.gradle

Lines changed: 1 addition & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
alias(libs.plugins.nebula.release) apply false
2+
alias(libs.plugins.nebula.release)
33
alias(libs.plugins.gradle.nexus.publish)
44
id("org.openrndr.extra.convention.dokka")
55
}
@@ -8,37 +8,6 @@ repositories {
88
mavenCentral()
99
}
1010

11-
def multiplatformModules = [
12-
"orx-camera",
13-
"orx-color",
14-
"orx-compositor",
15-
"orx-compute-graph",
16-
"orx-compute-graph-nodes",
17-
"orx-easing",
18-
"orx-fx",
19-
"orx-gradient-descent",
20-
"orx-image-fit",
21-
"orx-jumpflood",
22-
"orx-marching-squares",
23-
"orx-no-clear",
24-
"orx-noise",
25-
"orx-parameters",
26-
"orx-property-watchers",
27-
"orx-shade-styles",
28-
"orx-shader-phrases",
29-
"orx-shapes",
30-
"orx-quadtree",
31-
"orx-hash-grid",
32-
"orx-depth-camera",
33-
"orx-triangulation",
34-
"orx-view-box",
35-
"orx-turtle"
36-
]
37-
38-
def doNotPublish = ["openrndr-demos"]
39-
40-
def isReleaseVersion = !version.endsWith("SNAPSHOT")
41-
4211
task buildMainReadme {
4312
doFirst {
4413
def subProjects = project.subprojects
@@ -119,149 +88,6 @@ task buildMainReadme {
11988
mainReadme.write(newReadme.join("\n"))
12089
}
12190
}
122-
123-
// publishable && multiplatform
124-
configure(allprojects.findAll { !doNotPublish.contains(it.name) && (multiplatformModules.contains(it.name)) }) {
125-
apply plugin: 'maven-publish'
126-
apply plugin: 'signing'
127-
128-
def fjdj = tasks.create("fakeJavaDocJar", Jar) {
129-
archiveClassifier = "javadoc"
130-
}
131-
132-
publishing {
133-
publications {
134-
matching { it.name == "jvm" }.all { p ->
135-
artifact(fjdj)
136-
}
137-
}
138-
publications {
139-
all {
140-
versionMapping {
141-
allVariants {
142-
fromResolutionOf("allSourceSetsRuntimeDependenciesMetadata")
143-
}
144-
}
145-
pom {
146-
name = "$project.name"
147-
description = "$project.name"
148-
url = 'https://openrndr.org'
149-
developers {
150-
developer {
151-
id = 'edwinjakobs'
152-
name = 'Edwin Jakobs'
153-
154-
}
155-
}
156-
license {
157-
licenses {
158-
license {
159-
name = 'BSD-2-Clause'
160-
url = 'https://github.com/openrndr/orx/blob/master/LICENSE'
161-
distribution = 'repo'
162-
}
163-
}
164-
}
165-
scm {
166-
connection = "scm:git:[email protected]:openrndr/orx.git"
167-
developerConnection = "scm:git:ssh://github.com/openrndr/orx.git"
168-
url = "https://github.com/openrndr/orx"
169-
}
170-
}
171-
}
172-
}
173-
repositories {
174-
maven {
175-
credentials {
176-
username findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
177-
password findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")
178-
}
179-
if (!isReleaseVersion) {
180-
url "https://s01.oss.sonatype.org/content/repositories/snapshots"
181-
} else {
182-
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
183-
}
184-
}
185-
}
186-
}
187-
signing {
188-
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
189-
sign publishing.publications
190-
}
191-
}
192-
193-
// publishable && JVM only
194-
configure(allprojects.findAll { !doNotPublish.contains(it.name) && !multiplatformModules.contains(it.name) }) {
195-
apply plugin: 'java'
196-
apply plugin: 'maven-publish'
197-
apply plugin: 'nebula.release'
198-
apply plugin: 'signing'
199-
200-
java {
201-
withJavadocJar()
202-
withSourcesJar()
203-
}
204-
publishing {
205-
publications {
206-
maven(MavenPublication) {
207-
from components.java
208-
versionMapping {
209-
allVariants {
210-
fromResolutionResult()
211-
}
212-
}
213-
groupId = "org.openrndr.extra"
214-
artifactId = "$project.name"
215-
description = "$project.name"
216-
pom {
217-
name = "$project.name"
218-
description = "$project.name"
219-
url = 'https://openrndr.org'
220-
developers {
221-
developer {
222-
id = 'edwinjakobs'
223-
name = 'Edwin Jakobs'
224-
225-
}
226-
}
227-
license {
228-
licenses {
229-
license {
230-
name = 'BSD-2-Clause'
231-
url = 'https://github.com/openrndr/orx/blob/master/LICENSE'
232-
distribution = 'repo'
233-
}
234-
}
235-
}
236-
scm {
237-
connection = "scm:git:[email protected]:openrndr/orx.git"
238-
developerConnection = "scm:git:ssh://github.com/openrndr/orx.git"
239-
url = "https://github.com/openrndr/orx"
240-
}
241-
}
242-
}
243-
}
244-
repositories {
245-
maven {
246-
credentials {
247-
username findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
248-
password findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")
249-
}
250-
if (!isReleaseVersion) {
251-
url "https://s01.oss.sonatype.org/content/repositories/snapshots"
252-
} else {
253-
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
254-
}
255-
}
256-
}
257-
258-
}
259-
signing {
260-
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
261-
sign publishing.publications
262-
}
263-
}
264-
26591
group = "org.openrndr.extra"
26692

26793
nexusPublishing {

buildSrc/src/main/kotlin/org/openrndr/extra/convention/kotlin-jvm.gradle.kts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
package org.openrndr.extra.convention
22

3+
import gradle.kotlin.dsl.accessors._e1ec756838cb41004a28483270a62877.publishing
34
import org.gradle.accessors.dm.LibrariesForLibs
45
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
56
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7+
import java.net.URI
68

79
val libs = the<LibrariesForLibs>()
810

11+
val shouldPublish = project.name !in setOf("openrndr-demos")
12+
913
plugins {
1014
java
1115
kotlin("jvm")
12-
id("maven-publish")
16+
`maven-publish` apply false
1317
id("org.openrndr.extra.convention.component-metadata-rule")
1418
id("org.openrndr.extra.convention.dokka")
19+
signing
20+
}
21+
if (shouldPublish) {
22+
apply(plugin = "maven-publish")
1523
}
1624

25+
//apply(plugin = "nebula.release")
26+
1727
repositories {
1828
mavenCentral()
1929
mavenLocal()
@@ -59,4 +69,55 @@ tasks {
5969
kotlinOptions.apiVersion = libs.versions.kotlinApi.get()
6070
kotlinOptions.languageVersion = libs.versions.kotlinLanguage.get()
6171
}
72+
}
73+
74+
java {
75+
withJavadocJar()
76+
withSourcesJar()
77+
}
78+
79+
val isReleaseVersion = !(version.toString()).endsWith("SNAPSHOT")
80+
81+
if (shouldPublish) {
82+
publishing {
83+
publications {
84+
create<MavenPublication>("maven") {
85+
from(components["java"])
86+
groupId = "org.openrndr.extra"
87+
artifactId = project.name
88+
description = project.name
89+
pom {
90+
name.set("$project.name")
91+
description.set("$project.name")
92+
url.set("https://openrndr.org")
93+
developers {
94+
developer {
95+
id.set("edwinjakobs")
96+
name.set("Edwin Jakobs")
97+
email.set("[email protected]")
98+
}
99+
}
100+
101+
licenses {
102+
license {
103+
name.set("BSD-2-Clause")
104+
url.set("https://github.com/openrndr/orx/blob/master/LICENSE")
105+
distribution.set("repo")
106+
}
107+
}
108+
109+
scm {
110+
connection.set("scm:git:[email protected]:openrndr/orx.git")
111+
developerConnection.set("scm:git:ssh://github.com/openrndr/orx.git")
112+
url.set("https://github.com/openrndr/orx")
113+
}
114+
}
115+
}
116+
}
117+
}
118+
119+
signing {
120+
setRequired({ isReleaseVersion && gradle.taskGraph.hasTask("publish") })
121+
sign(publishing.publications)
122+
}
62123
}

buildSrc/src/main/kotlin/org/openrndr/extra/convention/kotlin-multiplatform.gradle.kts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ import CollectScreenshotsTask
44
import org.gradle.accessors.dm.LibrariesForLibs
55
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
66
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7+
import java.net.URI
78

89
val libs = the<LibrariesForLibs>()
910

11+
val shouldPublish = project.name !in setOf("openrndr-demos")
12+
1013
plugins {
1114
kotlin("multiplatform")
12-
id("maven-publish")
15+
`maven-publish` apply false
1316
id("org.openrndr.extra.convention.component-metadata-rule")
1417
id("org.openrndr.extra.convention.dokka")
18+
signing
19+
}
20+
if (shouldPublish) {
21+
apply(plugin = "maven-publish")
1522
}
1623

1724
repositories {
@@ -87,4 +94,59 @@ kotlin {
8794
}
8895
}
8996
}
97+
}
98+
99+
val isReleaseVersion = !(version.toString()).endsWith("SNAPSHOT")
100+
101+
if (shouldPublish) {
102+
publishing {
103+
publications {
104+
val fjdj = tasks.create("fakeJavaDocJar", Jar::class) {
105+
archiveClassifier.set("javadoc")
106+
}
107+
matching { it.name == "jvm" }.forEach { p ->
108+
p as MavenPublication
109+
p.artifact(fjdj)
110+
}
111+
all {
112+
this as MavenPublication
113+
versionMapping {
114+
allVariants {
115+
fromResolutionOf("allSourceSetsRuntimeDependenciesMetadata")
116+
}
117+
}
118+
pom {
119+
name.set("$project.name")
120+
description.set("$project.name")
121+
url.set("https://openrndr.org")
122+
developers {
123+
developer {
124+
id.set("edwinjakobs")
125+
name.set("Edwin Jakobs")
126+
email.set("[email protected]")
127+
}
128+
}
129+
130+
licenses {
131+
license {
132+
name.set("BSD-2-Clause")
133+
url.set("https://github.com/openrndr/orx/blob/master/LICENSE")
134+
distribution.set("repo")
135+
}
136+
}
137+
138+
scm {
139+
connection.set("scm:git:[email protected]:openrndr/orx.git")
140+
developerConnection.set("scm:git:ssh://github.com/openrndr/orx.git")
141+
url.set("https://github.com/openrndr/orx")
142+
}
143+
}
144+
}
145+
}
146+
}
147+
148+
signing {
149+
setRequired({ isReleaseVersion && gradle.taskGraph.hasTask("publish") })
150+
sign(publishing.publications)
151+
}
90152
}

0 commit comments

Comments
 (0)