This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git
commit c6cac83e8d915c1bbc4a40481b143644c69da2ee Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 22:29:25 2026 +0000 Format Groovy IT scripts Formatting only: the CONVERSION-phase AST of every file is unchanged. See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/MEAR-198/verify.groovy | 2 +- src/it/MEAR-243-skinny-wars-provided/verify.groovy | 132 ++++++++---------- src/it/MEAR-278-same-artifact-twice/verify.groovy | 16 +-- src/it/basic/verify.groovy | 45 +++---- src/it/descriptor-encoding/verify.groovy | 16 +-- src/it/filenamemapping-usage-fail/verify.groovy | 4 +- src/it/non-skinny-wars/verify.groovy | 52 +++----- src/it/packaging-excludes/verify.groovy | 41 +++--- src/it/packaging-includes/verify.groovy | 42 +++--- src/it/resource-custom-directory/verify.groovy | 27 ++-- src/it/same-artifactId/verify.groovy | 41 +++--- .../skinny-wars-filenamemapping-full/verify.groovy | 69 ++++------ .../verify.groovy | 69 ++++------ src/it/skinny-wars-timestamp/verify.groovy | 148 ++++++++++----------- src/it/skinny-wars/verify.groovy | 87 +++++------- src/it/transitive-excludes/verify.groovy | 22 ++- 16 files changed, 336 insertions(+), 477 deletions(-) diff --git a/src/it/MEAR-198/verify.groovy b/src/it/MEAR-198/verify.groovy index eab47aa..4642db2 100644 --- a/src/it/MEAR-198/verify.groovy +++ b/src/it/MEAR-198/verify.groovy @@ -18,7 +18,7 @@ * under the License. */ -File target = new File( basedir, "target" ) +File target = new File(basedir, "target") assert target.exists() && target.isDirectory() : "target file is missing or not a directory." File artifact = new File( target, "maven-ear-plugin-test-mear-198-1.0-SNAPSHOT.ear" ) diff --git a/src/it/MEAR-243-skinny-wars-provided/verify.groovy b/src/it/MEAR-243-skinny-wars-provided/verify.groovy index 0bea897..f3cb208 100644 --- a/src/it/MEAR-243-skinny-wars-provided/verify.groovy +++ b/src/it/MEAR-243-skinny-wars-provided/verify.groovy @@ -17,114 +17,86 @@ * under the License. */ -import java.util.jar.*; - -void assertJar( String fileName, String[] includedEntries, String[] excludedEntries, boolean assertManifest, - String[] expectedClassPathElements ) -{ - File jarFile = new File( basedir, fileName ); - System.out.println( "Checking for existence of " + jarFile ); - if ( !jarFile.isFile() ) - { - throw new IllegalStateException( "Missing file: " + jarFile ); +import java.util.jar.* + +void assertJar(String fileName, String[] includedEntries, String[] excludedEntries, boolean assertManifest, + String[] expectedClassPathElements) { + File jarFile = new File(basedir, fileName) + System.out.println("Checking for existence of " + jarFile) + if (!jarFile.isFile()) { + throw new IllegalStateException("Missing file: " + jarFile) } - JarFile jar = new JarFile( jarFile ); + JarFile jar = new JarFile(jarFile) - if ( includedEntries != null ) - { - for ( String included : includedEntries ) - { - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included + ". Artifact: " + fileName ); + if (includedEntries != null) { + for (String included : includedEntries) { + System.out.println("Checking for included archive entry " + included) + if (jar.getEntry(included) == null) { + throw new IllegalStateException("Missing archive entry: " + included + ". Artifact: " + fileName) } } } - if ( excludedEntries != null ) - { - for ( String excluded : excludedEntries ) - { - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded - + ". Artifact: " + fileName ); + if (excludedEntries != null) { + for (String excluded : excludedEntries) { + System.out.println("Checking for excluded artifact " + excluded) + if (jar.getEntry(excluded) != null) { + throw new IllegalStateException("Archive entry should be excluded: " + excluded + + ". Artifact: " + fileName) } } } - if ( assertManifest ) - { - Manifest manifest = jar.getManifest(); - String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path"); - if ( expectedClassPathElements == null) - { - if ( manifestClassPath != null ) - { - throw new IllegalStateException( "Superfluous Class-Path entry in MANIFEST.MF of artifact: " - + fileName ); + if (assertManifest) { + Manifest manifest = jar.getManifest() + String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path") + if (expectedClassPathElements == null) { + if (manifestClassPath != null) { + throw new IllegalStateException("Superfluous Class-Path entry in MANIFEST.MF of artifact: " + + fileName) } } - else - { - if ( manifestClassPath == null ) - { - throw new IllegalStateException( "Missing Class-Path entry in MANIFEST.MF of artifact: " - + fileName ); + else { + if (manifestClassPath == null) { + throw new IllegalStateException("Missing Class-Path entry in MANIFEST.MF of artifact: " + + fileName) } - manifestClassPath = manifestClassPath.trim(); + manifestClassPath = manifestClassPath.trim() String[] actualClassPathElements = manifestClassPath.length() == 0 ? - new String[0] : manifestClassPath.split( " " ); - if ( !Arrays.equals( expectedClassPathElements, actualClassPathElements ) ) - { - throw new IllegalStateException( "Invalid Class-Path entry in MANIFEST.MF of artifact: " - + fileName - + ". Expected: " + Arrays.toString( expectedClassPathElements ) - + ". Actual: " + Arrays.toString( actualClassPathElements ) ); + new String[0] : manifestClassPath.split(" ") + if (!Arrays.equals(expectedClassPathElements, actualClassPathElements)) { + throw new IllegalStateException("Invalid Class-Path entry in MANIFEST.MF of artifact: " + + fileName + + ". Expected: " + Arrays.toString(expectedClassPathElements) + + ". Actual: " + Arrays.toString(actualClassPathElements)) } } } } -String[] includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar" -]; +String[] includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/commons-lang-2.6.jar"] -assertJar( "war-module-one/target/war-module-one-1.0.war", includedEntries, null, false, null ); +assertJar("war-module-one/target/war-module-one-1.0.war", includedEntries, null, false, null) -String[] expectedClassPathElements = [ - "commons-lang-2.6.jar" -]; +String[] expectedClassPathElements = ["commons-lang-2.6.jar"] -assertJar( "war-module-two/target/war-module-two-1.0.war", includedEntries, null, true, expectedClassPathElements ); +assertJar("war-module-two/target/war-module-two-1.0.war", includedEntries, null, true, expectedClassPathElements) -includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF" -]; +includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF"] -String[] excludedEntries = [ - "WEB-INF/lib/commons-lang-2.6.jar" -]; +String[] excludedEntries = ["WEB-INF/lib/commons-lang-2.6.jar"] -expectedClassPathElements = []; +expectedClassPathElements = [] -assertJar( "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-one-1.0.war", - includedEntries, excludedEntries, true, expectedClassPathElements ); +assertJar("ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-one-1.0.war", + includedEntries, excludedEntries, true, expectedClassPathElements) -assertJar( "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-two-1.0.war", - includedEntries, excludedEntries, true, expectedClassPathElements ); +assertJar("ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-two-1.0.war", + includedEntries, excludedEntries, true, expectedClassPathElements) -excludedEntries = [ - "commons-lang-2.6.jar", - "lib/commons-lang-2.6.jar" -]; +excludedEntries = ["commons-lang-2.6.jar", "lib/commons-lang-2.6.jar"] -assertJar( "ear-module/target/ear-module-1.0.ear", null, excludedEntries, false, null ); +assertJar("ear-module/target/ear-module-1.0.ear", null, excludedEntries, false, null) -return true; +return true diff --git a/src/it/MEAR-278-same-artifact-twice/verify.groovy b/src/it/MEAR-278-same-artifact-twice/verify.groovy index 1707947..3396bd0 100644 --- a/src/it/MEAR-278-same-artifact-twice/verify.groovy +++ b/src/it/MEAR-278-same-artifact-twice/verify.groovy @@ -19,21 +19,19 @@ import java.util.jar.JarFile -File jarFile = new File( basedir, "target/test-ear-0.0.1-SNAPSHOT.ear" ) +File jarFile = new File(basedir, "target/test-ear-0.0.1-SNAPSHOT.ear") -JarFile jar = new JarFile( jarFile ) +JarFile jar = new JarFile(jarFile) -def shouldNotBeIncludedEntries = [ "log4j-log4j-1.2.8.jar" ] +def shouldNotBeIncludedEntries = ["log4j-log4j-1.2.8.jar"] println shouldNotBeIncludedEntries -for ( String entry : shouldNotBeIncludedEntries ) -{ - print( "Checking for existence of " + entry ) +for (String entry : shouldNotBeIncludedEntries) { + print("Checking for existence of " + entry) - if ( jar.getEntry( entry ) == null ) - { - return true + if (jar.getEntry(entry) == null) { + return true } } diff --git a/src/it/basic/verify.groovy b/src/it/basic/verify.groovy index c4d445d..d13c098 100644 --- a/src/it/basic/verify.groovy +++ b/src/it/basic/verify.groovy @@ -17,42 +17,35 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "target/test-1.0.ear" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "target/test-1.0.ear") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "META-INF/application.xml", - "META-INF/appserver-application.xml" -]; +String[] includedEntries = ["META-INF/application.xml", "META-INF/appserver-application.xml"] -// Reproducible Builds: check that every entry has the same timestamp -long entryTime = -1; +// Reproducible Builds: check that every entry has the same timestamp +long entryTime = -1 -for ( String included : includedEntries ) -{ - System.out.println( "Checking for existence of " + included ); - JarEntry jarEntry = jar.getEntry( included ); - if ( jarEntry == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +for ( String included : includedEntries ) { + System.out.println( "Checking for existence of " + included ) + JarEntry jarEntry = jar.getEntry( included ) + if ( jarEntry == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } - if ( entryTime < 0 ) - { - entryTime = jarEntry.getTime(); + if ( entryTime < 0 ) { + entryTime = jarEntry.getTime() } - if ( entryTime != jarEntry.getTime() ) - { + if ( entryTime != jarEntry.getTime() ) { throw new IllegalStateException( "Invalid jar entry time: " + jarEntry.getTime() - + " of archive entry: " + included - + ", expected: " + entryTime ); + + " of archive entry: " + included + + ", expected: " + entryTime ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/descriptor-encoding/verify.groovy b/src/it/descriptor-encoding/verify.groovy index 4a2fc3e..9c21a94 100644 --- a/src/it/descriptor-encoding/verify.groovy +++ b/src/it/descriptor-encoding/verify.groovy @@ -18,16 +18,16 @@ */ import groovy.xml.XmlParser -def latin1File = new File( basedir, "latin-1/target/application.xml" ) +def latin1File = new File(basedir, "latin-1/target/application.xml") assert latin1File.exists() -println "latin-1/target/application.xml: " + latin1File.getText( 'ISO-8859-1' ) -def latin1Chars = new XmlParser().parse( latin1File ).description.text() +println "latin-1/target/application.xml: " + latin1File.getText('ISO-8859-1') +def latin1Chars = new XmlParser().parse(latin1File).description.text() println "Latin-1: " + latin1Chars -assert "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF".equals( latin1Chars ) +assert "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF".equals(latin1Chars) -def utf8File = new File( basedir, "utf-8/target/application.xml" ) +def utf8File = new File(basedir, "utf-8/target/application.xml") assert utf8File.exists() -println "utf-8/target/application.xml: " + utf8File.getText( 'UTF-8' ) -def utf8Chars = new XmlParser().parse( utf8File ).description.text() +println "utf-8/target/application.xml: " + utf8File.getText('UTF-8') +def utf8Chars = new XmlParser().parse(utf8File).description.text() println "UTF-8: " + utf8Chars -assert "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF".equals( utf8Chars ) +assert "TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF".equals(utf8Chars) diff --git a/src/it/filenamemapping-usage-fail/verify.groovy b/src/it/filenamemapping-usage-fail/verify.groovy index 1e1208a..b50150f 100644 --- a/src/it/filenamemapping-usage-fail/verify.groovy +++ b/src/it/filenamemapping-usage-fail/verify.groovy @@ -17,6 +17,6 @@ * under the License. */ -def buildLog = new File( basedir, "build.log" ).getText('UTF-8') -assert buildLog.contains( '[ERROR] fileNameMapping has been removed with version 3.0.0. You are still using it.' ) : "missing output about fileNameMapping removement." +def buildLog = new File(basedir, "build.log").getText('UTF-8') +assert buildLog.contains('[ERROR] fileNameMapping has been removed with version 3.0.0. You are still using it.') : "missing output about fileNameMapping removement." assert buildLog.contains( '[ERROR] Use outputFileNameMapping instead.' ) : "missing information about usage today." diff --git a/src/it/non-skinny-wars/verify.groovy b/src/it/non-skinny-wars/verify.groovy index 455f5d3..266b725 100644 --- a/src/it/non-skinny-wars/verify.groovy +++ b/src/it/non-skinny-wars/verify.groovy @@ -17,51 +17,39 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.nonskinnywars-war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.nonskinnywars-war-module-1.0.war") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +String[] includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/commons-lang-2.6.jar"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -jar.close(); +jar.close() -jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ) +System.out.println( "Checking for existence of " + jarFile ) assert jarFile.isFile() : "Missing file: " + jarFile -jar = new JarFile( jarFile ); +jar = new JarFile( jarFile ) -includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/commons-lang-2.6.jar"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/packaging-excludes/verify.groovy b/src/it/packaging-excludes/verify.groovy index ba3405f..0fdc5ef 100644 --- a/src/it/packaging-excludes/verify.groovy +++ b/src/it/packaging-excludes/verify.groovy @@ -17,39 +17,30 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "target/test-1.0.ear" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "target/test-1.0.ear") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "META-INF/application.xml", - "META-INF/MANIFEST.MF" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +String[] includedEntries = ["META-INF/application.xml", "META-INF/MANIFEST.MF"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -String[] excludedEntries = [ - "commons-lang-2.6.jar" -]; -for ( String excluded : excludedEntries ) -{ - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded ); +String[] excludedEntries = ["commons-lang-2.6.jar"] +for ( String excluded : excludedEntries ) { + System.out.println( "Checking for excluded artifact " + excluded ) + if ( jar.getEntry( excluded ) != null ) { + throw new IllegalStateException( "Archive entry should be excluded: " + excluded ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/packaging-includes/verify.groovy b/src/it/packaging-includes/verify.groovy index 653e8f1..6b403e7 100644 --- a/src/it/packaging-includes/verify.groovy +++ b/src/it/packaging-includes/verify.groovy @@ -17,40 +17,30 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "target/test-1.0.ear" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "target/test-1.0.ear") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "commons-lang-commons-lang-2.6.jar", - "META-INF/application.xml", - "META-INF/MANIFEST.MF" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +String[] includedEntries = ["commons-lang-commons-lang-2.6.jar", "META-INF/application.xml", "META-INF/MANIFEST.MF"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -String[] excludedEntries = [ - "commons-io-2.11.0.jar" -]; -for ( String excluded : excludedEntries ) -{ - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded ); +String[] excludedEntries = ["commons-io-2.11.0.jar"] +for ( String excluded : excludedEntries ) { + System.out.println( "Checking for excluded artifact " + excluded ) + if ( jar.getEntry( excluded ) != null ) { + throw new IllegalStateException( "Archive entry should be excluded: " + excluded ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/resource-custom-directory/verify.groovy b/src/it/resource-custom-directory/verify.groovy index fd1f376..ed8d938 100644 --- a/src/it/resource-custom-directory/verify.groovy +++ b/src/it/resource-custom-directory/verify.groovy @@ -17,27 +17,22 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "target/test-1.0.ear" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "target/test-1.0.ear") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "META-INF/application.xml", - "APP-INF/classes/foo.properties" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for existence of " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +String[] includedEntries = ["META-INF/application.xml", "APP-INF/classes/foo.properties"] +for ( String included : includedEntries ) { + System.out.println( "Checking for existence of " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/same-artifactId/verify.groovy b/src/it/same-artifactId/verify.groovy index 9683344..f7e2899 100644 --- a/src/it/same-artifactId/verify.groovy +++ b/src/it/same-artifactId/verify.groovy @@ -16,26 +16,21 @@ * specific language governing permissions and limitations * under the License. */ - - def service1 = new File( basedir, "app/target/app-1.0-SNAPSHOT/service1.jar" ).toURL().toString(); - assert new URL( "jar:${service1}!/com/example/A.class" ).content != null - try - { - new URL( "jar:${service1}!/com/example/B.class" ).content - assert false : "service1.jar should not contain com.example.B.class" - } - catch( FileNotFoundException e) - { - } - - def service2 = new File( basedir, "app/target/app-1.0-SNAPSHOT/service2.jar" ).toURL().toString(); - assert new URL( "jar:${service2}!/com/example/B.class").content != null - try - { - new URL( "jar:${service2}!/com/example/A.class").content - assert false : "service2.jar should not contain com.example.A.class" - } - catch( FileNotFoundException e) - { - } - \ No newline at end of file + +def service1 = new File(basedir, "app/target/app-1.0-SNAPSHOT/service1.jar").toURL().toString() +assert new URL("jar:${service1}!/com/example/A.class").content != null +try { + new URL("jar:${service1}!/com/example/B.class").content + assert false : "service1.jar should not contain com.example.B.class" +} +catch(FileNotFoundException e) { +} + +def service2 = new File(basedir, "app/target/app-1.0-SNAPSHOT/service2.jar").toURL().toString() +assert new URL("jar:${service2}!/com/example/B.class").content != null +try { + new URL("jar:${service2}!/com/example/A.class").content + assert false : "service2.jar should not contain com.example.A.class" +} +catch(FileNotFoundException e) { +} diff --git a/src/it/skinny-wars-filenamemapping-full/verify.groovy b/src/it/skinny-wars-filenamemapping-full/verify.groovy index 29abb70..4f37449 100644 --- a/src/it/skinny-wars-filenamemapping-full/verify.groovy +++ b/src/it/skinny-wars-filenamemapping-full/verify.groovy @@ -17,66 +17,51 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-1.0.war") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +String[] includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -Manifest manifest = jar.getManifest(); -String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path"); +Manifest manifest = jar.getManifest() +String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path") assert manifestClassPath.equals("lib/commons-lang-commons-lang-2.6.jar") : "Missing entry in war MANIFEST.MF: lib/commons-lang-commons-lang-2.6.jar" -String[] excludedEntries = [ - "WEB-INF/lib/commons-lang-commons-lang-2.6.jar" -]; -for ( String excluded : excludedEntries ) -{ - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded ); +String[] excludedEntries = ["WEB-INF/lib/commons-lang-commons-lang-2.6.jar"] +for ( String excluded : excludedEntries ) { + System.out.println( "Checking for excluded artifact " + excluded ) + if ( jar.getEntry( excluded ) != null ) { + throw new IllegalStateException( "Archive entry should be excluded: " + excluded ) } } -jar.close(); +jar.close() -jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ) +System.out.println( "Checking for existence of " + jarFile ) assert jarFile.isFile() : "Missing file: " + jarFile -jar = new JarFile( jarFile ); +jar = new JarFile( jarFile ) -includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/commons-lang-2.6.jar"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/skinny-wars-filenamemapping-no-version/verify.groovy b/src/it/skinny-wars-filenamemapping-no-version/verify.groovy index fea70d2..268bdae 100644 --- a/src/it/skinny-wars-filenamemapping-no-version/verify.groovy +++ b/src/it/skinny-wars-filenamemapping-no-version/verify.groovy @@ -17,66 +17,51 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "ear-module/target/ear-module-1.0/war-module.war" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "ear-module/target/ear-module-1.0/war-module.war") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +String[] includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -Manifest manifest = jar.getManifest(); -String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path"); +Manifest manifest = jar.getManifest() +String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path") assert manifestClassPath.equals("lib/commons-lang.jar") : "Missing entry in war MANIFEST.MF: lib/commons-lang.jar" -String[] excludedEntries = [ - "WEB-INF/lib/commons-lang-2.6.jar" -]; -for ( String excluded : excludedEntries ) -{ - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded ); +String[] excludedEntries = ["WEB-INF/lib/commons-lang-2.6.jar"] +for ( String excluded : excludedEntries ) { + System.out.println( "Checking for excluded artifact " + excluded ) + if ( jar.getEntry( excluded ) != null ) { + throw new IllegalStateException( "Archive entry should be excluded: " + excluded ) } } -jar.close(); +jar.close() -jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ) +System.out.println( "Checking for existence of " + jarFile ) assert jarFile.isFile() : "Missing file: " + jarFile -jar = new JarFile( jarFile ); +jar = new JarFile( jarFile ) -includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/commons-lang-2.6.jar"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/skinny-wars-timestamp/verify.groovy b/src/it/skinny-wars-timestamp/verify.groovy index 1292acf..07d27d3 100644 --- a/src/it/skinny-wars-timestamp/verify.groovy +++ b/src/it/skinny-wars-timestamp/verify.groovy @@ -17,109 +17,95 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -void assertFileExists( File file ) -{ - System.out.println( "Checking for existence of " + file ); - if ( !file.isFile() ) - { - throw new IllegalStateException( "Missing file: " + file ); +void assertFileExists(File file) { + System.out.println("Checking for existence of " + file) + if (!file.isFile()) { + throw new IllegalStateException("Missing file: " + file) } } -void assertIncludes( File file, String[] includedEntries ) -{ - JarFile jar = new JarFile( file ); - try - { - for ( String included : includedEntries ) - { - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +void assertIncludes(File file, String[] includedEntries) { + JarFile jar = new JarFile(file) + try { + for (String included : includedEntries) { + System.out.println("Checking for included archive entry " + included) + if (jar.getEntry(included) == null) { + throw new IllegalStateException("Missing archive entry: " + included) } } } - finally - { - jar.close(); + finally { + jar.close() } } -void assertExcludes( File file, String[] excludedEntries ) -{ - JarFile jar = new JarFile( file ); - try - { - for ( String excluded : excludedEntries ) - { - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded ); +void assertExcludes(File file, String[] excludedEntries) { + JarFile jar = new JarFile(file) + try { + for (String excluded : excludedEntries) { + System.out.println("Checking for excluded artifact " + excluded) + if (jar.getEntry(excluded) != null) { + throw new IllegalStateException("Archive entry should be excluded: " + excluded) } } } - finally - { - jar.close(); + finally { + jar.close() } } -void assertManifestClassPath( File file, String classPath ) -{ - JarFile jar = new JarFile( file ); - try - { - Manifest manifest = jar.getManifest(); - String manifestClassPath = manifest.getMainAttributes().getValue( "Class-Path" ); - System.out.println( "manifestClassPath: " + manifestClassPath ); - if ( !( classPath == null && manifestClassPath == null - || manifestClassPath != null && manifestClassPath.equals( classPath ) ) ) - { - throw new IllegalStateException( "Missing entry in war MANIFEST.MF: " + classPath ); +void assertManifestClassPath(File file, String classPath) { + JarFile jar = new JarFile(file) + try { + Manifest manifest = jar.getManifest() + String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path") + System.out.println("manifestClassPath: " + manifestClassPath) + if (!(classPath == null && manifestClassPath == null + || manifestClassPath != null && manifestClassPath.equals(classPath))) { + throw new IllegalStateException("Missing entry in war MANIFEST.MF: " + classPath) } } - finally - { - jar.close(); + finally { + jar.close() } } -File warOneFile = new File( basedir, "war-module-one/target/war-module-one-1.0.war" ); -assertFileExists( warOneFile ); -assertIncludes( warOneFile, [ "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar", - "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" ] as String[] ); -assertManifestClassPath( warOneFile, "commons-lang-2.6.jar jar-sample-one-1.0-20150825.210557-91.jar" ); +File warOneFile = new File(basedir, "war-module-one/target/war-module-one-1.0.war") +assertFileExists(warOneFile) +assertIncludes(warOneFile, [ + "WEB-INF/web.xml", + "META-INF/MANIFEST.MF", + "WEB-INF/lib/commons-lang-2.6.jar", + "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" +] as String[]) +assertManifestClassPath(warOneFile, "commons-lang-2.6.jar jar-sample-one-1.0-20150825.210557-91.jar") -File warTwoFile = new File( basedir, "war-module-two/target/war-module-two-1.0.war" ); -assertFileExists( warTwoFile ); -assertIncludes( warTwoFile, [ "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar" ] as String[] ); -assertExcludes( warTwoFile, [ "WEB-INF/lib/commons-lang-2.6.jar" ] as String[] ); -assertManifestClassPath( warTwoFile, "jar-sample-one-1.0-SNAPSHOT.jar" ); +File warTwoFile = new File(basedir, "war-module-two/target/war-module-two-1.0.war") +assertFileExists(warTwoFile) +assertIncludes(warTwoFile, ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar"] as String[]) +assertExcludes(warTwoFile, ["WEB-INF/lib/commons-lang-2.6.jar"] as String[]) +assertManifestClassPath(warTwoFile, "jar-sample-one-1.0-SNAPSHOT.jar") -File warModuleOneFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-one-1.0.war" ); -assertFileExists( warModuleOneFile ); -assertIncludes( warModuleOneFile, [ "WEB-INF/web.xml", - "META-INF/MANIFEST.MF" ] as String[] ); -assertExcludes( warModuleOneFile, [ "WEB-INF/lib/commons-lang-2.6.jar", - "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar", - "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" ] as String[] ); -assertManifestClassPath( warModuleOneFile, "commons-lang-commons-lang-2.6.jar eartest-jar-sample-one-1.0-20150825.210557-91.jar" ); +File warModuleOneFile = new File(basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-one-1.0.war") +assertFileExists(warModuleOneFile) +assertIncludes(warModuleOneFile, ["WEB-INF/web.xml", "META-INF/MANIFEST.MF"] as String[]) +assertExcludes(warModuleOneFile, [ + "WEB-INF/lib/commons-lang-2.6.jar", + "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar", + "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" +] as String[]) +assertManifestClassPath(warModuleOneFile, "commons-lang-commons-lang-2.6.jar eartest-jar-sample-one-1.0-20150825.210557-91.jar") -File warModuleTwoFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-two-1.0.war" ); -assertFileExists( warModuleTwoFile ); -assertIncludes( warModuleTwoFile, [ "WEB-INF/web.xml", - "META-INF/MANIFEST.MF" ] as String[] ); -assertExcludes( warModuleTwoFile, [ "WEB-INF/lib/commons-lang-2.6.jar", - "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar", - "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" ] as String[] ); -assertManifestClassPath( warModuleTwoFile, "eartest-jar-sample-one-1.0-20150825.210557-91.jar commons-lang-commons-lang-2.6.jar" ); +File warModuleTwoFile = new File(basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-two-1.0.war") +assertFileExists(warModuleTwoFile) +assertIncludes(warModuleTwoFile, ["WEB-INF/web.xml", "META-INF/MANIFEST.MF"] as String[]) +assertExcludes(warModuleTwoFile, [ + "WEB-INF/lib/commons-lang-2.6.jar", + "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar", + "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" +] as String[]) +assertManifestClassPath(warModuleTwoFile, "eartest-jar-sample-one-1.0-20150825.210557-91.jar commons-lang-commons-lang-2.6.jar") -return true; +return true diff --git a/src/it/skinny-wars/verify.groovy b/src/it/skinny-wars/verify.groovy index da7ebcd..d2af279 100644 --- a/src/it/skinny-wars/verify.groovy +++ b/src/it/skinny-wars/verify.groovy @@ -17,81 +17,64 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File jarFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +File jarFile = new File(basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-1.0.war") +System.out.println("Checking for existence of " + jarFile) assert jarFile.isFile() : "Missing file: " + jarFile -JarFile jar = new JarFile( jarFile ); +JarFile jar = new JarFile( jarFile ) -String[] includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF" -]; +String[] includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF"] -// Reproducible Builds: check that every entry has the same timestamp -long entryTime = -1; +// Reproducible Builds: check that every entry has the same timestamp +long entryTime = -1 -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - JarEntry jarEntry = jar.getEntry( included ); - if ( jarEntry == null ) - { - throw new IllegalStateException( "Missing WAR entry: " + included ); +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + JarEntry jarEntry = jar.getEntry( included ) + if ( jarEntry == null ) { + throw new IllegalStateException( "Missing WAR entry: " + included ) } - if ( entryTime < 0 ) - { - entryTime = jarEntry.getTime(); + if ( entryTime < 0 ) { + entryTime = jarEntry.getTime() } - if ( entryTime != jarEntry.getTime() ) - { + if ( entryTime != jarEntry.getTime() ) { throw new IllegalStateException( "Invalid jar entry time: " + jarEntry.getTime() - + " of archive entry: " + included - + ", expected: " + entryTime ); + + " of archive entry: " + included + + ", expected: " + entryTime ) } } -Manifest manifest = jar.getManifest(); -String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path"); +Manifest manifest = jar.getManifest() +String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path") assert manifestClassPath.equals("commons-lang-commons-lang-2.6.jar") : "Missing entry in war MANIFEST.MF: commons-lang-commons-lang-2.6.jar" -String[] excludedEntries = [ - "WEB-INF/lib/commons-lang-commons-lang-2.6.jar" -]; -for ( String excluded : excludedEntries ) -{ - System.out.println( "Checking for excluded artifact " + excluded ); - if ( jar.getEntry( excluded ) != null ) - { - throw new IllegalStateException( "Archive entry should be excluded: " + excluded ); +String[] excludedEntries = ["WEB-INF/lib/commons-lang-commons-lang-2.6.jar"] +for ( String excluded : excludedEntries ) { + System.out.println( "Checking for excluded artifact " + excluded ) + if ( jar.getEntry( excluded ) != null ) { + throw new IllegalStateException( "Archive entry should be excluded: " + excluded ) } } -jar.close(); +jar.close() -jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ); -System.out.println( "Checking for existence of " + jarFile ); +jarFile = new File( basedir, "war-module/target/war-module-1.0.war" ) +System.out.println( "Checking for existence of " + jarFile ) assert jarFile.isFile() : "Missing file: " + jarFile -jar = new JarFile( jarFile ); +jar = new JarFile( jarFile ) -includedEntries = [ - "WEB-INF/web.xml", - "META-INF/MANIFEST.MF", - "WEB-INF/lib/commons-lang-2.6.jar" -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for included archive entry " + included ); - if ( jar.getEntry( included ) == null ) - { - throw new IllegalStateException( "Missing archive entry: " + included ); +includedEntries = ["WEB-INF/web.xml", "META-INF/MANIFEST.MF", "WEB-INF/lib/commons-lang-2.6.jar"] +for ( String included : includedEntries ) { + System.out.println( "Checking for included archive entry " + included ) + if ( jar.getEntry( included ) == null ) { + throw new IllegalStateException( "Missing archive entry: " + included ) } } -jar.close(); +jar.close() -return true; +return true diff --git a/src/it/transitive-excludes/verify.groovy b/src/it/transitive-excludes/verify.groovy index 9f0ca7f..b5379a6 100644 --- a/src/it/transitive-excludes/verify.groovy +++ b/src/it/transitive-excludes/verify.groovy @@ -20,19 +20,17 @@ import java.util.jar.JarEntry import java.util.jar.JarFile -File earFile = new File( basedir, "target/mear73-1.0-SNAPSHOT.ear" ); +File earFile = new File(basedir, "target/mear73-1.0-SNAPSHOT.ear") assert earFile.isFile() : "Missing file: " + earFile -JarFile ear = new JarFile( earFile ); -Enumeration entries = ear.entries(); -while( entries.hasMoreElements() ) -{ - JarEntry entry = (JarEntry) entries.nextElement(); - if( entry.getName().endsWith( ".jar" ) && !"org.apache.maven-maven-core-3.9.9.jar".equals( entry.getName() ) ) - { - throw new IllegalStateException( "Unexpected archive entry: " + entry.getName() ); - } +JarFile ear = new JarFile( earFile ) +Enumeration entries = ear.entries() +while( entries.hasMoreElements() ) { + JarEntry entry = (JarEntry) entries.nextElement() + if( entry.getName().endsWith( ".jar" ) && !"org.apache.maven-maven-core-3.9.9.jar".equals( entry.getName() ) ) { + throw new IllegalStateException( "Unexpected archive entry: " + entry.getName() ) + } } -ear.close(); +ear.close() -return true; +return true
