File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
buildSrc/src/main/kotlin/io/tnboot/gradle/build
telenor-boot-dependencies Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ class PublishPlugin : Plugin<Project> {
20
20
}
21
21
}
22
22
23
- open class Extension {
23
+ open class Extension (
24
+ private val project : Project ,
25
+ ) {
24
26
var enabled = true
25
27
var evenWithChildren = false
26
28
@@ -37,13 +39,15 @@ class PublishPlugin : Plugin<Project> {
37
39
fun configure (block : MavenPublication .() -> Unit ) {
38
40
configurations.add(block)
39
41
}
42
+
43
+ val isPublished get() = enabled && (evenWithChildren || project.childProjects.isEmpty())
40
44
}
41
45
42
46
override fun apply (target : Project ) {
43
- target.extensions.add(Extension ::class .java, " publish" , Extension ())
47
+ target.extensions.add(Extension ::class .java, " publish" , Extension (target ))
44
48
target.afterEvaluate {
45
49
target.extensions.getByType(Extension ::class .java).let { extension ->
46
- if (! extension.enabled || (target.childProjects.isNotEmpty() && ! extension.evenWithChildren) ) return @afterEvaluate
50
+ if (! extension.isPublished ) return @afterEvaluate
47
51
log.debug(" Enabling Maven Publications for project {}" , target.name)
48
52
target.mavenPublish {
49
53
extension.configurations.forEach {
Original file line number Diff line number Diff line change @@ -32,3 +32,10 @@ fun Project.mavenPublish(block: MavenPublication.() -> Unit) {
32
32
}
33
33
}
34
34
}
35
+
36
+ val Project .publishedProjects get() = rootProject.allprojects.filter {
37
+ it != project && it.plugins.hasPlugin(PublishPlugin ::class .java) &&
38
+ it.extensions.getByType(PublishPlugin .Extension ::class .java).isPublished
39
+ }
40
+
41
+ val Project .notation get() = " $group :$name :$version "
Original file line number Diff line number Diff line change 1
1
import io.tnboot.gradle.build.DependencyGroups
2
2
import io.tnboot.gradle.build.mavenPublish
3
+ import io.tnboot.gradle.build.notation
4
+ import io.tnboot.gradle.build.publishedProjects
3
5
4
6
plugins {
5
7
`java- platform`
@@ -15,6 +17,7 @@ val bom = DependencyGroups(
15
17
dependencies {
16
18
constraints {
17
19
bom.dependencies.forEach { add(" api" , it) }
20
+ publishedProjects.forEach { add(" api" , it.notation) }
18
21
}
19
22
}
20
23
You can’t perform that action at this time.
0 commit comments