Skip to content

Commit a929da7

Browse files
committed
refactor(buildSrc): Configure publication of plugins via conventions
This nicely deduplicates the publishing code for plugin platforms in favor of the more complete configuration in the publication conventions. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent dd16768 commit a929da7

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

buildSrc/src/main/kotlin/ort-plugins-conventions.gradle.kts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ plugins {
2424

2525
// Apply precompiled plugins.
2626
id("ort-base-conventions")
27+
id("ort-publication-conventions")
2728
}
2829

2930
javaPlatform {
@@ -41,29 +42,3 @@ dependencies {
4142
api(it)
4243
}
4344
}
44-
45-
configure<PublishingExtension> {
46-
publications {
47-
create<MavenPublication>(name) {
48-
groupId = "org.ossreviewtoolkit.plugins"
49-
50-
from(components["javaPlatform"])
51-
52-
pom {
53-
licenses {
54-
license {
55-
name = "Apache-2.0"
56-
url = "https://www.apache.org/licenses/LICENSE-2.0"
57-
}
58-
}
59-
60-
scm {
61-
connection = "scm:git:https://github.com/oss-review-toolkit/ort.git"
62-
developerConnection = "scm:git:[email protected]:oss-review-toolkit/ort.git"
63-
tag = version.toString()
64-
url = "https://github.com/oss-review-toolkit/ort"
65-
}
66-
}
67-
}
68-
}
69-
}

buildSrc/src/main/kotlin/ort-publication-conventions.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ configure<PublishingExtension> {
3535

3636
groupId = "org${getGroupId(parent)}"
3737

38-
from(components["java"])
39-
artifact(tasks["sourcesJar"])
40-
artifact(tasks["docsJavadocJar"])
38+
listOf("java", "javaPlatform").mapNotNull { components.findByName(it) }.forEach(::from)
39+
listOf("sourcesJar", "docsJavadocJar").mapNotNull { tasks.findByName(it) }.forEach(::artifact)
4140

4241
pom {
4342
name = project.name

0 commit comments

Comments
 (0)