diff --git a/.github/workflows/nebula.yml b/.github/workflows/nebula.yml index adee7de..c0cc37b 100644 --- a/.github/workflows/nebula.yml +++ b/.github/workflows/nebula.yml @@ -83,7 +83,8 @@ jobs: - ${{ runner.os }}-gradlewrapper- - name: Verify plugin publication if: | - startsWith(github.ref, 'refs/tags/v') + startsWith(github.ref, 'refs/tags/v') && + (!contains(github.ref, '-rc.')) run: ./gradlew --stacktrace -Dgradle.publish.key=${{ secrets.gradlePublishKey }} -Dgradle.publish.secret=${{ secrets.gradlePublishSecret }} publishPlugins --validate-only -x signPluginMavenPublication -x check publish: if: startsWith(github.ref, 'refs/tags/v') diff --git a/build.gradle b/build.gradle index 8fde04f..4c2e4b4 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,7 @@ repositories { } dependencies { + compileOnly 'io.github.gradle-nexus:publish-plugin:1.0.0' implementation 'com.netflix.nebula:nebula-oss-publishing-plugin:latest.release' implementation 'com.netflix.nebula:gradle-contacts-plugin:latest.release' implementation 'com.netflix.nebula:gradle-dependency-lock-plugin:latest.release' diff --git a/gradle.lockfile b/gradle.lockfile index 88cb974..b94b7bd 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -40,7 +40,7 @@ commons-lang:commons-lang:2.4=integTestRuntimeClasspath,runtimeClasspath,testRun commons-logging:commons-logging:1.2=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath de.regnis.q.sequence:sequence-library:1.0.3=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.github.gradle-nexus:publish-plugin:1.0.0=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath +io.github.gradle-nexus:publish-plugin:1.0.0=compileClasspath,integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath joda-time:joda-time:2.10=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath junit:junit:4.12=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath net.java.dev.jna:jna-platform:5.7.0=integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath diff --git a/src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy b/src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy index 0343174..207c426 100644 --- a/src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy +++ b/src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy @@ -15,10 +15,12 @@ */ package nebula.plugin.plugin +import io.github.gradlenexus.publishplugin.AbstractNexusStagingRepositoryTask import nebula.plugin.publishing.NebulaOssPublishingExtension import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.invocation.Gradle import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory @@ -63,6 +65,7 @@ class NebulaPluginPlugin implements Plugin { static final PLUGIN_IDS = GRADLE_PLUGIN_IDS + THIRDPARTY_PLUGIN_IDS + NEBULA_PLUGIN_IDS private final ProviderFactory providers + private boolean isPluginPublishingValidation @Inject NebulaPluginPlugin(ProviderFactory providerFactory) { @@ -71,6 +74,7 @@ class NebulaPluginPlugin implements Plugin { @Override void apply(Project project) { + this.isPluginPublishingValidation = project.gradle.startParameter.taskNames.contains('--validate-only') project.with { def nebulaOssPublishingExtension = project.rootProject.extensions.findByType(NebulaOssPublishingExtension) ?: project.rootProject.extensions.create("nebulaOssPublishing", NebulaOssPublishingExtension) nebulaOssPublishingExtension.packageGroup.set("com.netflix") @@ -174,7 +178,7 @@ class NebulaPluginPlugin implements Plugin { gradle.taskGraph.whenReady { graph -> tasks.publishPlugins.onlyIf { - graph.hasTask(':final') || gradle.startParameter.taskNames.contains('--validate-only') + graph.hasTask(':final') || isPluginPublishingValidation } } } @@ -215,10 +219,28 @@ class NebulaPluginPlugin implements Plugin { } - project.tasks.withType(Sign).configureEach { - it.mustRunAfter(validatePluginsTask, project.tasks.named('check')) + /** + * Configure signing unless it is plugin validation + */ + if (!isPluginPublishingValidation) { + project.tasks.withType(Sign).configureEach { + it.mustRunAfter(validatePluginsTask, project.tasks.named('check')) + } + } + + /** + * Disable publishing to maven repositories when running --validate-only + */ + if (isPluginPublishingValidation) { + project.tasks.withType(PublishToMavenRepository).configureEach { + it.enabled = false + } + project.tasks.withType(AbstractNexusStagingRepositoryTask).configureEach { + it.enabled = false + } } } + } private void disableGradleModuleMetadataTask(Project project) {