Skip to content

Commit

Permalink
signJarRemovedManifestEntries is now a regex and is applied to all at…
Browse files Browse the repository at this point in the history
…tributes

not only the mainAttributes, but also the attributes per package. This is mainly
to really unsign jars. When using pack200 some jars caused problems.
  • Loading branch information
tschulte committed Mar 3, 2015
1 parent 35bf623 commit 5b36d21
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GradleJnlpPluginExtension {
Map<String, String> signJarParams = [:]
Map<String, String> signJarAddedManifestEntries
String signJarFilteredMetaInfFiles = '(?:SIG-.*|.*[.](?:DSA|SF|RSA)|INDEX.LIST)'
List<String> signJarRemovedManifestEntries = ['Trusted-Only', 'Trusted-Library']
String signJarRemovedManifestEntries = '(?:Trusted-Only|Trusted-Library|.*-Digest)'

Closure withXmlClosure
Closure desc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SignJarsTask extends AbstractCopyJarsTask {
if (project.jnlp.usePack200) {
project.exec {
commandLine "pack200", "--repack", jarToSign
}.assertNormalExitValue()
}
}

// AntBuilder is not thread-safe, therefore we need to create
Expand All @@ -57,7 +57,7 @@ class SignJarsTask extends AbstractCopyJarsTask {
if (project.jnlp.usePack200) {
project.exec {
commandLine "pack200", "${jarToSign}.pack.gz", jarToSign
}.assertNormalExitValue()
}
project.delete(jarToSign)
}
}
Expand All @@ -71,9 +71,12 @@ class SignJarsTask extends AbstractCopyJarsTask {
// ensure either Manifest-Version or Signature-Version is set, otherwise the manifest will not be written
if (!manifest.mainAttributes.getValue('Manifest-Version') && !manifest.mainAttributes.getValue('Signature-Version'))
manifest.mainAttributes.putValue('Manifest-Version', '1.0')
project.jnlp.signJarRemovedManifestEntries.each { key ->
manifest.mainAttributes.remove(new Attributes.Name(key))
def removeManifestEntries = { attributes ->
def keysToRemove = attributes.keySet().findAll { key -> key.toString() ==~ "(?i)${project.jnlp.signJarRemovedManifestEntries}" }
attributes.keySet().removeAll(keysToRemove)
}
removeManifestEntries(manifest.mainAttributes)
manifest.entries.values().each(removeManifestEntries)
project.jnlp.signJarAddedManifestEntries.each { key, value ->
manifest.mainAttributes.putValue(key, value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class JnlpWithPack200IntegrationSpecification extends AbstractPluginSpecificatio
repositories {
jcenter()
}
dependencies {
// jxlayer is already signed. This caused problems with usePack200
compile 'org.swinglabs:jxlayer:3.0.4'
}
mainClassName = 'de.gliderpilot.jnlp.test.Main'
task genkey << {
ant.genkey(alias: 'myalias', storepass: 'mystorepass', dname: 'CN=Ant Group, OU=Jakarta Division, O=Apache.org, C=US',
Expand Down Expand Up @@ -100,6 +104,6 @@ class JnlpWithPack200IntegrationSpecification extends AbstractPluginSpecificatio

def 'jar file is packed with pack200'() {
expect:
new File(project.buildDir, "jnlp/lib").list() == ['test__V1.0.jar.pack.gz']
new File(project.buildDir, "jnlp/lib").list().sort() == ['jxlayer__V3.0.4.jar.pack.gz', 'test__V1.0.jar.pack.gz']
}
}

0 comments on commit 5b36d21

Please sign in to comment.