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-war-plugin.git
commit ea03b3cf7313b35c48ecaf4dc44bf09b7511f0ec Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 22:23:57 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/MWAR-131/verify.groovy | 10 ++-- src/it/MWAR-143/verify.groovy | 69 ++++++++++------------ src/it/MWAR-326/verify.groovy | 4 +- src/it/MWAR-371/verify.groovy | 32 +++++----- src/it/MWAR-427_update-without-clean/verify.groovy | 4 +- src/it/default/verify.groovy | 54 ++++++++--------- src/it/web-resources-filtering/verify.groovy | 20 +++---- 7 files changed, 87 insertions(+), 106 deletions(-) diff --git a/src/it/MWAR-131/verify.groovy b/src/it/MWAR-131/verify.groovy index 659f172..27149a6 100644 --- a/src/it/MWAR-131/verify.groovy +++ b/src/it/MWAR-131/verify.groovy @@ -19,21 +19,21 @@ */ // Make sure the -classes jar from the first webapp is installed into the local repo -File localRepoClassesJar = new File( basedir, - "../../../target/local-repo/com/example/mwar131-webapp/1.0-SNAPSHOT/mwar131-webapp-1.0-SNAPSHOT-classes.jar"); +File localRepoClassesJar = new File(basedir, + "../../../target/local-repo/com/example/mwar131-webapp/1.0-SNAPSHOT/mwar131-webapp-1.0-SNAPSHOT-classes.jar") assert localRepoClassesJar.exists() && !localRepoClassesJar.isDirectory() : "The -classes jar file is missing or is a directory." // Make sure the -classes jar is included in WEB-INF/lib of the second webapp File classesJar = new File( basedir, - "mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/mwar131-webapp-1.0-SNAPSHOT-classes.jar"); + "mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/mwar131-webapp-1.0-SNAPSHOT-classes.jar") assert classesJar.exists() && !classesJar.isDirectory() : "The -classes jar file is missing or is a directory." // Make sure dependencies of the -classes jar are included in WEB-INF/lib of the second webapp File strutsJar = new File( basedir, - "mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/struts-core-1.3.9.jar"); + "mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/struts-core-1.3.9.jar") assert strutsJar.exists() && !strutsJar.isDirectory() : "The Struts 1.3.9 jar file is missing or is a directory." // Make sure transitive dependencies of the -classes jar are included in WEB-INF/lib of the second webapp File digesterJar = new File( basedir, - "mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/commons-digester-1.8.jar"); + "mwar131-webapp2/target/mwar131-webapp2/WEB-INF/lib/commons-digester-1.8.jar") assert digesterJar.exists() && !digesterJar.isDirectory() : "The Commons Digester 1.8 jar file is missing or is a directory." diff --git a/src/it/MWAR-143/verify.groovy b/src/it/MWAR-143/verify.groovy index 0dcb44b..d88fe8c 100644 --- a/src/it/MWAR-143/verify.groovy +++ b/src/it/MWAR-143/verify.groovy @@ -18,67 +18,60 @@ * under the License. */ -import org.codehaus.plexus.util.*; - -boolean filesAreIdentical( File expected, File current ) - throws IOException -{ - if ( expected.length() != current.length() ) - { - return false; +import org.codehaus.plexus.util.* + +boolean filesAreIdentical(File expected, File current) +throws IOException { + if (expected.length() != current.length()) { + return false } - FileInputStream expectedIn = new FileInputStream( expected ); - FileInputStream currentIn = new FileInputStream( current ); - try - { - byte[] expectedBuffer = IOUtil.toByteArray( expectedIn ); - - byte[] currentBuffer = IOUtil.toByteArray( currentIn ); - if ( expectedBuffer.length != currentBuffer.length ) - { - return false; + FileInputStream expectedIn = new FileInputStream(expected) + FileInputStream currentIn = new FileInputStream(current) + try { + byte[] expectedBuffer = IOUtil.toByteArray(expectedIn) + + byte[] currentBuffer = IOUtil.toByteArray(currentIn) + if (expectedBuffer.length != currentBuffer.length) { + return false } - for ( int i = 0,size = expectedBuffer.length; i<size; i++ ) - { - if ( expectedBuffer[i] != currentBuffer[i] ) - { - return false; + for (int i = 0, size = expectedBuffer.length; i<size; i++) { + if (expectedBuffer[i] != currentBuffer[i]) { + return false } } } - finally - { - expectedIn.close(); - currentIn.close(); + finally { + expectedIn.close() + currentIn.close() } - return true; + return true } -File originalImg = new File( basedir, "war-common/src/main/images/duke-beer.jpg" ); +File originalImg = new File(basedir, "war-common/src/main/images/duke-beer.jpg") -File targetImg = new File( basedir, "war-common/target/common-overlay-1.0-SNAPSHOT/duke-beer.jpg" ); +File targetImg = new File(basedir, "war-common/target/common-overlay-1.0-SNAPSHOT/duke-beer.jpg") -boolean identical = filesAreIdentical( originalImg, targetImg ); +boolean identical = filesAreIdentical(originalImg, targetImg) assert identical : "filtered images are not identical in war-common." -File target = new File( basedir, "war-filter-overlay/target" ); +File target = new File( basedir, "war-filter-overlay/target" ) assert target.exists() && target.isDirectory() : "target file is missing or not a directory." -File webappDirectory = new File( target, "custom-manifest-1.0-SNAPSHOT" ); +File webappDirectory = new File( target, "custom-manifest-1.0-SNAPSHOT" ) assert webappDirectory.exists() && webappDirectory.isDirectory() : "webappDirectory is missing or not a directory." -File param = new File( webappDirectory, "WEB-INF/classes/filter.properties" ); +File param = new File( webappDirectory, "WEB-INF/classes/filter.properties" ) assert param.exists() && !param.isDirectory() : "filter.properties file is missing or a directory." -String paramContent = param.getText( 'UTF-8' ); +String paramContent = param.getText( 'UTF-8' ) -int indexOf = paramContent.indexOf( "debug.test = hello world !" ); +int indexOf = paramContent.indexOf( "debug.test = hello world !" ) assert indexOf >= 0 : "filter.properties does not contains debug.test = hello world !" -targetImg = new File( basedir, "war-filter-overlay/target/custom-manifest-1.0-SNAPSHOT/duke-beer.jpg" ); +targetImg = new File( basedir, "war-filter-overlay/target/custom-manifest-1.0-SNAPSHOT/duke-beer.jpg" ) -identical = filesAreIdentical( originalImg, targetImg ); +identical = filesAreIdentical( originalImg, targetImg ) assert identical : "filtered images are not identical with overlay." diff --git a/src/it/MWAR-326/verify.groovy b/src/it/MWAR-326/verify.groovy index 89f9839..547808f 100644 --- a/src/it/MWAR-326/verify.groovy +++ b/src/it/MWAR-326/verify.groovy @@ -18,8 +18,8 @@ * 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-war-plugin-test-mwar-326-1.0-SNAPSHOT.war" ); +File artifact = new File( target, "maven-war-plugin-test-mwar-326-1.0-SNAPSHOT.war" ) assert artifact.exists() : "default artifact should exist." diff --git a/src/it/MWAR-371/verify.groovy b/src/it/MWAR-371/verify.groovy index 4978d38..3ee2116 100644 --- a/src/it/MWAR-371/verify.groovy +++ b/src/it/MWAR-371/verify.groovy @@ -17,30 +17,26 @@ * under the License. */ -boolean checkFile( String fileName, String artifact, String module ) -{ - def customA1 = new File( basedir, "${artifact}/target/${artifact}-1.0-SNAPSHOT/x/${fileName}" ) - if ( ! customA1.exists() ) - { - System.err.println( "${artifact}/target/${artifact}-1.0-SNAPSHOT/x/${fileName} does not exist." ) +boolean checkFile(String fileName, String artifact, String module) { + def customA1 = new File(basedir, "${artifact}/target/${artifact}-1.0-SNAPSHOT/x/${fileName}") + if (! customA1.exists()) { + System.err.println("${artifact}/target/${artifact}-1.0-SNAPSHOT/x/${fileName} does not exist.") return false } - if ( ! customA1.text.contains( module ) ) - { - System.err.println( "${artifact}/target/${artifact}-1.0-SNAPSHOT/x/${fileName} is not ${module}." ) + if (! customA1.text.contains(module)) { + System.err.println("${artifact}/target/${artifact}-1.0-SNAPSHOT/x/${fileName} is not ${module}.") return false } return true } -boolean checkFile( String fileName, String module ) -{ - return checkFile( fileName, module, module ) +boolean checkFile(String fileName, String module) { + return checkFile(fileName, module, module) } -assert checkFile( "a1.txt", "custom" ) -assert checkFile( "a2.txt", "custom" ) -assert checkFile( "a3.txt", "custom", "generic" ) -assert checkFile( "a1.txt", "generic" ) -assert checkFile( "a2.txt", "generic" ) -assert checkFile( "a3.txt", "generic" ) +assert checkFile("a1.txt", "custom") +assert checkFile("a2.txt", "custom") +assert checkFile("a3.txt", "custom", "generic") +assert checkFile("a1.txt", "generic") +assert checkFile("a2.txt", "generic") +assert checkFile("a3.txt", "generic") diff --git a/src/it/MWAR-427_update-without-clean/verify.groovy b/src/it/MWAR-427_update-without-clean/verify.groovy index 282f1d0..571e26e 100644 --- a/src/it/MWAR-427_update-without-clean/verify.groovy +++ b/src/it/MWAR-427_update-without-clean/verify.groovy @@ -18,8 +18,8 @@ */ // outdated-default: MWAR-427 and MWAR-433, only WEB-INF/lib/ is checked for outdated files by default -def defaultWar = new java.util.jar.JarFile( new File( basedir, "outdated-default/target/mwar427-1.0-SNAPSHOT.war" ), false ) -assert defaultWar.getEntry( 'WEB-INF/lib/plexus-utils-3.0.23.jar' ) != null : "updated dependency missing" +def defaultWar = new java.util.jar.JarFile(new File(basedir, "outdated-default/target/mwar427-1.0-SNAPSHOT.war"), false) +assert defaultWar.getEntry('WEB-INF/lib/plexus-utils-3.0.23.jar') != null : "updated dependency missing" assert defaultWar.getEntry( 'WEB-INF/lib/mwar427-1.0-SNAPSHOT.jar' ) != null : "archived classes missing" assert defaultWar.getEntry( 'index.html' ) != null : "renamed page missing" assert defaultWar.getEntry( "WEB-INF/lib/plexus-utils-" + plexusUtilVersion + ".jar" ) == null : "outdated dependency not removed" diff --git a/src/it/default/verify.groovy b/src/it/default/verify.groovy index 5bb254d..7462e8d 100644 --- a/src/it/default/verify.groovy +++ b/src/it/default/verify.groovy @@ -17,50 +17,42 @@ * under the License. */ -import java.util.jar.*; +import java.util.jar.* -File explodedDir = new File( basedir, "target/maven-it-it0016-1.0" ); -System.out.println( "Checking for existence of exploded directory " + explodedDir ); +File explodedDir = new File(basedir, "target/maven-it-it0016-1.0") +System.out.println("Checking for existence of exploded directory " + explodedDir) assert explodedDir.isDirectory() String[] expectedPaths = [ - "index.html", - "WEB-INF/classes/org/apache/maven/it0016/Person.class", - "WEB-INF/lib/commons-logging-1.0.3.jar", -]; -for ( String path : expectedPaths ) -{ - File file = new File( explodedDir, path ); - System.out.println( "Checking for existence of " + file ); + "index.html", + "WEB-INF/classes/org/apache/maven/it0016/Person.class", + "WEB-INF/lib/commons-logging-1.0.3.jar", +] +for (String path : expectedPaths) { + File file = new File(explodedDir, path) + System.out.println("Checking for existence of " + file) assert file.exists() } -String[] unexpectedPaths = [ - "WEB-INF/lib/servlet-api-2.4.jar", -]; -for ( String path : unexpectedPaths ) -{ - File file = new File( explodedDir, path ); - System.out.println( "Checking for absence of " + file ); +String[] unexpectedPaths = ["WEB-INF/lib/servlet-api-2.4.jar",] +for (String path : unexpectedPaths) { + File file = new File(explodedDir, path) + System.out.println("Checking for absence of " + file) assert !file.exists() } -File warFile = new File( basedir, "target/maven-it-it0016-1.0.war" ); -System.out.println( "Checking for existence of " + warFile ); +File warFile = new File(basedir, "target/maven-it-it0016-1.0.war") +System.out.println("Checking for existence of " + warFile) assert warFile.isFile() -JarFile war = new JarFile( warFile ); +JarFile war = new JarFile(warFile) -String[] includedEntries = [ - "WEB-INF/classes/org/apache/maven/it0016/Person.class", - "WEB-INF/lib/commons-logging-1.0.3.jar", -]; -for ( String included : includedEntries ) -{ - System.out.println( "Checking for existence of " + included ); - assert war.getEntry( included ) != null +String[] includedEntries = ["WEB-INF/classes/org/apache/maven/it0016/Person.class", "WEB-INF/lib/commons-logging-1.0.3.jar",] +for (String included : includedEntries) { + System.out.println("Checking for existence of " + included) + assert war.getEntry(included) != null } -war.close(); +war.close() -return true; +return true diff --git a/src/it/web-resources-filtering/verify.groovy b/src/it/web-resources-filtering/verify.groovy index 5038302..6652a04 100644 --- a/src/it/web-resources-filtering/verify.groovy +++ b/src/it/web-resources-filtering/verify.groovy @@ -21,27 +21,27 @@ def aao = "\u00e5\u00e4\u00f6" // a-ring, a-umlaut and o-umlaut def check = { String module, String finalName -> - def webInf = new File( basedir, "${module}/target/${finalName}/WEB-INF" ) + def webInf = new File(basedir, "${module}/target/${finalName}/WEB-INF") assert webInf.isDirectory() : "${webInf} is missing or is not a directory" - def jettyEnv = new File( webInf, "jetty-env.xml" ) + def jettyEnv = new File(webInf, "jetty-env.xml") assert jettyEnv.isFile() : "${jettyEnv} is missing or is a directory" - def jettyEnvContent = jettyEnv.getText( "UTF-8" ) - assert jettyEnvContent.contains( "Characters that should be encoded in UTF-8: ${aao}" ) : "non-ascii characters changed encoding during filtering" - assert jettyEnvContent.contains( '<Set name="URL">jdbc:oracle:thin:@localhost:1521:orcl</Set>' ) : "jdbc.url not filtered correctly" + def jettyEnvContent = jettyEnv.getText("UTF-8") + assert jettyEnvContent.contains("Characters that should be encoded in UTF-8: ${aao}") : "non-ascii characters changed encoding during filtering" + assert jettyEnvContent.contains('<Set name="URL">jdbc:oracle:thin:@localhost:1521:orcl</Set>') : "jdbc.url not filtered correctly" - def myProperties = new File( webInf, "classes/my.properties" ) + def myProperties = new File(webInf, "classes/my.properties") assert myProperties.isFile() : "${myProperties} is missing or is a directory" def properties = new Properties() - myProperties.withInputStream { properties.load( it ) } // reads ISO-8859-1 - assert properties.getProperty( "my.property" ) == "Characters that should be encoded in ISO-8859-1: ${aao}" : "non-ascii characters have wrong encoding after filtering" + myProperties.withInputStream { properties.load(it) } // reads ISO-8859-1 + assert properties.getProperty("my.property") == "Characters that should be encoded in ISO-8859-1: ${aao}" : "non-ascii characters have wrong encoding after filtering" return jettyEnvContent } // default delimiters, the escaped expression stays as it is -def defaultContent = check( "web", "example-web" ) -assert defaultContent.contains( "Author id: 1" ) : "project.developers[0].id not filtered correctly" +def defaultContent = check("web", "example-web") +assert defaultContent.contains("Author id: 1") : "project.developers[0].id not filtered correctly" assert defaultContent.contains( '<Set name="password">${jdbc.password}</Set>' ) : "jdbc.password has been filtered" // custom @@*@@ delimiters, the escaped expression stays as it is
