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-invoker-plugin.git
commit cc19e52c534422c4747b95680547f563de147e9f Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 23:23:14 2026 +0000 Modernize Groovy IT scripts See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/MINVOKER-289/verify.groovy | 3 - src/it/clone-maven-plugin-packaging/verify.groovy | 14 +-- src/it/fail-build-with-verify/verify.groovy | 26 +--- src/it/fail-build/verify.groovy | 26 +--- src/it/fail-postbuild/verify.groovy | 26 +--- src/it/fail-prebuild/verify.groovy | 26 +--- src/it/fail-run-postbuild/verify.groovy | 26 +--- src/it/install-extra-artifacts/verify.groovy | 70 ++++------- src/it/integration-test-never-fails/verify.groovy | 26 +--- src/it/invocation-multiple/verify.groovy | 56 ++------- src/it/invocation-offline/verify.groovy | 11 +- src/it/invocation-project/verify.groovy | 14 +-- src/it/invocation-spaces/verify.groovy | 64 +++------- src/it/invoker-report/verify.groovy | 71 ++--------- src/it/local-repo-default/verify.groovy | 68 +++------- src/it/local-repo-isolated/verify.groovy | 38 +----- src/it/local-repo-path/verify.groovy | 11 +- src/it/pom-filtering-reactor/verify.groovy | 24 +--- src/it/pom-less-invocation/verify.groovy | 40 ++---- src/it/project-cloning-reactor/verify.groovy | 11 +- src/it/project-cloning/setup.groovy | 16 +-- src/it/project-cloning/verify.groovy | 52 +++----- src/it/script-classpath-duplicates/verify.groovy | 38 ++---- src/it/script-errors/verify.groovy | 16 +-- src/it/script-interpreter-detection/verify.groovy | 38 ++---- src/it/script-target-bytecode/verify.groovy | 2 - src/it/selector-scripts/setup.groovy | 2 - src/it/selector-scripts/verify.groovy | 139 ++++++++------------- src/it/spaces-should-work_non-windows/setup.groovy | 7 +- src/it/special-characters-should-work/setup.groovy | 7 +- .../staging-dependencies-test-scope/verify.groovy | 59 +++------ src/it/staging-dependencies/verify.groovy | 126 +++++++------------ src/it/staging-pom/verify.groovy | 48 ++----- src/it/staging-reactor/verify.groovy | 76 ++++------- src/it/updateOnly/verify.groovy | 14 +-- 35 files changed, 330 insertions(+), 961 deletions(-) diff --git a/src/it/MINVOKER-289/verify.groovy b/src/it/MINVOKER-289/verify.groovy index 1b2e85d..04220d2 100644 --- a/src/it/MINVOKER-289/verify.groovy +++ b/src/it/MINVOKER-289/verify.groovy @@ -1,6 +1,3 @@ -import java.lang.reflect.Array -import java.util.stream.Collectors - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/it/clone-maven-plugin-packaging/verify.groovy b/src/it/clone-maven-plugin-packaging/verify.groovy index 2ee7280..c1e93a9 100644 --- a/src/it/clone-maven-plugin-packaging/verify.groovy +++ b/src/it/clone-maven-plugin-packaging/verify.groovy @@ -17,15 +17,5 @@ * under the License. */ -import java.io.*; - -try -{ - File itRoot = new File( basedir, "target/it/clone-clean" ); - return itRoot.exists(); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +File itRoot = new File( basedir, "target/it/clone-clean" ); +assert itRoot.exists() diff --git a/src/it/fail-build-with-verify/verify.groovy b/src/it/fail-build-with-verify/verify.groovy index b7d9d2e..77d475a 100644 --- a/src/it/fail-build-with-verify/verify.groovy +++ b/src/it/fail-build-with-verify/verify.groovy @@ -17,25 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile = new File( basedir, "target/it/project/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +assert touchFile.exists() diff --git a/src/it/fail-build/verify.groovy b/src/it/fail-build/verify.groovy index b7d9d2e..77d475a 100644 --- a/src/it/fail-build/verify.groovy +++ b/src/it/fail-build/verify.groovy @@ -17,25 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile = new File( basedir, "target/it/project/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +assert touchFile.exists() diff --git a/src/it/fail-postbuild/verify.groovy b/src/it/fail-postbuild/verify.groovy index b7d9d2e..77d475a 100644 --- a/src/it/fail-postbuild/verify.groovy +++ b/src/it/fail-postbuild/verify.groovy @@ -17,25 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile = new File( basedir, "target/it/project/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +assert touchFile.exists() diff --git a/src/it/fail-prebuild/verify.groovy b/src/it/fail-prebuild/verify.groovy index b7d9d2e..77d475a 100644 --- a/src/it/fail-prebuild/verify.groovy +++ b/src/it/fail-prebuild/verify.groovy @@ -17,25 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile = new File( basedir, "target/it/project/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +assert touchFile.exists() diff --git a/src/it/fail-run-postbuild/verify.groovy b/src/it/fail-run-postbuild/verify.groovy index b7d9d2e..77d475a 100644 --- a/src/it/fail-run-postbuild/verify.groovy +++ b/src/it/fail-run-postbuild/verify.groovy @@ -17,25 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile = new File( basedir, "target/it/project/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +assert touchFile.exists() diff --git a/src/it/install-extra-artifacts/verify.groovy b/src/it/install-extra-artifacts/verify.groovy index 70e5d9f..a79c62d 100644 --- a/src/it/install-extra-artifacts/verify.groovy +++ b/src/it/install-extra-artifacts/verify.groovy @@ -17,53 +17,29 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File itRepoDir = new File( basedir, "target/it-repo" ); +assert itRepoDir.isDirectory() : "IT local repository missing: " + itRepoDir -try +String[] files = +[ + "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.jar", + "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.pom", + "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4-javadoc.jar", + "org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom", + "org/apache/maven/maven-parent/15/maven-parent-15.pom", + "org/apache/apache/6/apache-6.pom", + "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar", + "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom", + "junit/junit/3.8.2/junit-3.8.2.jar", + "junit/junit/3.8.2/junit-3.8.2.pom", + "jdom/jdom/1.1/jdom-1.1.pom", + "org/jdom/jdom/1.1/jdom-1.1.pom", + "org/jdom/jdom/1.1/jdom-1.1.jar", +]; +for ( String file : files ) { - File itRepoDir = new File( basedir, "target/it-repo" ); - if ( !itRepoDir.isDirectory() ) - { - System.out.println( "IT local repository missing: " + itRepoDir ); - return false; - } - - String[] files = - [ - "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.jar", - "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.pom", - "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4-javadoc.jar", - "org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom", - "org/apache/maven/maven-parent/15/maven-parent-15.pom", - "org/apache/apache/6/apache-6.pom", - "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar", - "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom", - "junit/junit/3.8.2/junit-3.8.2.jar", - "junit/junit/3.8.2/junit-3.8.2.pom", - "jdom/jdom/1.1/jdom-1.1.pom", - "org/jdom/jdom/1.1/jdom-1.1.pom", - "org/jdom/jdom/1.1/jdom-1.1.jar", - ]; - for ( String file : files ) - { - File stagedFile = new File( itRepoDir, file ); - System.out.println( "Checking for existence of: " + stagedFile ); - if ( !stagedFile.isFile() ) - { - throw new IllegalStateException( "Missing: " + stagedFile ); - } - if ( file.endsWith( "jdom-1.1.jar" ) && stagedFile.length() < 1024 * 10 ) - { - throw new IllegalStateException( "Corrupt: " + stagedFile ); - } - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + assert stagedFile.isFile() : "Missing: " + stagedFile + assert !( file.endsWith( "jdom-1.1.jar" ) && stagedFile.length() < 1024 * 10 ) : "Corrupt: " + stagedFile } - -return true; diff --git a/src/it/integration-test-never-fails/verify.groovy b/src/it/integration-test-never-fails/verify.groovy index b7d9d2e..77d475a 100644 --- a/src/it/integration-test-never-fails/verify.groovy +++ b/src/it/integration-test-never-fails/verify.groovy @@ -17,25 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile = new File( basedir, "target/it/project/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +assert touchFile.exists() diff --git a/src/it/invocation-multiple/verify.groovy b/src/it/invocation-multiple/verify.groovy index 75237e9..190a83d 100644 --- a/src/it/invocation-multiple/verify.groovy +++ b/src/it/invocation-multiple/verify.groovy @@ -17,50 +17,18 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File test0File = new File( basedir, "target/it/project/target/test0.txt" ); +System.out.println( "Checking for existence of first test file: " + test0File ); +assert test0File.exists() -import org.codehaus.plexus.util.*; +String test0 = test0File.getText( 'UTF-8' ).trim(); +System.out.println( "Checking contents of first test file: " + test0 ); +assert "ISO-8859-1" == test0 -try -{ - File test0File = new File( basedir, "target/it/project/target/test0.txt" ); - System.out.println( "Checking for existence of first test file: " + test0File ); - if ( !test0File.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } +File test1File = new File( basedir, "target/it/project/target/test1.txt" ); +System.out.println( "Checking for existence of second test file: " + test1File ); +assert test1File.exists() - String test0 = FileUtils.fileRead( test0File, "UTF-8" ).trim(); - System.out.println( "Checking contents of first test file: " + test0 ); - if ( !"ISO-8859-1".equals( test0 ) ) - { - System.out.println( "FAILED!" ); - return false; - } - - File test1File = new File( basedir, "target/it/project/target/test1.txt" ); - System.out.println( "Checking for existence of second test file: " + test1File ); - if ( !test1File.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } - - String test1 = FileUtils.fileRead( test1File, "UTF-8" ).trim(); - System.out.println( "Checking contents of second test file: " + test1 ); - if ( !"UTF-8".equals( test1 ) ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +String test1 = test1File.getText( 'UTF-8' ).trim(); +System.out.println( "Checking contents of second test file: " + test1 ); +assert "UTF-8" == test1 diff --git a/src/it/invocation-offline/verify.groovy b/src/it/invocation-offline/verify.groovy index 00ac1d0..aaf127d 100644 --- a/src/it/invocation-offline/verify.groovy +++ b/src/it/invocation-offline/verify.groovy @@ -17,16 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - // sanity check to make sure the builds were actually run File repoDir = new File( basedir, "target/it-repo" ); System.out.println( "Checking for existence of test repo: " + repoDir ); -if ( !repoDir.exists() ) -{ - throw new FileNotFoundException( "Missing repository directory: " + repoDir ); -} - -return true; +assert repoDir.exists() : "Missing repository directory: " + repoDir diff --git a/src/it/invocation-project/verify.groovy b/src/it/invocation-project/verify.groovy index c59928c..a1fe94e 100644 --- a/src/it/invocation-project/verify.groovy +++ b/src/it/invocation-project/verify.groovy @@ -17,8 +17,6 @@ * under the License. */ -import java.io.*; - String[] unexpectedPaths = [ "sub-1/target", @@ -29,10 +27,7 @@ for ( String path : unexpectedPaths ) { File file = new File( new File( basedir, "target/it/project" ), path); System.out.println( "Checking for absence of: " + file ); - if ( file.exists() ) - { - throw new IOException( "Unexpected path found: " + file ); - } + assert !file.exists() : "Unexpected path found: " + file } String[] expectedPaths = @@ -45,10 +40,5 @@ for ( String path : expectedPaths ) { File file = new File( new File( basedir, "target/it/project" ), path); System.out.println( "Checking for existence of: " + file ); - if ( !file.exists() ) - { - throw new IOException( "Expected path not found: " + file ); - } + assert file.exists() : "Expected path not found: " + file } - -return true; diff --git a/src/it/invocation-spaces/verify.groovy b/src/it/invocation-spaces/verify.groovy index 348b663..a60b23b 100644 --- a/src/it/invocation-spaces/verify.groovy +++ b/src/it/invocation-spaces/verify.groovy @@ -17,58 +17,24 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File testFile = new File( basedir, "target/it projects/project/target/classes/test.txt" ); +System.out.println( "Checking for existence of test file: " + testFile ); +assert testFile.exists() -import org.codehaus.plexus.util.*; +String[] values = [ + "value with spaces from settings", + "value with spaces from cli", +]; -try -{ - File testFile = new File( basedir, "target/it projects/project/target/classes/test.txt" ); - System.out.println( "Checking for existence of test file: " + testFile ); - if ( !testFile.exists() ) +testFile.withReader( 'UTF-8' ) { reader -> + for ( String value : values ) { - System.out.println( "FAILED!" ); - return false; + String line = reader.readLine(); + System.out.println( "Checking for occurrence of: " + value ); + assert value == line } - - String[] values = [ - "value with spaces from settings", - "value with spaces from cli", - ]; - - BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( testFile ), "UTF-8" ) ); - try - { - for ( String value : values ) - { - String line = reader.readLine(); - System.out.println( "Checking for occurrence of: " + value ); - if ( !value.equals( line ) ) - { - System.out.println( "FAILED!" ); - return false; - } - } - } - finally - { - reader.close(); - } - - File installedFile = new File( basedir, "target/it repo/test/spacy-pom/0.1-SNAPSHOT/spacy-pom-0.1-SNAPSHOT.jar" ); - System.out.println( "Checking for existence of installed file: " + installedFile ); - if ( !installedFile.exists() ) - { - System.out.println( "FAILED!" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; } -return true; +File installedFile = new File( basedir, "target/it repo/test/spacy-pom/0.1-SNAPSHOT/spacy-pom-0.1-SNAPSHOT.jar" ); +System.out.println( "Checking for existence of installed file: " + installedFile ); +assert installedFile.exists() diff --git a/src/it/invoker-report/verify.groovy b/src/it/invoker-report/verify.groovy index d2607dc..8e6f7b7 100644 --- a/src/it/invoker-report/verify.groovy +++ b/src/it/invoker-report/verify.groovy @@ -17,71 +17,20 @@ * under the License. */ -import java.io.*; -import java.util.*; - File reportFile = new File( basedir, "target/site/invoker.html"); -passed = true; - System.out.println( "Checking for existence of report file: " + reportFile ); -if ( !reportFile.exists() ) -{ - System.out.println( "FAILED!" ); - passed = false; -} - -buildLogReader = null; -try -{ - buildLogReader = new BufferedReader( new FileReader( new File( basedir, "build.log" ) ) ); - allWarningLines = new ArrayList(); - - currentLine = null; - while ( ( currentLine = buildLogReader.readLine() ) != null ) - { - if ( currentLine.contains( "[WARNING] Incomplete job name-description" ) ) - { - allWarningLines.add( currentLine ); - } - } +assert reportFile.exists() : "Report file missing: " + reportFile - missingNameLinesCount = 0; - missingDescriptionLinesCount = 0; - - for ( currentLine : allWarningLines ) - { - if ( currentLine.contains( "name is missing" ) ) - { - ++missingNameLinesCount; - } - - if ( currentLine.contains( "description is missing" ) ) - { - ++missingDescriptionLinesCount; - } - } +allWarningLines = new File( basedir, "build.log" ).readLines().findAll { + it.contains( "[WARNING] Incomplete job name-description" ) +} - expectedMissingNames = 4; - if ( expectedMissingNames != missingNameLinesCount ) - { - System.out.println( "Current missingNameLinesCount: " + missingNameLinesCount + " but expecting: " + expectedMissingNames ); - passed = false; - } +missingNameLinesCount = allWarningLines.count { it.contains( "name is missing" ) }; +missingDescriptionLinesCount = allWarningLines.count { it.contains( "description is missing" ) }; - expectedMissingDescriptions = 1; - if ( expectedMissingDescriptions != missingDescriptionLinesCount ) - { - System.out.println( "Current missingDescriptionLinesCount: " + missingDescriptionLinesCount + " but expecting: " + expectedMissingDescriptions ); - passed = false; - } -} -finally -{ - if ( buildLogReader != null ) - { - buildLogReader.close(); - } -} +expectedMissingNames = 4; +assert expectedMissingNames == missingNameLinesCount : "Current missingNameLinesCount: " + missingNameLinesCount + " but expecting: " + expectedMissingNames -return passed; +expectedMissingDescriptions = 1; +assert expectedMissingDescriptions == missingDescriptionLinesCount : "Current missingDescriptionLinesCount: " + missingDescriptionLinesCount + " but expecting: " + expectedMissingDescriptions diff --git a/src/it/local-repo-default/verify.groovy b/src/it/local-repo-default/verify.groovy index 249c645..68a7929 100644 --- a/src/it/local-repo-default/verify.groovy +++ b/src/it/local-repo-default/verify.groovy @@ -17,55 +17,27 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File badRepoDir = new File( basedir, "target/bad-repo" ); +assert !badRepoDir.exists() : "Sub build used wrong local repository (from its settings.xml): " + badRepoDir -try -{ - File badRepoDir = new File( basedir, "target/bad-repo" ); - if ( badRepoDir.exists() ) - { - System.out.println( "Sub build used wrong local repository (from its settings.xml): " + badRepoDir ); - return false; - } - - /* - * NOTE: This relies heavily on the Invoker Plugin's configuration of our parent build, not nice but until MINVOKER-49 - * is available here, we have no other way of getting the path. - */ - File localRepoPathOfThisBuild = new File( basedir.getParentFile().getParentFile(), "local-repo" ); - System.out.println("Local repository of this build: " + localRepoPathOfThisBuild); - - File textFile = new File( basedir, "target/its/project/target/local-repo-path.txt" ); - BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( textFile ), "UTF-8" ) ); - File localRepoPathOfSubBuild = new File( reader.readLine() ); - reader.close(); - System.out.println("Local repository of sub build: " + localRepoPathOfSubBuild); +/* + * NOTE: This relies heavily on the Invoker Plugin's configuration of our parent build, not nice but until MINVOKER-49 + * is available here, we have no other way of getting the path. + */ +File localRepoPathOfThisBuild = new File( basedir.getParentFile().getParentFile(), "local-repo" ); +System.out.println("Local repository of this build: " + localRepoPathOfThisBuild); - /* - * This is partly a sanity check of the Maven core (i.e. its MavenSettingsBuilder) which should ensure - * ${settings.localRepository} == ${maven.repo.local} - * This IT is run with maven.repo.local but the Invoker Plugin passes settings.localRepository down to the sub build - * so these paths must match. - */ - if ( !localRepoPathOfThisBuild.getCanonicalPath().equals( localRepoPathOfSubBuild.getCanonicalPath() ) ) - { - System.out.println( "Sub build used wrong local repository: " + localRepoPathOfSubBuild ); - return false; - } +File textFile = new File( basedir, "target/its/project/target/local-repo-path.txt" ); +File localRepoPathOfSubBuild = new File( textFile.readLines( 'UTF-8' )[0] ); +System.out.println("Local repository of sub build: " + localRepoPathOfSubBuild); - File installedFile = new File( localRepoPathOfThisBuild, "test/local-repo-default/0.1-SNAPSHOT/local-repo-default-0.1-SNAPSHOT.pom" ); - if ( !installedFile.isFile() ) - { - System.out.println( "Installed file missing in local repo: " + installedFile ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +/* + * This is partly a sanity check of the Maven core (i.e. its MavenSettingsBuilder) which should ensure + * ${settings.localRepository} == ${maven.repo.local} + * This IT is run with maven.repo.local but the Invoker Plugin passes settings.localRepository down to the sub build + * so these paths must match. + */ +assert localRepoPathOfThisBuild.getCanonicalPath() == localRepoPathOfSubBuild.getCanonicalPath() : "Sub build used wrong local repository: " + localRepoPathOfSubBuild -return true; +File installedFile = new File( localRepoPathOfThisBuild, "test/local-repo-default/0.1-SNAPSHOT/local-repo-default-0.1-SNAPSHOT.pom" ); +assert installedFile.isFile() : "Installed file missing in local repo: " + installedFile diff --git a/src/it/local-repo-isolated/verify.groovy b/src/it/local-repo-isolated/verify.groovy index 1593cff..45c0594 100644 --- a/src/it/local-repo-isolated/verify.groovy +++ b/src/it/local-repo-isolated/verify.groovy @@ -17,37 +17,11 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File badRepoDir = new File( basedir, "target/bad-repo" ); +assert !badRepoDir.exists() : "IT used wrong local repository: " + badRepoDir -try -{ - File badRepoDir = new File( basedir, "target/bad-repo" ); - if ( badRepoDir.exists() ) - { - System.out.println( "IT used wrong local repository: " + badRepoDir ); - return false; - } +File itRepoDir = new File( basedir, "target/it-repo" ); +assert itRepoDir.isDirectory() : "IT local repository missing: " + itRepoDir - File itRepoDir = new File( basedir, "target/it-repo" ); - if ( !itRepoDir.isDirectory() ) - { - System.out.println( "IT local repository missing: " + itRepoDir ); - return false; - } - - File installedFile = new File( itRepoDir, "test/local-repo-isolated/0.1-SNAPSHOT/local-repo-isolated-0.1-SNAPSHOT.pom" ); - if ( !installedFile.isFile() ) - { - System.out.println( "Installed file missing in local repo: " + installedFile ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +File installedFile = new File( itRepoDir, "test/local-repo-isolated/0.1-SNAPSHOT/local-repo-isolated-0.1-SNAPSHOT.pom" ); +assert installedFile.isFile() : "Installed file missing in local repo: " + installedFile diff --git a/src/it/local-repo-path/verify.groovy b/src/it/local-repo-path/verify.groovy index 00ac1d0..aaf127d 100644 --- a/src/it/local-repo-path/verify.groovy +++ b/src/it/local-repo-path/verify.groovy @@ -17,16 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - // sanity check to make sure the builds were actually run File repoDir = new File( basedir, "target/it-repo" ); System.out.println( "Checking for existence of test repo: " + repoDir ); -if ( !repoDir.exists() ) -{ - throw new FileNotFoundException( "Missing repository directory: " + repoDir ); -} - -return true; +assert repoDir.exists() : "Missing repository directory: " + repoDir diff --git a/src/it/pom-filtering-reactor/verify.groovy b/src/it/pom-filtering-reactor/verify.groovy index 6921bb8..865ad52 100644 --- a/src/it/pom-filtering-reactor/verify.groovy +++ b/src/it/pom-filtering-reactor/verify.groovy @@ -17,12 +17,6 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -import org.codehaus.plexus.util.*; - boolean check( String project, boolean filtered ) { File pomFile = new File( basedir, "target/it/" + project + "/pom.xml" ); @@ -33,7 +27,7 @@ boolean check( String project, boolean filtered ) return false; } - String xml = FileUtils.fileRead( pomFile, "UTF-8" ); + String xml = pomFile.getText( 'UTF-8' ); String[] values = [ "<prop0>pom-filtering-reactor</prop0>", @@ -50,16 +44,6 @@ boolean check( String project, boolean filtered ) return true; } -try -{ - return check( "mod2-parent", true ) && check( "mod2-parent/mod2", true ) && check( "mod2-parent/mod1-parent", true ) - && check( "mod2-parent/mod1", true ) && check( "mod2-parent/mod3", true) - && check( "mod2-parent/mod1/src/it", false ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +assert check( "mod2-parent", true ) && check( "mod2-parent/mod2", true ) && check( "mod2-parent/mod1-parent", true ) && + check( "mod2-parent/mod1", true ) && check( "mod2-parent/mod3", true) && + check( "mod2-parent/mod1/src/it", false ) diff --git a/src/it/pom-less-invocation/verify.groovy b/src/it/pom-less-invocation/verify.groovy index 5f0aaa7..478e5d4 100644 --- a/src/it/pom-less-invocation/verify.groovy +++ b/src/it/pom-less-invocation/verify.groovy @@ -17,37 +17,15 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File itDir = new File( basedir, "target/it" ); +assert itDir.isDirectory() : "IT directory not existent: " + itDir -try +String[] paths = [ + "no-pom", + "no-pom/build.log", +]; +for ( String path : paths ) { - File itDir = new File( basedir, "target/it" ); - if ( !itDir.isDirectory() ) - { - System.out.println( "IT directory not existent: " + itDir ); - return false; - } - - String[] paths = [ - "no-pom", - "no-pom/build.log", - ]; - for ( String path : paths ) - { - File file = new File( itDir, path ); - if ( !file.exists() ) - { - System.out.println( "Expected file/directory not existent: " + file ); - return false; - } - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; + File file = new File( itDir, path ); + assert file.exists() : "Expected file/directory not existent: " + file } - -return true; diff --git a/src/it/project-cloning-reactor/verify.groovy b/src/it/project-cloning-reactor/verify.groovy index 22358c9..0f73188 100644 --- a/src/it/project-cloning-reactor/verify.groovy +++ b/src/it/project-cloning-reactor/verify.groovy @@ -17,16 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - // sanity check to make sure the builds were actually run File itDir = new File( basedir, "target/it" ); System.out.println( "Checking for existence of clones: " + itDir ); -if ( !itDir.exists() ) -{ - throw new FileNotFoundException( "Missing IT directory: " + itDir ); -} - -return true; +assert itDir.exists() : "Missing IT directory: " + itDir diff --git a/src/it/project-cloning/setup.groovy b/src/it/project-cloning/setup.groovy index ca4c31a..b890f60 100644 --- a/src/it/project-cloning/setup.groovy +++ b/src/it/project-cloning/setup.groovy @@ -17,19 +17,7 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - File emptyDir = new File( basedir, "src/it/module-1/empty-dir" ); - emptyDir.mkdirs(); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +File emptyDir = new File( basedir, "src/it/module-1/empty-dir" ); +emptyDir.mkdirs(); return true; diff --git a/src/it/project-cloning/verify.groovy b/src/it/project-cloning/verify.groovy index 4568519..4d2e5d5 100644 --- a/src/it/project-cloning/verify.groovy +++ b/src/it/project-cloning/verify.groovy @@ -17,43 +17,21 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File itDir = new File( basedir, "target/it" ); +assert itDir.isDirectory() : "IT directory not existent: " + itDir -try +// NOTE: It is part of the test design that "module" is a prefix of "module-1" +String[] paths = [ + "module", + "module/pom.xml", + "module-1", + "module-1/pom.xml", + "module-1/empty-dir", + "module-1/sub-module", + "module-1/sub-module/pom.xml", +]; +for ( String path : paths ) { - File itDir = new File( basedir, "target/it" ); - if ( !itDir.isDirectory() ) - { - System.out.println( "IT directory not existent: " + itDir ); - return false; - } - - // NOTE: It is part of the test design that "module" is a prefix of "module-1" - String[] paths = [ - "module", - "module/pom.xml", - "module-1", - "module-1/pom.xml", - "module-1/empty-dir", - "module-1/sub-module", - "module-1/sub-module/pom.xml", - ]; - for ( String path : paths ) - { - File file = new File( itDir, path ); - if ( !file.exists() ) - { - System.out.println( "Cloned file/directory not existent: " + file ); - return false; - } - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; + File file = new File( itDir, path ); + assert file.exists() : "Cloned file/directory not existent: " + file } - -return true; diff --git a/src/it/script-classpath-duplicates/verify.groovy b/src/it/script-classpath-duplicates/verify.groovy index 7155c09..4c8c967 100644 --- a/src/it/script-classpath-duplicates/verify.groovy +++ b/src/it/script-classpath-duplicates/verify.groovy @@ -17,33 +17,15 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - String[] files = [ - "target/it/beanshell/target/created-by-prebuild.bsh", - "target/it/beanshell/target/created-by-postbuild.bsh", - "target/it/groovy/target/created-by-prebuild.groovy", - "target/it/groovy/target/created-by-postbuild.groovy", - ]; - for ( String file : files ) - { - File touchFile = new File( basedir, file ); - System.out.println( "Checking for existence of: " + touchFile ); - if ( !touchFile.isFile() ) - { - System.out.println( "FAILED!" ); - return false; - } - } -} -catch( Throwable t ) +String[] files = [ + "target/it/beanshell/target/created-by-prebuild.bsh", + "target/it/beanshell/target/created-by-postbuild.bsh", + "target/it/groovy/target/created-by-prebuild.groovy", + "target/it/groovy/target/created-by-postbuild.groovy", + ]; +for ( String file : files ) { - t.printStackTrace(); - return false; + File touchFile = new File( basedir, file ); + System.out.println( "Checking for existence of: " + touchFile ); + assert touchFile.isFile() } - -return true; diff --git a/src/it/script-errors/verify.groovy b/src/it/script-errors/verify.groovy index 81ac2c8..d02aa85 100644 --- a/src/it/script-errors/verify.groovy +++ b/src/it/script-errors/verify.groovy @@ -17,25 +17,13 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else File touchFile; touchFile = new File( basedir, "target/its/beanshell/touch.txt" ); System.out.println( "Checking for existence of touch file: " + touchFile ); -if ( !touchFile.exists() ) -{ - throw new FileNotFoundException( "Did not find marker file: " + touchFile ); -} +assert touchFile.exists() : "Did not find marker file: " + touchFile touchFile = new File( basedir, "target/its/groovy/touch.txt" ); System.out.println( "Checking for existence of touch file: " + touchFile ); -if ( !touchFile.exists() ) -{ - throw new FileNotFoundException( "Did not find marker file: " + touchFile ); -} - -return true; +assert touchFile.exists() : "Did not find marker file: " + touchFile diff --git a/src/it/script-interpreter-detection/verify.groovy b/src/it/script-interpreter-detection/verify.groovy index 45300fd..d1d42d1 100644 --- a/src/it/script-interpreter-detection/verify.groovy +++ b/src/it/script-interpreter-detection/verify.groovy @@ -17,33 +17,15 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -try -{ - String[] files = [ - "target/its/beanshell/target/prebuild.bsh", - "target/its/beanshell/target/postbuild.bsh", - "target/its/groovy/target/prebuild.groovy", - "target/its/groovy/target/postbuild.groovy", - ]; - for ( String file : files ) - { - File touchFile = new File( basedir, file ); - System.out.println( "Checking for existence of: " + touchFile ); - if ( !touchFile.isFile() ) - { - System.out.println( "FAILED!" ); - return false; - } - } -} -catch( Throwable t ) +String[] files = [ + "target/its/beanshell/target/prebuild.bsh", + "target/its/beanshell/target/postbuild.bsh", + "target/its/groovy/target/prebuild.groovy", + "target/its/groovy/target/postbuild.groovy", + ]; +for ( String file : files ) { - t.printStackTrace(); - return false; + File touchFile = new File( basedir, file ); + System.out.println( "Checking for existence of: " + touchFile ); + assert touchFile.isFile() } - -return true; diff --git a/src/it/script-target-bytecode/verify.groovy b/src/it/script-target-bytecode/verify.groovy index e2b4961..ce689a7 100644 --- a/src/it/script-target-bytecode/verify.groovy +++ b/src/it/script-target-bytecode/verify.groovy @@ -22,5 +22,3 @@ File result = new File( basedir, "target/its/project/record-superclass.txt" ) assert result.exists() : "the post-build hook script did not run" assert result.text == "java.lang.Object" - -return true diff --git a/src/it/selector-scripts/setup.groovy b/src/it/selector-scripts/setup.groovy index 44b015c..12f9aa8 100644 --- a/src/it/selector-scripts/setup.groovy +++ b/src/it/selector-scripts/setup.groovy @@ -17,8 +17,6 @@ * under the License. */ -import java.io.File - // Previous potential target 'content' has impact on IT execution // (Some new file should be created by verify.sh) new File( basedir, "target/invoker-reports-test" ).deleteDir() diff --git a/src/it/selector-scripts/verify.groovy b/src/it/selector-scripts/verify.groovy index b91b30b..ff64c46 100644 --- a/src/it/selector-scripts/verify.groovy +++ b/src/it/selector-scripts/verify.groovy @@ -17,99 +17,60 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - -import org.codehaus.plexus.util.*; - -try +String[] expected = [ + "target/its/script-ret-true/target/touch.txt", + "target/its/script-ret-quiet/target/touch.txt", + ]; +for ( String file : expected ) { - String[] expected = [ - "target/its/script-ret-true/target/touch.txt", - "target/its/script-ret-quiet/target/touch.txt", - ]; - for ( String file : expected ) - { - File touchFile = new File( basedir, file ); - System.out.println( "Checking for existence of: " + touchFile ); - if ( !touchFile.isFile() ) - { - System.out.println( "FAILED!" ); - return false; - } - } - - String[] unexpected = [ - "target/its/script-ret-false/target/touch.txt", - "target/its/script-ret-other/target/touch.txt", - "target/its/script-throws/target/touch.txt", - ]; - for ( String file : unexpected ) - { - File touchFile = new File( basedir, file ); - System.out.println( "Checking for absence of: " + touchFile ); - if ( touchFile.exists() ) - { - System.out.println( file + " should not be here -> FAILED!" ); - return false; - } - } - - String[] success = [ - "target/invoker-reports-test/BUILD-script-ret-true.xml", - "target/invoker-reports-test/BUILD-script-ret-quiet.xml", - ]; - for ( String file : success ) - { - File resultFile = new File( basedir, file ); - System.out.println( "Checking build result: " + resultFile ); - String xml = FileUtils.fileRead( resultFile, "UTF-8" ); - if ( xml.indexOf("result=\"success\"") < 0 && xml.indexOf("result='success'") < 0 ) - { - System.out.println( resultFile + " not success -> FAILED!" ); - return false; - } - } - - String[] skipped = [ - "target/invoker-reports-test/BUILD-script-ret-false.xml", - "target/invoker-reports-test/BUILD-script-ret-other.xml", - ]; - for ( String file : skipped ) - { - File resultFile = new File( basedir, file ); - System.out.println( "Checking build result: " + resultFile ); - String xml = FileUtils.fileRead( resultFile, "UTF-8" ); - if ( xml.indexOf("result=\"skipped\"") < 0 && xml.indexOf("result='skipped'") < 0 ) - { - System.out.println( resultFile + " not skipped -> FAILED!" ); - return false; - } - } - - - String[] inerror = [ - "target/invoker-reports-test/BUILD-script-throw.xml", - ]; - for ( String file : inerror ) - { - File resultFile = new File( basedir, file ); - System.out.println( "Checking build result: " + resultFile ); - String xml = FileUtils.fileRead( resultFile, "UTF-8" ); - if ( xml.indexOf("result=\"error\"") < 0 && xml.indexOf("result='error'") < 0 ) - { - System.out.println( resultFile + " not failed -> FAILED!" ); - return false; - } - } + File touchFile = new File( basedir, file ); + System.out.println( "Checking for existence of: " + touchFile ); + assert touchFile.isFile() +} +String[] unexpected = [ + "target/its/script-ret-false/target/touch.txt", + "target/its/script-ret-other/target/touch.txt", + "target/its/script-throws/target/touch.txt", + ]; +for ( String file : unexpected ) +{ + File touchFile = new File( basedir, file ); + System.out.println( "Checking for absence of: " + touchFile ); + assert !touchFile.exists() : file + " should not be here -> FAILED!" +} +String[] success = [ + "target/invoker-reports-test/BUILD-script-ret-true.xml", + "target/invoker-reports-test/BUILD-script-ret-quiet.xml", + ]; +for ( String file : success ) +{ + File resultFile = new File( basedir, file ); + System.out.println( "Checking build result: " + resultFile ); + String xml = resultFile.getText( 'UTF-8' ); + assert xml.indexOf("result=\"success\"") >= 0 || xml.indexOf("result='success'") >= 0 : resultFile + " not success -> FAILED!" } -catch( Throwable t ) + +String[] skipped = [ + "target/invoker-reports-test/BUILD-script-ret-false.xml", + "target/invoker-reports-test/BUILD-script-ret-other.xml", + ]; +for ( String file : skipped ) { - t.printStackTrace(); - return false; + File resultFile = new File( basedir, file ); + System.out.println( "Checking build result: " + resultFile ); + String xml = resultFile.getText( 'UTF-8' ); + assert xml.indexOf("result=\"skipped\"") >= 0 || xml.indexOf("result='skipped'") >= 0 : resultFile + " not skipped -> FAILED!" } -return true; +String[] inerror = [ + "target/invoker-reports-test/BUILD-script-throw.xml", + ]; +for ( String file : inerror ) +{ + File resultFile = new File( basedir, file ); + System.out.println( "Checking build result: " + resultFile ); + String xml = resultFile.getText( 'UTF-8' ); + assert xml.indexOf("result=\"error\"") >= 0 || xml.indexOf("result='error'") >= 0 : resultFile + " not failed -> FAILED!" +} diff --git a/src/it/spaces-should-work_non-windows/setup.groovy b/src/it/spaces-should-work_non-windows/setup.groovy index 829476f..5dda424 100644 --- a/src/it/spaces-should-work_non-windows/setup.groovy +++ b/src/it/spaces-should-work_non-windows/setup.groovy @@ -17,9 +17,6 @@ * under the License. */ -import java.io.* -import java.util.* -import java.util.regex.* import org.apache.commons.io.FileUtils File srcIt = new File (basedir, "src/it"); @@ -27,6 +24,4 @@ File originalFolder = new File (srcIt, "minvoker-test"); File destinationFolder = new File(srcIt, "test-\u00c9\u00e9\u00ea- & -\u00c9\u00e9\u00ea-test"); FileUtils.deleteQuietly(destinationFolder); // rename old one into new one with special characters. -if (!originalFolder.renameTo(destinationFolder)) { - throw new IOException("Rename didn't work.") -} +assert originalFolder.renameTo(destinationFolder) : "Rename didn't work." diff --git a/src/it/special-characters-should-work/setup.groovy b/src/it/special-characters-should-work/setup.groovy index 85f8a98..1b895f2 100644 --- a/src/it/special-characters-should-work/setup.groovy +++ b/src/it/special-characters-should-work/setup.groovy @@ -17,9 +17,6 @@ * under the License. */ -import java.io.* -import java.util.* -import java.util.regex.* import org.apache.commons.io.FileUtils File srcIt = new File (basedir, "src/it"); @@ -27,6 +24,4 @@ File originalFolder = new File (srcIt, "minvoker-test"); File destinationFolder = new File(srcIt, "test-\u00c9\u00e9\u00ea-more-\u00c9\u00e9\u00ea-test"); FileUtils.deleteQuietly(destinationFolder); // rename old one into new one with special characters. -if (!originalFolder.renameTo(destinationFolder)) { - throw new IOException("Rename didn't work.") -} +assert originalFolder.renameTo(destinationFolder) : "Rename didn't work." diff --git a/src/it/staging-dependencies-test-scope/verify.groovy b/src/it/staging-dependencies-test-scope/verify.groovy index c06f51f..eb54ae8 100644 --- a/src/it/staging-dependencies-test-scope/verify.groovy +++ b/src/it/staging-dependencies-test-scope/verify.groovy @@ -17,49 +17,28 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - import org.codehaus.plexus.util.*; import org.codehaus.plexus.util.xml.*; -try -{ - File itRepoDir = new File( basedir, "target/it-repo" ); - System.out.println( "Checking for existence of: " + itRepoDir ); - if ( !itRepoDir.isDirectory() ) - { - System.out.println( "FAILED!" ); - return false; - } +File itRepoDir = new File( basedir, "target/it-repo" ); +System.out.println( "Checking for existence of: " + itRepoDir ); +assert itRepoDir.isDirectory() - String[] files = [ - "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar", - "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom", - "org/slf4j/slf4j-api/maven-metadata-local.xml", - "org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom", - "org/slf4j/slf4j-parent/maven-metadata-local.xml", - "org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar", - "org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.pom", - "org/slf4j/slf4j-simple/maven-metadata-local.xml", - "test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.pom", - "test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.jar" - ]; - for ( String file : files ) - { - File stagedFile = new File( itRepoDir, file ); - System.out.println( "Checking for existence of: " + stagedFile ); - if ( !stagedFile.isFile() ) - { - throw new IllegalStateException( "Missing: " + stagedFile ); - } - } -} -catch( Throwable t ) +String[] files = [ + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar", + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom", + "org/slf4j/slf4j-api/maven-metadata-local.xml", + "org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom", + "org/slf4j/slf4j-parent/maven-metadata-local.xml", + "org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar", + "org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.pom", + "org/slf4j/slf4j-simple/maven-metadata-local.xml", + "test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.pom", + "test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.jar" + ]; +for ( String file : files ) { - t.printStackTrace(); - return false; + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + assert stagedFile.isFile() : "Missing: " + stagedFile } - -return true; diff --git a/src/it/staging-dependencies/verify.groovy b/src/it/staging-dependencies/verify.groovy index d3c9f35..5b6ae1c 100644 --- a/src/it/staging-dependencies/verify.groovy +++ b/src/it/staging-dependencies/verify.groovy @@ -17,89 +17,59 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; - import org.codehaus.plexus.util.*; import org.codehaus.plexus.util.xml.*; -try -{ - File itRepoDir = new File( basedir, "target/it-repo" ); - System.out.println( "Checking for existence of: " + itRepoDir ); - if ( !itRepoDir.isDirectory() ) - { - System.out.println( "FAILED!" ); - return false; - } - - String[] files = [ - "junit/junit/4.13.1/junit-4.13.1.pom", - "junit/junit/4.13.1/junit-4.13.1.jar", - "junit/junit/maven-metadata-local.xml", - "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.pom", - "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.jar", - "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata-local.xml", - "org/apache/maven/its/minvoker-70/maven-metadata-local.xml", - "org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-SNAPSHOT.pom", - "org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata-local.xml", - "org/apache/maven/its/parent-b/maven-metadata-local.xml", - "org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-SNAPSHOT.pom", - "org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata-local.xml", - "org/apache/maven/its/parent-a/maven-metadata-local.xml", - "org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-SNAPSHOT.pom", - "org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata-local.xml", - "org/apache/maven/its/pom/maven-metadata-local.xml", - "org/apache/maven/its/dep/1.0/dep-1.0.pom", - "org/apache/maven/its/dep/1.0/dep-1.0-tests.jar", - "org/apache/maven/its/dep/2.0/dep-2.0.pom", - "org/apache/maven/its/dep/2.0/dep-2.0.jar", - "org/apache/maven/its/dep/maven-metadata-local.xml", - "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.jar", - "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.pom", - "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom", - "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar", - "org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom" - ]; - for ( String file : files ) - { - File stagedFile = new File( itRepoDir, file ); - System.out.println( "Checking for existence of: " + stagedFile ); - if ( !stagedFile.isFile() ) - { - throw new IllegalStateException( "Missing: " + stagedFile ); - } - } +File itRepoDir = new File( basedir, "target/it-repo" ); +System.out.println( "Checking for existence of: " + itRepoDir ); +assert itRepoDir.isDirectory() - File stagedTestScope = new File(itRepoDir, "org/slf4j/slf4j-simple"); - if ( stagedTestScope.exists() ) - { - throw new IllegalStateException( "Test scope dependencies should not exists" ); - } +String[] files = [ + "junit/junit/4.13.1/junit-4.13.1.pom", + "junit/junit/4.13.1/junit-4.13.1.jar", + "junit/junit/maven-metadata-local.xml", + "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.pom", + "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.jar", + "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/minvoker-70/maven-metadata-local.xml", + "org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-SNAPSHOT.pom", + "org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/parent-b/maven-metadata-local.xml", + "org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-SNAPSHOT.pom", + "org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/parent-a/maven-metadata-local.xml", + "org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-SNAPSHOT.pom", + "org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/pom/maven-metadata-local.xml", + "org/apache/maven/its/dep/1.0/dep-1.0.pom", + "org/apache/maven/its/dep/1.0/dep-1.0-tests.jar", + "org/apache/maven/its/dep/2.0/dep-2.0.pom", + "org/apache/maven/its/dep/2.0/dep-2.0.jar", + "org/apache/maven/its/dep/maven-metadata-local.xml", + "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.jar", + "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.pom", + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom", + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar", + "org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom" + ]; +for ( String file : files ) +{ + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + assert stagedFile.isFile() : "Missing: " + stagedFile +} - Reader reader = ReaderFactory.newXmlReader( new File( itRepoDir, "org/apache/maven/its/dep/maven-metadata-local.xml" ) ); - Xpp3Dom dom = Xpp3DomBuilder.build( reader ); - IOUtil.close( reader ); +File stagedTestScope = new File(itRepoDir, "org/slf4j/slf4j-simple"); +assert !stagedTestScope.exists() : "Test scope dependencies should not exists" - if ( dom.getChild( "versioning" ).getChild( "versions" ).getChildCount() != 2 ) - { - throw new IllegalStateException( "Invalid version number count in metadata" ); - } +Reader reader = ReaderFactory.newXmlReader( new File( itRepoDir, "org/apache/maven/its/dep/maven-metadata-local.xml" ) ); +Xpp3Dom dom = Xpp3DomBuilder.build( reader ); +IOUtil.close( reader ); - List versions = new ArrayList(); - versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 0 ).getValue() ); - versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 1 ).getValue() ); - Collections.sort( versions ); - if ( !versions.equals( Arrays.asList( new String[] { "1.0", "2.0" } ) ) ) - { - throw new IllegalStateException( "Invalid version numbers in metadata: " + versions ); - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +assert dom.getChild( "versioning" ).getChild( "versions" ).getChildCount() == 2 : "Invalid version number count in metadata" -return true; +List versions = new ArrayList(); +versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 0 ).getValue() ); +versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 1 ).getValue() ); +Collections.sort( versions ); +assert versions.equals( Arrays.asList( new String[] { "1.0", "2.0" } ) ) : "Invalid version numbers in metadata: " + versions diff --git a/src/it/staging-pom/verify.groovy b/src/it/staging-pom/verify.groovy index b1d033f..0793e20 100644 --- a/src/it/staging-pom/verify.groovy +++ b/src/it/staging-pom/verify.groovy @@ -17,41 +17,19 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File itRepoDir = new File( basedir, "target/it-repo" ); +System.out.println( "Checking for existence of: " + itRepoDir ); +assert itRepoDir.isDirectory() -try +String[] files = [ + "test/pom-packaging/1.0-SNAPSHOT/pom-packaging-1.0-SNAPSHOT.pom", + "org/apache/maven/plugins/maven-plugins/39/maven-plugins-39.pom", + "org/apache/maven/maven-parent/39/maven-parent-39.pom", + "org/apache/apache/29/apache-29.pom" + ]; +for ( String file : files ) { - File itRepoDir = new File( basedir, "target/it-repo" ); - System.out.println( "Checking for existence of: " + itRepoDir ); - if ( !itRepoDir.isDirectory() ) - { - System.out.println( "FAILED!" ); - return false; - } - - String[] files = [ - "test/pom-packaging/1.0-SNAPSHOT/pom-packaging-1.0-SNAPSHOT.pom", - "org/apache/maven/plugins/maven-plugins/39/maven-plugins-39.pom", - "org/apache/maven/maven-parent/39/maven-parent-39.pom", - "org/apache/apache/29/apache-29.pom" - ]; - for ( String file : files ) - { - File stagedFile = new File( itRepoDir, file ); - System.out.println( "Checking for existence of: " + stagedFile ); - if ( !stagedFile.isFile() ) - { - System.out.println( "FAILED!" ); - return false; - } - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + assert stagedFile.isFile() } - -return true; diff --git a/src/it/staging-reactor/verify.groovy b/src/it/staging-reactor/verify.groovy index c0cac4d..c7b6beb 100644 --- a/src/it/staging-reactor/verify.groovy +++ b/src/it/staging-reactor/verify.groovy @@ -17,55 +17,33 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +File itRepoDir = new File( basedir, "mod1/target/it-repo" ); +System.out.println( "Checking for existence of: " + itRepoDir ); +assert itRepoDir.isDirectory() -try +// NOTE: Checking the metadata is included to guard against regression of MINVOKER-43 +String[] files = [ + "test/mod1/maven-metadata-local.xml", + "test/mod1/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod1/1.0-SNAPSHOT/mod1-1.0-SNAPSHOT.pom", + "test/mod1/1.0-SNAPSHOT/mod1-1.0-SNAPSHOT.jar", + "test/mod1-parent/maven-metadata-local.xml", + "test/mod1-parent/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod1-parent/1.0-SNAPSHOT/mod1-parent-1.0-SNAPSHOT.pom", + "test/mod2/maven-metadata-local.xml", + "test/mod2/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.pom", + "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.jar", + "test/mod3/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod3/1.0-SNAPSHOT/mod3-1.0-SNAPSHOT.pom", + "test/mod3/1.0-SNAPSHOT/mod3-1.0-SNAPSHOT.jar", + "test/mod2-parent/maven-metadata-local.xml", + "test/mod2-parent/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod2-parent/1.0-SNAPSHOT/mod2-parent-1.0-SNAPSHOT.pom", + ]; +for ( String file : files ) { - File itRepoDir = new File( basedir, "mod1/target/it-repo" ); - System.out.println( "Checking for existence of: " + itRepoDir ); - if ( !itRepoDir.isDirectory() ) - { - System.out.println( "FAILED!" ); - return false; - } - - // NOTE: Checking the metadata is included to guard against regression of MINVOKER-43 - String[] files = [ - "test/mod1/maven-metadata-local.xml", - "test/mod1/1.0-SNAPSHOT/maven-metadata-local.xml", - "test/mod1/1.0-SNAPSHOT/mod1-1.0-SNAPSHOT.pom", - "test/mod1/1.0-SNAPSHOT/mod1-1.0-SNAPSHOT.jar", - "test/mod1-parent/maven-metadata-local.xml", - "test/mod1-parent/1.0-SNAPSHOT/maven-metadata-local.xml", - "test/mod1-parent/1.0-SNAPSHOT/mod1-parent-1.0-SNAPSHOT.pom", - "test/mod2/maven-metadata-local.xml", - "test/mod2/1.0-SNAPSHOT/maven-metadata-local.xml", - "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.pom", - "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.jar", - "test/mod3/1.0-SNAPSHOT/maven-metadata-local.xml", - "test/mod3/1.0-SNAPSHOT/mod3-1.0-SNAPSHOT.pom", - "test/mod3/1.0-SNAPSHOT/mod3-1.0-SNAPSHOT.jar", - "test/mod2-parent/maven-metadata-local.xml", - "test/mod2-parent/1.0-SNAPSHOT/maven-metadata-local.xml", - "test/mod2-parent/1.0-SNAPSHOT/mod2-parent-1.0-SNAPSHOT.pom", - ]; - for ( String file : files ) - { - File stagedFile = new File( itRepoDir, file ); - System.out.println( "Checking for existence of: " + stagedFile ); - if ( !stagedFile.isFile() ) - { - System.out.println( "FAILED!" ); - return false; - } - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + assert stagedFile.isFile() } - -return true; diff --git a/src/it/updateOnly/verify.groovy b/src/it/updateOnly/verify.groovy index 18922e7..77de758 100644 --- a/src/it/updateOnly/verify.groovy +++ b/src/it/updateOnly/verify.groovy @@ -17,18 +17,8 @@ * under the License. */ -import java.io.*; - File marker = new File( basedir, "target/it/project/target/marker.txt" ); -if ( !marker.exists() ) -{ - throw new IOException( "Marker file should have been created in setup: " + marker ); -} +assert marker.exists() : "Marker file should have been created in setup: " + marker File archive = new File( basedir, "target/it/project/target/project-0.1-SNAPSHOT.jar" ); -if ( archive.exists() ) -{ - throw new IOException( "Target file creation should have been skipped: " + archive ); -} - -return true; +assert !archive.exists() : "Target file creation should have been skipped: " + archive
