File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
buildSrc/src/main/kotlin/io/tnboot/gradle/build
telenor-boot-dependencies Expand file tree Collapse file tree 2 files changed +15
-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 isEnabled 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.isEnabled ) 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 1
1
import io.tnboot.gradle.build.DependencyGroups
2
+ import io.tnboot.gradle.build.PublishPlugin
2
3
import io.tnboot.gradle.build.mavenPublish
3
4
4
5
plugins {
@@ -15,6 +16,13 @@ val bom = DependencyGroups(
15
16
dependencies {
16
17
constraints {
17
18
bom.dependencies.forEach { add(" api" , it) }
19
+
20
+ rootProject.allprojects.filter {
21
+ it != project && it.plugins.hasPlugin(PublishPlugin ::class .java) &&
22
+ it.extensions.getByType(PublishPlugin .Extension ::class .java).isEnabled
23
+ }.forEach {
24
+ add(" api" , it)
25
+ }
18
26
}
19
27
}
20
28
You can’t perform that action at this time.
0 commit comments