From 1cc1bfa27b40e9463b98420960d3bf38662ad7ff Mon Sep 17 00:00:00 2001 From: Steve Hill Date: Sat, 9 May 2020 07:33:27 -0700 Subject: [PATCH] Set archivesBaseName from jenkinsPlugin.shortName Fixes #163 --- .../org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy | 3 +++ .../jpi/AbstractManifestIntegrationSpec.groovy | 11 ++++++----- .../plugins/jpi/JarManifestIntegrationSpec.groovy | 4 ++-- .../gradle/plugins/jpi/JpiExtensionSpec.groovy | 3 --- .../plugins/jpi/JpiManifestIntegrationSpec.groovy | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy b/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy index 59cf446b..4e7ede29 100644 --- a/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy +++ b/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy @@ -129,6 +129,9 @@ class JpiPlugin implements Plugin { configureTestDependencies(gradleProject) configurePublishing(gradleProject) configureTestHpl(gradleProject) + gradleProject.afterEvaluate { + gradleProject.setProperty('archivesBaseName', ext.shortName) + } } private static Properties loadDotJenkinsOrg() { diff --git a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/AbstractManifestIntegrationSpec.groovy b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/AbstractManifestIntegrationSpec.groovy index 84b39c92..c9a9f8df 100644 --- a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/AbstractManifestIntegrationSpec.groovy +++ b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/AbstractManifestIntegrationSpec.groovy @@ -17,7 +17,7 @@ abstract class AbstractManifestIntegrationSpec extends IntegrationSpec { abstract String taskToRun() - abstract String generatedFileName() + abstract String generatedFileName(String base = "${projectName}-${projectVersion}") def setup() { settings = projectDir.newFile('settings.gradle') @@ -58,7 +58,7 @@ abstract class AbstractManifestIntegrationSpec extends IntegrationSpec { '''.stripIndent() when: - def actual = generateManifestThroughGradle() + def actual = generateManifestThroughGradle(projectVersion, 'hello') then: actual['Long-Name'] == 'hello' @@ -75,7 +75,7 @@ abstract class AbstractManifestIntegrationSpec extends IntegrationSpec { '''.stripIndent() when: - def actual = generateManifestThroughGradle() + def actual = generateManifestThroughGradle(projectVersion, 'hello') then: actual['Long-Name'] == 'The Hello Plugin' @@ -486,9 +486,10 @@ abstract class AbstractManifestIntegrationSpec extends IntegrationSpec { } @CompileStatic - Map generateManifestThroughGradle(String overrideVersion = projectVersion) { + Map generateManifestThroughGradle(String overrideVersion = projectVersion, + String overrideFileName = null) { runTask(overrideVersion) - String fileName = generatedFileName() + String fileName = overrideFileName ? generatedFileName(overrideFileName) : generatedFileName() if (overrideVersion != projectVersion) { if (overrideVersion == null) { fileName = fileName.replace('-' + projectVersion, '') diff --git a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JarManifestIntegrationSpec.groovy b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JarManifestIntegrationSpec.groovy index 11f6443c..7e5f5ce6 100644 --- a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JarManifestIntegrationSpec.groovy +++ b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JarManifestIntegrationSpec.groovy @@ -8,7 +8,7 @@ class JarManifestIntegrationSpec extends AbstractManifestIntegrationSpec { } @Override - String generatedFileName() { - "${projectName}-${projectVersion}.jar" + String generatedFileName(String base = projectName) { + "${base}-${projectVersion}.jar" } } diff --git a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy index 023cde62..ab096385 100644 --- a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy +++ b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy @@ -1,13 +1,10 @@ package org.jenkinsci.gradle.plugins.jpi -import org.gradle.api.GradleException import org.gradle.api.Project import org.gradle.testfixtures.ProjectBuilder import spock.lang.Specification class JpiExtensionSpec extends Specification { - Project project = Mock(Project) - def 'work directory defaults to work if not set'() { when: Project project = ProjectBuilder.builder().build() diff --git a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiManifestIntegrationSpec.groovy b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiManifestIntegrationSpec.groovy index eda96ce9..4d8f17db 100644 --- a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiManifestIntegrationSpec.groovy +++ b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiManifestIntegrationSpec.groovy @@ -7,7 +7,7 @@ class JpiManifestIntegrationSpec extends AbstractManifestIntegrationSpec { } @Override - String generatedFileName() { - "${projectName}.hpi" + String generatedFileName(String base = projectName) { + "${base}.hpi" } }