Skip to content

Commit

Permalink
[bug] closes #92 - do not include null in manifest's Class-Pat
Browse files Browse the repository at this point in the history
  • Loading branch information
johnrengelman committed Aug 26, 2014
1 parent 04df838 commit fcffc23
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v1.1.1
======

+ Fix bug in `'createStartScripts'` task that was causing it to not execute `'shadowJar'` task ([Issue #90](https://github.com/johnrengelman/shadow/issues/90))
+ Do not include `null` in ShadowJar Manifest `'Class-Path'` value when `jar` task does not specify a value for it. ([Issue #92](https://github.com/johnrengelman/shadow/issues/92)

v1.1.0
======
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class ShadowJavaPlugin implements Plugin<Project> {
shadow.doFirst {
def files = project.configurations.findByName(ShadowBasePlugin.CONFIGURATION_NAME).files
if (files) {
def value = project.tasks.jar.manifest.attributes.get('Class-Path')
manifest.attributes 'Class-Path': [value, files.collect { "lib/${it.name}" }.join(' ')].join(' ')
def libs = [project.tasks.jar.manifest.attributes.get('Class-Path')]
libs.addAll files.collect { "lib/${it.name}" }
manifest.attributes 'Class-Path': libs.findAll { it }.join(' ')
}
}
shadow.from(convention.sourceSets.main.output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,37 @@ class ShadowPluginSpec extends PluginSpecification {
assert classpath == 'a.jar lib/junit-3.8.2.jar'

}

@Issue('SHADOW-92')
def "do not include null value in Class-Path when jar file does not contain Class-Path"() {
given:

buildFile << """
|apply plugin: 'java'
|apply plugin: 'com.github.johnrengelman.shadow'
|
|repositories { maven { url "${repo.uri}" } }
|dependencies { shadow 'junit:junit:3.8.2' }
|
|shadowJar {
| baseName = 'shadow'
| classifier = null
|}
""".stripMargin()

when:
runner.arguments << 'shadowJar'
ExecutionResult result = runner.run()

then:
success(result)
assert output.exists()

and:
JarFile jar = new JarFile(output)
Attributes attributes = jar.manifest.getMainAttributes()
String classpath = attributes.getValue('Class-Path')
assert classpath == 'lib/junit-3.8.2.jar'

}
}

0 comments on commit fcffc23

Please sign in to comment.