-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow ignoring duplicate entries in Jar files
Add new member `duplicatesStrategy` to task signJars. This member is unset by default, which is the same behavior as before. Setting the value to `INCLUDE` would result in the same. If the member is set to `EXCLUDE`, duplicate entries in jar files are ignored and a debug message is printed to the log. If it is `WARN`, a warning is printed to the log, but the build will fail nonetheless, because the JarOutputStream will not allow duplicate entries. If it is `FAIL`, the build will fail as well, but gracefully by throwing a DuplicateFileCopyingException. Closes: #37
- Loading branch information
Showing
2 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...nlp-plugin/src/test/groovy/de/gliderpilot/gradle/jnlp/SignJarsDuplicateEntriesSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2015 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.gliderpilot.gradle.jnlp | ||
|
||
import org.gradle.api.file.DuplicatesStrategy | ||
import spock.lang.Issue | ||
|
||
@Issue("https://github.com/tschulte/gradle-jnlp-plugin/issues/37") | ||
class SignJarsDuplicateEntriesSpec extends AbstractJnlpIntegrationSpec { | ||
|
||
def setup() { | ||
writeHelloWorld('de.gliderpilot.jnlp.test') | ||
file('src/main/resources/test') | ||
file('src/test/resources/test') | ||
buildFile << """\ | ||
apply plugin: 'java' | ||
apply plugin: 'application' | ||
jnlp { | ||
usePack200 = false | ||
signJarRemovedNamedManifestEntries = ".*" | ||
} | ||
mainClassName = 'de.gliderpilot.jnlp.test.HelloWorld' | ||
jar { | ||
from sourceSets.test.output | ||
} | ||
""".stripIndent() | ||
enableJarSigner() | ||
} | ||
|
||
def 'cannot sign jar without DuplicatesStrategy'() { | ||
expect: | ||
runTasksWithFailure(':createWebstartDir') | ||
} | ||
|
||
def 'cannot sign jar with DuplicatesStrategy.INCLUDE'() { | ||
given: | ||
duplicatesStrategy = DuplicatesStrategy.INCLUDE | ||
|
||
expect: | ||
runTasksWithFailure(':createWebstartDir') | ||
} | ||
|
||
def 'cannot sign jar with DuplicatesStrategy.FAIL'() { | ||
given: | ||
duplicatesStrategy = DuplicatesStrategy.FAIL | ||
|
||
expect: | ||
runTasksWithFailure(':createWebstartDir') | ||
} | ||
|
||
def 'cannot sign jar with duplicatesStrategy.WARN'() { | ||
given: | ||
duplicatesStrategy = DuplicatesStrategy.WARN | ||
|
||
expect: | ||
runTasksWithFailure(':createWebstartDir') | ||
} | ||
|
||
def 'can sign jar with DuplicatesStrategy.EXCLUDE'() { | ||
given: | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
|
||
expect: | ||
runTasksSuccessfully(':createWebstartDir') | ||
} | ||
|
||
void setDuplicatesStrategy(DuplicatesStrategy duplicatesStrategy) { | ||
buildFile << """\ | ||
tasks.signJars { | ||
duplicatesStrategy = DuplicatesStrategy.${duplicatesStrategy} | ||
} | ||
""".stripIndent() | ||
} | ||
|
||
} |