@@ -382,6 +382,7 @@ class SemanticVersionPluginTest {
382382 allprojects {
383383 apply(plugin = "java-library")
384384 apply(plugin = "maven-publish")
385+ apply(plugin = "dev.poolside.gradle.semantic-version")
385386 repositories {
386387 mavenCentral()
387388 maven { url = uri("${mavenRepo.absolutePath} ") }
@@ -455,6 +456,7 @@ class SemanticVersionPluginTest {
455456 allprojects {
456457 apply(plugin = "java-library")
457458 apply(plugin = "maven-publish")
459+ apply(plugin = "dev.poolside.gradle.semantic-version")
458460 repositories {
459461 mavenCentral()
460462 maven { url = uri("${mavenRepo.absolutePath} ") }
@@ -772,4 +774,113 @@ class SemanticVersionPluginTest {
772774 val jarFiles = mavenRepo.walk().filter { it.name.endsWith(" my-library-0.1.1.jar" ) }.toList()
773775 assertTrue(jarFiles.isEmpty())
774776 }
777+
778+ @ParameterizedTest(name = " {index} gradle version {0}" )
779+ @MethodSource(" gradleVersions" )
780+ fun `subproject only has plugin installed` (gradleVersion : String ) {
781+ val build = """
782+ plugins {
783+ `java`
784+ }
785+ allprojects {
786+ apply(plugin = "java")
787+ repositories {
788+ mavenCentral()
789+ maven { url = uri("${mavenRepo.absolutePath} ") }
790+ }
791+ java {
792+ group = "dev.poolside.test"
793+ }
794+ }
795+ """ .trimIndent()
796+ FileManager .writeFile(folder = testProjectDir, filename = " build.gradle.kts" , content = build)
797+ val settings = """
798+ rootProject.name = "testing"
799+ include("lib")
800+ include("lib2")
801+ """ .trimIndent()
802+ FileManager .writeFile(folder = testProjectDir, filename = " settings.gradle.kts" , content = settings)
803+ val libBuild = """
804+ plugins {
805+ `java-library`
806+ `maven-publish`
807+ id("dev.poolside.gradle.semantic-version")
808+ }
809+ java {
810+ version = "0.1"
811+ }
812+ publishing {
813+ publications {
814+ create<MavenPublication>("mavenJava") {
815+ artifactId = "my-sublibrary"
816+ from(components["java"])
817+ }
818+ }
819+ repositories {
820+ maven { url = uri("${mavenRepo.absolutePath} ") }
821+ }
822+ }
823+ dependencies {
824+ api("org.apache.commons:commons-math3:3.6.1")
825+ implementation("com.google.guava:guava:30.1.1-jre")
826+ }
827+ """ .trimIndent()
828+ FileManager .writeFile(folder = testProjectDir, path = " lib" , filename = " build.gradle.kts" , content = libBuild)
829+ val lib2Build = """
830+ plugins {
831+ `java-library`
832+ `maven-publish`
833+ id("dev.poolside.gradle.semantic-version")
834+ }
835+ java {
836+ version = "0.2"
837+ }
838+ publishing {
839+ publications {
840+ create<MavenPublication>("mavenJava") {
841+ artifactId = "my-sublibrary2"
842+ from(components["java"])
843+ }
844+ }
845+ repositories {
846+ maven { url = uri("${mavenRepo.absolutePath} ") }
847+ }
848+ }
849+ dependencies {
850+ api("org.apache.commons:commons-math3:3.6.1")
851+ implementation("com.google.guava:guava:30.1.1-jre")
852+ }
853+ """ .trimIndent()
854+ FileManager .writeFile(folder = testProjectDir, path = " lib2" , filename = " build.gradle.kts" , content = lib2Build)
855+ GradleRunner .create()
856+ .withPluginClasspath()
857+ .withProjectDir(testProjectDir)
858+ .withGradleVersion(gradleVersion)
859+ .withArguments(" :lib:publish" , " :lib2:publish" )
860+ // .withDebug(true)
861+ .build()
862+ testProjectDir.walk().filter { it.name.startsWith(" pom" ) }.forEach { pomFile ->
863+ pomFile.forEachLine { println (it) }
864+ val pom = PomParser .parse(pomFile.absolutePath)
865+ if (pom.artifactId == " my-sublibrary" ) {
866+ assertEquals(" 0.1.0" , pom.version)
867+ } else if (pom.artifactId == " my-sublibrary2" ) {
868+ assertEquals(" 0.2.0" , pom.version)
869+ } else {
870+ fail()
871+ }
872+ }
873+ val valid = mutableListOf (
874+ " ${mavenRepo.absolutePath} /dev/poolside/test/my-sublibrary/0.1.0/my-sublibrary-0.1.0.jar" ,
875+ " ${mavenRepo.absolutePath} /dev/poolside/test/my-sublibrary2/0.2.0/my-sublibrary2-0.2.0.jar"
876+ )
877+ mavenRepo.walk().filter { it.name.endsWith(" .jar" ) }.forEach { jarFile ->
878+ if (valid.contains(jarFile.absolutePath)) {
879+ valid.remove(jarFile.absolutePath)
880+ } else {
881+ fail(" missing jarfile ${jarFile.absolutePath} " )
882+ }
883+ }
884+ assertTrue(valid.isEmpty())
885+ }
775886}
0 commit comments