diff --git a/.github/workflows/nebula.yml b/.github/workflows/nebula.yml index eac7745..30b0e52 100644 --- a/.github/workflows/nebula.yml +++ b/.github/workflows/nebula.yml @@ -9,15 +9,8 @@ on: pull_request: jobs: - validation: - name: "Gradle Wrapper Validation" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: gradle/wrapper-validation-action@v1 buildmultijdk: if: (!startsWith(github.ref, 'refs/tags/v')) - needs: validation runs-on: ubuntu-latest strategy: matrix: @@ -38,27 +31,16 @@ jobs: 17 ${{ matrix.java }} java-package: jdk - - uses: actions/cache@v4 - id: gradle-cache - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }} - restore-keys: | - - ${{ runner.os }}-gradle- - - uses: actions/cache@v4 - id: gradle-wrapper-cache + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5 with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }} - restore-keys: | - - ${{ runner.os }}-gradlewrapper- + cache-overwrite-existing: true - name: Gradle build run: ./gradlew --info --stacktrace build env: JDK_VERSION_FOR_TESTS: ${{ matrix.java }} validatepluginpublication: if: startsWith(github.ref, 'refs/tags/v') - needs: validation runs-on: ubuntu-latest name: Gradle Plugin Publication Validation env: @@ -78,20 +60,10 @@ jobs: 17 21 java-package: jdk - - uses: actions/cache@v4 - id: gradle-cache + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5 with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }} - restore-keys: | - - ${{ runner.os }}-gradle- - - uses: actions/cache@v4 - id: gradle-wrapper-cache - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }} - restore-keys: | - - ${{ runner.os }}-gradlewrapper- + cache-overwrite-existing: true - name: Verify plugin publication if: | startsWith(github.ref, 'refs/tags/v') && @@ -123,20 +95,10 @@ jobs: 17 21 java-package: jdk - - uses: actions/cache@v4 - id: gradle-cache - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }} - restore-keys: | - - ${{ runner.os }}-gradle- - - uses: actions/cache@v4 - id: gradle-wrapper-cache + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5 with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }} - restore-keys: | - - ${{ runner.os }}-gradlewrapper- + cache-overwrite-existing: true - name: Publish candidate if: | startsWith(github.ref, 'refs/tags/v') && diff --git a/build.gradle.kts b/build.gradle.kts index cab6643..6d04d5f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,9 @@ dependencies { implementation("org.apache.maven:maven-model:3.6.2") testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") testImplementation("org.junit.vintage:junit-vintage-engine:5.14.0") + testImplementation("org.ajoberstar.grgit:grgit-core:4.1.1") { + exclude (group= "org.codehaus.groovy", module= "groovy") + } } gradlePlugin { diff --git a/gradle.lockfile b/gradle.lockfile index 7d728da..a7eecdd 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -2,15 +2,18 @@ # Manual edits can break the build and are not advised. # This file is expected to be part of source control. cglib:cglib-nodep:3.2.2=integTestRuntimeClasspath,testRuntimeClasspath -com.netflix.nebula:nebula-test:11.5.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.googlecode.javaewah:JavaEWAH:1.1.12=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.netflix.nebula:nebula-test:11.6.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath io.github.gradle-nexus:publish-plugin:2.0.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath junit:junit:4.13.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath net.bytebuddy:byte-buddy:1.15.11=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.ajoberstar.grgit:grgit-core:4.1.1=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.maven:maven-model:3.6.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.assertj:assertj-core:3.27.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.codehaus.plexus:plexus-utils:3.2.1=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest-core:1.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest:2.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-reflect:2.2.0=compileClasspath,embeddedKotlin,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -27,5 +30,6 @@ org.junit.platform:junit-platform-launcher:1.14.0=integTestCompileClasspath,inte org.junit.vintage:junit-vintage-engine:5.14.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.objenesis:objenesis:2.4=integTestRuntimeClasspath,testRuntimeClasspath org.opentest4j:opentest4j:1.3.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.slf4j:slf4j-api:1.7.30=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.spockframework:spock-core:2.3-groovy-4.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath empty=annotationProcessor,integTestAnnotationProcessor,testAnnotationProcessor diff --git a/src/main/kotlin/nebula/plugin/publishing/MavenCentralPublishingPlugin.kt b/src/main/kotlin/nebula/plugin/publishing/MavenCentralPublishingPlugin.kt index 0b19284..df06d12 100644 --- a/src/main/kotlin/nebula/plugin/publishing/MavenCentralPublishingPlugin.kt +++ b/src/main/kotlin/nebula/plugin/publishing/MavenCentralPublishingPlugin.kt @@ -66,11 +66,11 @@ class MavenCentralPublishingPlugin @Inject constructor(private val providerFact throw GradleException("Could not find registered NexusPublishExtension") } - nexusPublishExtension.packageGroup.set(nebulaOssPublishingExtension.packageGroup.get()) + nexusPublishExtension.packageGroup.set(nebulaOssPublishingExtension.packageGroup) nexusPublishExtension.repositories.sonatype { nexusUrl.set(URI(sonatypeOssRepositoryUrl)) - username.set(nebulaOssPublishingExtension.sonatypeUsername.get()) - password.set(nebulaOssPublishingExtension.sonatypePassword.get()) + username.set(nebulaOssPublishingExtension.sonatypeUsername) + password.set(nebulaOssPublishingExtension.sonatypePassword) stagingProfileId.set(getStagingProfileId(project)) } diff --git a/src/main/kotlin/nebula/plugin/publishing/NebulaOssPublishingPlugin.kt b/src/main/kotlin/nebula/plugin/publishing/NebulaOssPublishingPlugin.kt index a5c3c3a..4966e67 100644 --- a/src/main/kotlin/nebula/plugin/publishing/NebulaOssPublishingPlugin.kt +++ b/src/main/kotlin/nebula/plugin/publishing/NebulaOssPublishingPlugin.kt @@ -18,13 +18,16 @@ package nebula.plugin.publishing import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.provider.ProviderFactory +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.withType import javax.inject.Inject /** * Configures artifact signing and publication to NetflixOSS and Maven Central */ -open class NebulaOssPublishingPlugin @Inject constructor(private val providerFactory: ProviderFactory): Plugin { +open class NebulaOssPublishingPlugin @Inject constructor(private val providerFactory: ProviderFactory) : + Plugin { companion object { const val netflixOssDefaultRepositoryBaseUrl = "https://artifacts-oss.netflix.net/artifactory" const val netflixOssGradlePluginsRepository = "gradle-plugins" @@ -43,6 +46,16 @@ open class NebulaOssPublishingPlugin @Inject constructor(private val providerFac project.pluginManager.apply(MavenCentralPublishingPlugin::class) project.pluginManager.apply(NebulaOssRepositoriesPlugin::class) + project.plugins.withId("com.netflix.nebula.release") { + project.afterEvaluate { + project.tasks.withType { + mustRunAfter(project.rootProject.tasks.named("release")) + } + project.rootProject.tasks.named("postRelease") { + dependsOn(project.tasks.withType()) + } + } + } } private fun setExtensionDefaults(nebulaOssPublishingExtension: NebulaOssPublishingExtension, project: Project) { @@ -64,7 +77,7 @@ open class NebulaOssPublishingPlugin @Inject constructor(private val providerFac "sonatypeStagingProfileId" ) ?: netflixDefaultStagingProfile - if(!stagingProfileId.isNotBlank()) { + if (!stagingProfileId.isNotBlank()) { extension.stagingProfileId.convention(stagingProfileId) } } @@ -77,14 +90,14 @@ open class NebulaOssPublishingPlugin @Inject constructor(private val providerFac "sonatypePackageGroup" ) ?: project.group.toString().split(".").take(2).joinToString(".") - if(packageGroup.isNotBlank()) { + if (packageGroup.isNotBlank()) { extension.packageGroup.convention(packageGroup) } } private fun setSigningKey(extension: NebulaOssPublishingExtension, project: Project) { val signingKeyFile = project.rootProject.file(signingKeyFileLocation) - if(signingKeyFile.exists()) { + if (signingKeyFile.exists()) { extension.signingKey.convention(signingKeyFile.readText()) } else { val signingKey = findPropertyValue( @@ -93,54 +106,64 @@ open class NebulaOssPublishingPlugin @Inject constructor(private val providerFac "sonatype.signingKey", "netflixOssSigningKey" ) - if(!signingKey.isNullOrBlank()) { + if (!signingKey.isNullOrBlank()) { extension.signingKey.convention(signingKey) } } } private fun setSigningPassword(extension: NebulaOssPublishingExtension, project: Project) { - val signingPassword = findPropertyValue(project, + val signingPassword = findPropertyValue( + project, "NETFLIX_OSS_SIGNING_PASSWORD", "sonatype.signingPassword", - "netflixOssSigningPassword") - if(!signingPassword.isNullOrBlank()) { + "netflixOssSigningPassword" + ) + if (!signingPassword.isNullOrBlank()) { extension.signingPassword.convention(signingPassword) } } private fun setNetflixOssCredentials(extension: NebulaOssPublishingExtension, project: Project) { - val netflixOssUsername = findPropertyValue(project, + val netflixOssUsername = findPropertyValue( + project, "NETFLIX_OSS_REPO_USERNAME", "netflixOss.username", - "netflixOssUsername") - if(!netflixOssUsername.isNullOrBlank()) { + "netflixOssUsername" + ) + if (!netflixOssUsername.isNullOrBlank()) { extension.netflixOssUsername.convention(netflixOssUsername) } - val netflixOssPassword = findPropertyValue(project, + val netflixOssPassword = findPropertyValue( + project, "NETFLIX_OSS_REPO_PASSWORD", "netflixOss.password", - "netflixOssPassword") - if(!netflixOssPassword.isNullOrBlank()) { + "netflixOssPassword" + ) + if (!netflixOssPassword.isNullOrBlank()) { extension.netflixOssPassword.convention(netflixOssPassword) } } private fun setMavenCentralCredentials(extension: NebulaOssPublishingExtension, project: Project) { - val sonatypeUsername = findPropertyValue(project, + val sonatypeUsername = findPropertyValue( + project, "NETFLIX_OSS_SONATYPE_USERNAME", "sonatype.username", - "sonatypeUsername") - if(!sonatypeUsername.isNullOrBlank()) { + "sonatypeUsername" + ) + if (!sonatypeUsername.isNullOrBlank()) { extension.sonatypeUsername.convention(sonatypeUsername) } - val sonatypePassword = findPropertyValue(project, + val sonatypePassword = findPropertyValue( + project, "NETFLIX_OSS_SONATYPE_PASSWORD", "sonatype.password", - "sonatypePassword") - if(!sonatypePassword.isNullOrBlank()) { + "sonatypePassword" + ) + if (!sonatypePassword.isNullOrBlank()) { extension.sonatypePassword.convention(sonatypePassword) } } @@ -152,7 +175,7 @@ open class NebulaOssPublishingPlugin @Inject constructor(private val providerFac "netflixOss.repositoryBaseUrl", "netflixOssRepositoryBaseUrl" ) - if(!repositoryBaseUrl.isNullOrBlank()) { + if (!repositoryBaseUrl.isNullOrBlank()) { extension.netflixOssRepositoryBaseUrl.convention(repositoryBaseUrl) } else { extension.netflixOssRepositoryBaseUrl.convention(netflixOssDefaultRepositoryBaseUrl) @@ -195,32 +218,38 @@ open class NebulaOssPublishingPlugin @Inject constructor(private val providerFac } private fun projectExecutionHasTask(project: Project, task: String): Boolean { - return project.gradle.startParameter.taskNames.contains(task) || project.gradle.startParameter.taskNames.contains(":${task}") + return project.gradle.startParameter.taskNames.contains(task) || project.gradle.startParameter.taskNames.contains( + ":${task}" + ) } - private fun findPropertyValue(project: Project, - envVariableName: String, - namespacedPropertyName: String, - propertyName: String - ) : String? { + private fun findPropertyValue( + project: Project, + envVariableName: String, + namespacedPropertyName: String, + propertyName: String + ): String? { val propertyValueFromEnv = readEnvVariable(envVariableName) return when { propertyValueFromEnv != null -> { propertyValueFromEnv } + project.hasProperty(propertyName) -> { project.prop(propertyName) } + project.hasProperty(namespacedPropertyName) -> { project.prop(namespacedPropertyName) } + else -> null } } - private fun readEnvVariable(envVariableName: String) : String? { + private fun readEnvVariable(envVariableName: String): String? { val envVariable = providerFactory.environmentVariable(envVariableName) - return if(envVariable.isPresent) envVariable.get() else null + return if (envVariable.isPresent) envVariable.get() else null } private fun Project.prop(s: String): String? = project.findProperty(s) as String? diff --git a/src/test/kotlin/nebula/plugin/publishing/GitUtil.kt b/src/test/kotlin/nebula/plugin/publishing/GitUtil.kt new file mode 100644 index 0000000..116a08b --- /dev/null +++ b/src/test/kotlin/nebula/plugin/publishing/GitUtil.kt @@ -0,0 +1,36 @@ +package nebula.plugin.publishing + +import nebula.test.dsl.TestProjectRunner +import org.ajoberstar.grgit.Grgit +import java.io.File + +fun withGitTag( + projectDir: File, + remoteGitDir: File, + tag: String, + block: () -> TestProjectRunner +): TestProjectRunner { + Grgit.init { + dir = remoteGitDir + } + val localCopy = Grgit.clone { + dir = projectDir + uri = remoteGitDir.toURI().toString() + } + projectDir.resolve(".gitignore").writeText( + """ +.gradle/ +""" + ) + val runner = block() + localCopy.add { + this.patterns = setOf(".") + } + localCopy.commit { + message = "Initial" + } + localCopy.tag.add { + name = tag + } + return runner +} \ No newline at end of file diff --git a/src/test/kotlin/nebula/plugin/publishing/NebulaOssPublishingPluginTest.kt b/src/test/kotlin/nebula/plugin/publishing/NebulaOssPublishingPluginTest.kt index ffcd971..7935556 100644 --- a/src/test/kotlin/nebula/plugin/publishing/NebulaOssPublishingPluginTest.kt +++ b/src/test/kotlin/nebula/plugin/publishing/NebulaOssPublishingPluginTest.kt @@ -1,8 +1,11 @@ package nebula.plugin.publishing import nebula.test.dsl.TestKitAssertions.assertThat +import nebula.test.dsl.pluginManagement import nebula.test.dsl.plugins import nebula.test.dsl.rootProject +import nebula.test.dsl.settings +import nebula.test.dsl.subProject import nebula.test.dsl.testProject import nebula.test.dsl.version import org.gradle.testkit.runner.TaskOutcome @@ -14,29 +17,237 @@ internal class NebulaOssPublishingPluginTest { @TempDir lateinit var projectDir: File + @TempDir + lateinit var remoteGitDir: File + + companion object { + //language=kotlin + const val DISABLE_PUBLISH_TASKS : String = """ +afterEvaluate { + tasks.withType() { + onlyIf { false } + } + tasks.withType(){ + onlyIf { false } // we don't have a signing key in integration tests (yet) + } +} +""" + + + //language=kotlin + const val DISABLE_MAVEN_CENTRAL_TASKS : String = """ +tasks.named("initializeSonatypeStagingRepository"){ + onlyIf { false } +} +tasks.named("closeSonatypeStagingRepository"){ + onlyIf { false } +} +tasks.named("releaseSonatypeStagingRepository"){ + onlyIf { false } +} +""" +} + @Test - fun `Apply plugin without failures`() { - val runner = testProject(projectDir) { - rootProject { - plugins { - id("java") - id("com.netflix.nebula.maven-publish") version "19.0.0" - id("com.netflix.nebula.oss-publishing") + fun `test single project final`() { + val runner = withGitTag(projectDir, remoteGitDir, "v0.0.1") { + testProject(projectDir) { + rootProject { + plugins { + id("java") + // this plugin has behavior dependent on the existence of the contacts plugin + id("com.netflix.nebula.contacts") version "latest.release" + // this plugin has behavior dependent on the existence of the info plugin + id("com.netflix.nebula.info") version "latest.release" + id("com.netflix.nebula.maven-publish") version "latest.release" + // this plugin has behavior dependent on the existence of the release plugin + id("com.netflix.nebula.release") version "latest.release" + id("com.netflix.nebula.maven-apache-license") version "latest.release" + id("com.netflix.nebula.oss-publishing") + } + //language=kotlin + rawBuildScript( + """ +group = "test" +description = "description" +nebulaOssPublishing { + packageGroup = "test" + netflixOssRepositoryBaseUrl = "http://" + netflixOssRepository = "my-releases" +} +contacts { + addPerson("nebula-plugins-oss@netflix.com") { + moniker = "Nebula Plugins Maintainers" + github = "nebula-plugins" + } +} +$DISABLE_PUBLISH_TASKS +$DISABLE_MAVEN_CENTRAL_TASKS +""" + ) } - rawBuildScript( - """ - group = "test" - nebulaOssPublishing { - netflixOssRepositoryBaseUrl = "http://" - netflixOssRepository = "my-releases" - netflixOssUsername = "user" - netflixOssPassword = "password" } - """ - ) + } + val result = runner.run( + "final", + "-Prelease.useLastTag=true", + "-PnetflixOss.username=user", + "-PnetflixOss.password=password", + "-Psonatype.username=user", + "-Psonatype.password=password", + "--stacktrace" + ) + assertThat(result.task(":initializeSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":generateMetadataFileForNebulaPublication")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":generatePomFileForNebulaPublication")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":verifyNebulaPublicationPomForMavenCentral")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":publishNebulaPublicationToSonatypeRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":closeSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":releaseSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":closeAndReleaseSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.UP_TO_DATE) + assertThat(result.task(":publishNebulaPublicationToNetflixOSSRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":release")).hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":postRelease")).hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":final")).hasOutcome(TaskOutcome.SUCCESS) + } + + @Test + fun `test multi project final`() { + val runner = withGitTag(projectDir, remoteGitDir, "v0.0.1") { + testProject(projectDir) { + settings { + pluginManagement { + plugins { + id("com.netflix.nebula.contacts") version "latest.release" + id("com.netflix.nebula.maven-publish") version "22.1.0" + id("com.netflix.nebula.maven-apache-license") version "22.1.0" + id("com.netflix.nebula.info") version "latest.release" + } + } + } + rootProject { + plugins { + // this plugin has behavior dependent on the existence of the contacts plugin + id("com.netflix.nebula.contacts") + // this plugin has behavior dependent on the existence of the info plugin + id("com.netflix.nebula.info") + // this plugin has behavior dependent on the existence of the release plugin + id("com.netflix.nebula.release") version "latest.release" + id("com.netflix.nebula.oss-publishing") + } + //language=kotlin + rawBuildScript( + """ + +nebulaOssPublishing { + packageGroup = "test" + netflixOssRepositoryBaseUrl = "http://" + netflixOssRepository = "my-releases" +} +contacts { + addPerson("nebula-plugins-oss@netflix.com") { + moniker = "Nebula Plugins Maintainers" + github = "nebula-plugins" + } +} +$DISABLE_MAVEN_CENTRAL_TASKS +""" + ) + } + subProject("sub1"){ + plugins { + id("java") + // this plugin has behavior dependent on the existence of the contacts plugin + id("com.netflix.nebula.contacts") + // this plugin has behavior dependent on the existence of the info plugin + id("com.netflix.nebula.info") + id("com.netflix.nebula.maven-publish") + id("com.netflix.nebula.maven-apache-license") + id("com.netflix.nebula.oss-publishing") + id("com.netflix.nebula.release") version "latest.release" + } + //language=kotlin + rawBuildScript(""" +group = "test" +description = "description" +$DISABLE_PUBLISH_TASKS +""") + } + subProject("sub2"){ + plugins { + id("java") + // this plugin has behavior dependent on the existence of the contacts plugin + id("com.netflix.nebula.contacts") + // this plugin has behavior dependent on the existence of the info plugin + id("com.netflix.nebula.info") + id("com.netflix.nebula.maven-publish") + id("com.netflix.nebula.maven-apache-license") + id("com.netflix.nebula.oss-publishing") + id("com.netflix.nebula.release") version "latest.release" + } + //language=kotlin + rawBuildScript(""" +group = "test" +description = "description" +$DISABLE_PUBLISH_TASKS +""") + } } } - val result = runner.run("build") - assertThat(result.task(":build")).hasOutcome(TaskOutcome.SUCCESS) + val result = runner.run( + "final", + "-Prelease.useLastTag=true", + "-PnetflixOss.username=user", + "-PnetflixOss.password=password", + "-Psonatype.username=user", + "-Psonatype.password=password", + "--stacktrace" + ) + assertThat(result.task(":initializeSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + + // sub1 + assertThat(result.task(":sub1:generateMetadataFileForNebulaPublication")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":sub1:generatePomFileForNebulaPublication")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":sub1:verifyNebulaPublicationPomForMavenCentral")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":sub1:publishNebulaPublicationToSonatypeRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":sub1:publishNebulaPublicationToNetflixOSSRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + + // sub2 + assertThat(result.task(":sub2:generateMetadataFileForNebulaPublication")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":sub2:generatePomFileForNebulaPublication")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":sub2:verifyNebulaPublicationPomForMavenCentral")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":sub2:publishNebulaPublicationToSonatypeRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":sub2:publishNebulaPublicationToNetflixOSSRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + + assertThat(result.task(":closeSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":releaseSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":closeAndReleaseSonatypeStagingRepository")) + .hasOutcome(TaskOutcome.UP_TO_DATE) + + assertThat(result.task(":release")).hasOutcome(TaskOutcome.SKIPPED) + assertThat(result.task(":postRelease")).hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":final")).hasOutcome(TaskOutcome.SUCCESS) } } \ No newline at end of file