1+ package nebula.plugin.publishing
2+
3+ import nebula.test.dsl.*
4+ import nebula.test.dsl.TestKitAssertions.assertThat
5+ import org.gradle.testkit.runner.TaskOutcome
6+ import org.junit.jupiter.api.Test
7+ import org.junit.jupiter.api.io.TempDir
8+ import java.io.File
9+
10+ internal class MultiprojectIntegrationTest {
11+ @TempDir
12+ lateinit var projectDir: File
13+
14+ @TempDir
15+ lateinit var remoteGitDir: File
16+
17+ private fun TestProjectBuilder.sampleMultiProjectSetup () {
18+ settings {
19+ pluginManagement {
20+ plugins {
21+ id(" com.netflix.nebula.contacts" ) version " latest.release"
22+ id(" com.netflix.nebula.maven-publish" ) version " 22.1.0"
23+ id(" com.netflix.nebula.maven-apache-license" ) version " 22.1.0"
24+ id(" com.netflix.nebula.info" ) version " latest.release"
25+ id(" com.netflix.nebula.release" ) version " latest.release"
26+ }
27+ }
28+ }
29+ rootProject {
30+ plugins {
31+ // this plugin has behavior dependent on the existence of the contacts plugin
32+ id(" com.netflix.nebula.contacts" )
33+ // this plugin has behavior dependent on the existence of the info plugin
34+ id(" com.netflix.nebula.info" )
35+ // this plugin has behavior dependent on the existence of the release plugin
36+ id(" com.netflix.nebula.release" )
37+ id(" com.netflix.nebula.oss-publishing" )
38+ }
39+ // language=kotlin
40+ rawBuildScript(
41+ """
42+
43+ nebulaOssPublishing {
44+ packageGroup = "test"
45+ netflixOssRepositoryBaseUrl = "http://"
46+ netflixOssRepository = "my-releases"
47+ }
48+ contacts {
49+ addPerson("nebula-plugins-oss@netflix.com") {
50+ moniker = "Nebula Plugins Maintainers"
51+ github = "nebula-plugins"
52+ }
53+ }
54+ $DISABLE_MAVEN_CENTRAL_TASKS
55+ """
56+ )
57+ }
58+ subProject(" sub1" ) {
59+ plugins {
60+ id(" java" )
61+ // this plugin has behavior dependent on the existence of the contacts plugin
62+ id(" com.netflix.nebula.contacts" )
63+ // this plugin has behavior dependent on the existence of the info plugin
64+ id(" com.netflix.nebula.info" )
65+ id(" com.netflix.nebula.maven-publish" )
66+ id(" com.netflix.nebula.maven-apache-license" )
67+ id(" com.netflix.nebula.oss-publishing" )
68+ id(" com.netflix.nebula.release" )
69+ }
70+ // language=kotlin
71+ rawBuildScript(
72+ """
73+ group = "test"
74+ description = "description"
75+ $DISABLE_PUBLISH_TASKS
76+ """
77+ )
78+ }
79+ subProject(" sub2" ) {
80+ plugins {
81+ id(" java" )
82+ // this plugin has behavior dependent on the existence of the contacts plugin
83+ id(" com.netflix.nebula.contacts" )
84+ // this plugin has behavior dependent on the existence of the info plugin
85+ id(" com.netflix.nebula.info" )
86+ id(" com.netflix.nebula.maven-publish" )
87+ id(" com.netflix.nebula.maven-apache-license" )
88+ id(" com.netflix.nebula.oss-publishing" )
89+ id(" com.netflix.nebula.release" )
90+ }
91+ // language=kotlin
92+ rawBuildScript(
93+ """
94+ group = "test"
95+ description = "description"
96+ $DISABLE_PUBLISH_TASKS
97+ """
98+ )
99+ }
100+ }
101+
102+ @Test
103+ fun `test multi project candidate` () {
104+ val runner = withGitTag(projectDir, remoteGitDir, " v0.0.1-rc.1" ) {
105+ testProject(projectDir) {
106+ sampleMultiProjectSetup()
107+ }
108+ }
109+ val result = runner.run (
110+ " candidate" ,
111+ " -Prelease.useLastTag=true" ,
112+ " -PnetflixOss.username=user" ,
113+ " -PnetflixOss.password=password" ,
114+ " --stacktrace"
115+ )
116+ assertThat(result.task(" :initializeSonatypeStagingRepository" )).isNull()
117+
118+ // sub1
119+ assertThat(result.task(" :sub1:generateMetadataFileForNebulaPublication" ))
120+ .hasOutcome(TaskOutcome .SUCCESS )
121+ assertThat(result.task(" :sub1:generatePomFileForNebulaPublication" ))
122+ .hasOutcome(TaskOutcome .SUCCESS )
123+ assertThat(result.task(" :sub1:verifyNebulaPublicationPomForMavenCentral" )).isNull()
124+ assertThat(result.task(" :sub1:publishNebulaPublicationToSonatypeRepository" )).isNull()
125+ assertThat(result.task(" :sub1:publishNebulaPublicationToNetflixOSSRepository" ))
126+ .hasOutcome(TaskOutcome .SKIPPED )
127+
128+ // sub2
129+ assertThat(result.task(" :sub2:generateMetadataFileForNebulaPublication" ))
130+ .hasOutcome(TaskOutcome .SUCCESS )
131+ assertThat(result.task(" :sub2:generatePomFileForNebulaPublication" ))
132+ .hasOutcome(TaskOutcome .SUCCESS )
133+ assertThat(result.task(" :sub2:verifyNebulaPublicationPomForMavenCentral" )).isNull()
134+ assertThat(result.task(" :sub2:publishNebulaPublicationToSonatypeRepository" )).isNull()
135+ assertThat(result.task(" :sub2:publishNebulaPublicationToNetflixOSSRepository" ))
136+ .hasOutcome(TaskOutcome .SKIPPED )
137+
138+ assertThat(result.task(" :closeSonatypeStagingRepository" )).isNull()
139+ assertThat(result.task(" :releaseSonatypeStagingRepository" )).isNull()
140+ assertThat(result.task(" :closeAndReleaseSonatypeStagingRepository" )).isNull()
141+
142+ assertThat(result.task(" :release" )).hasOutcome(TaskOutcome .SKIPPED )
143+ assertThat(result.task(" :postRelease" )).hasOutcome(TaskOutcome .SUCCESS )
144+ assertThat(result.task(" :candidate" )).hasOutcome(TaskOutcome .SUCCESS )
145+ }
146+
147+ @Test
148+ fun `test multi project final` () {
149+ val runner = withGitTag(projectDir, remoteGitDir, " v0.0.1" ) {
150+ testProject(projectDir) {
151+ sampleMultiProjectSetup()
152+ }
153+ }
154+ val result = runner.run (
155+ " final" ,
156+ " -Prelease.useLastTag=true" ,
157+ " -PnetflixOss.username=user" ,
158+ " -PnetflixOss.password=password" ,
159+ " -Psonatype.username=user" ,
160+ " -Psonatype.password=password" ,
161+ " --stacktrace"
162+ )
163+ assertThat(result.task(" :initializeSonatypeStagingRepository" ))
164+ .hasOutcome(TaskOutcome .SKIPPED )
165+
166+ // sub1
167+ assertThat(result.task(" :sub1:generateMetadataFileForNebulaPublication" ))
168+ .hasOutcome(TaskOutcome .SUCCESS )
169+ assertThat(result.task(" :sub1:generatePomFileForNebulaPublication" ))
170+ .hasOutcome(TaskOutcome .SUCCESS )
171+ assertThat(result.task(" :sub1:verifyNebulaPublicationPomForMavenCentral" ))
172+ .hasOutcome(TaskOutcome .SUCCESS )
173+ assertThat(result.task(" :sub1:publishNebulaPublicationToSonatypeRepository" ))
174+ .hasOutcome(TaskOutcome .SKIPPED )
175+ assertThat(result.task(" :sub1:publishNebulaPublicationToNetflixOSSRepository" ))
176+ .hasOutcome(TaskOutcome .SKIPPED )
177+
178+ // sub2
179+ assertThat(result.task(" :sub2:generateMetadataFileForNebulaPublication" ))
180+ .hasOutcome(TaskOutcome .SUCCESS )
181+ assertThat(result.task(" :sub2:generatePomFileForNebulaPublication" ))
182+ .hasOutcome(TaskOutcome .SUCCESS )
183+ assertThat(result.task(" :sub2:verifyNebulaPublicationPomForMavenCentral" ))
184+ .hasOutcome(TaskOutcome .SUCCESS )
185+ assertThat(result.task(" :sub2:publishNebulaPublicationToSonatypeRepository" ))
186+ .hasOutcome(TaskOutcome .SKIPPED )
187+ assertThat(result.task(" :sub2:publishNebulaPublicationToNetflixOSSRepository" ))
188+ .hasOutcome(TaskOutcome .SKIPPED )
189+
190+ assertThat(result.task(" :closeSonatypeStagingRepository" ))
191+ .hasOutcome(TaskOutcome .SKIPPED )
192+ assertThat(result.task(" :releaseSonatypeStagingRepository" ))
193+ .hasOutcome(TaskOutcome .SKIPPED )
194+ assertThat(result.task(" :closeAndReleaseSonatypeStagingRepository" ))
195+ .hasOutcome(TaskOutcome .UP_TO_DATE )
196+
197+ assertThat(result.task(" :release" )).hasOutcome(TaskOutcome .SKIPPED )
198+ assertThat(result.task(" :postRelease" )).hasOutcome(TaskOutcome .SUCCESS )
199+ assertThat(result.task(" :final" )).hasOutcome(TaskOutcome .SUCCESS )
200+ }
201+ }
0 commit comments