diff --git a/src/main/groovy/nebula/plugin/info/basic/BasicInfoPlugin.groovy b/src/main/groovy/nebula/plugin/info/basic/BasicInfoPlugin.groovy index 49f765c..c92a509 100644 --- a/src/main/groovy/nebula/plugin/info/basic/BasicInfoPlugin.groovy +++ b/src/main/groovy/nebula/plugin/info/basic/BasicInfoPlugin.groovy @@ -58,7 +58,7 @@ class BasicInfoPlugin implements Plugin, InfoCollectorPlugin { // All fields are known upfront, so we pump these in immediately. project.plugins.withType(InfoBrokerPlugin) { InfoBrokerPlugin manifestPlugin -> manifestPlugin.add(MANIFEST_VERSION.toString(), '1.0') // Java Standard - manifestPlugin.add(IMPLEMENTATION_TITLE.toString()) { "${project.group}#${project.name};${project.version}" } // !${jarTask.name}(jar)" + manifestPlugin.add(IMPLEMENTATION_TITLE.toString()) { "${project.group}#${project.name};${project.version}" }.changing = true manifestPlugin.add(IMPLEMENTATION_VERSION.toString()) { project.version } manifestPlugin.add('Built-Status') { project.status } // Could be promoted, so this is the actual status necessarily manifestPlugin.add('Built-By', System.getProperty('user.name')) diff --git a/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy b/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy index c7478d6..fd8189d 100644 --- a/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy +++ b/src/test/groovy/nebula/plugin/info/reporting/InfoJarManifestPluginLauncherSpec.groovy @@ -102,6 +102,58 @@ class InfoJarManifestPluginLauncherSpec extends IntegrationSpec { assertMainfestKeyExists(attributes, 'Gradle-Version') } + def "changes to group and version are reflected"() { + given: + writeHelloWorld('nebula.test') + buildFile << """ + ${applyPlugin(InfoBrokerPlugin)} + ${applyPlugin(BasicInfoPlugin)} + ${applyPlugin(InfoJarManifestPlugin)} + + apply plugin: 'java' + + group = 'com.netflix' + version = '1.0' + """.stripIndent() + + when: + runTasksSuccessfully('jar') + + then: + File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") + jarFile.exists() + Manifest manifest = new JarFile(jarFile).manifest + Attributes attributes = manifest.mainAttributes + attributes.getValue('Implementation-Title') == "com.netflix#changes-to-group-and-version-are-reflected;1.0" + } + + def "changes to group and version after project evaluation are reflected"() { + given: + writeHelloWorld('nebula.test') + buildFile << """ + ${applyPlugin(InfoBrokerPlugin)} + ${applyPlugin(BasicInfoPlugin)} + ${applyPlugin(InfoJarManifestPlugin)} + + apply plugin: 'java' + + afterEvaluate { + group = 'com.netflix' + version = '1.0' + } + """.stripIndent() + + when: + runTasksSuccessfully('jar') + + then: + File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar") + jarFile.exists() + Manifest manifest = new JarFile(jarFile).manifest + Attributes attributes = manifest.mainAttributes + attributes.getValue('Implementation-Title') == "com.netflix#changes-to-group-and-version-are-reflected;1.0" + } + private void assertMainfestKeyExists(Attributes attributes, String key) { assert attributes.containsKey(new Attributes.Name(key)) }