Skip to content

Commit

Permalink
Mark implementation title as changing so changes to project group and…
Browse files Browse the repository at this point in the history
… verison are reflected. Fixed #41
  • Loading branch information
DanielThomas committed Apr 4, 2018
1 parent 3114eeb commit 2701c2b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BasicInfoPlugin implements Plugin<Project>, 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'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 2701c2b

Please sign in to comment.