Package org.apache.maven.shared.verifier
Class Verifier
java.lang.Object
org.apache.maven.shared.verifier.Verifier
Deprecated.
Maven test harness for integration tests.
DEPRECATION NOTICE: This class is deprecated and this project will be retired soon.
Please migrate to
maven-executor
(org.apache.maven.executor:maven-executor),
which provides a unified, modern API for programmatic Maven execution with support for both
Maven 3.9+ and Maven 4+.
Benefits of maven-executor:
- Unified API that doesn't require updates when Maven CLI changes
- Support for both forked and embedded execution modes
- Dependency-less design
- Better environment isolation
- Transparent support for Maven 3.9+ and Maven 4+
Migration example:
// Old (maven-verifier):
Verifier verifier = new Verifier("/path/to/project");
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();
// New (maven-executor) — groupId: org.apache.maven.executor, artifactId: maven-executor:
Path mavenHome = Paths.get(System.getProperty("maven.home"));
try (ExecutorHelper executor = ExecutorHelper.forMavenInstallation(mavenHome, ExecutorHelper.Mode.AUTO)) {
ExecutorRequest request = ExecutorRequest.mavenBuilder()
.cwd(Paths.get("/path/to/project"))
.arguments("package")
.build();
ExecutorResult result = executor.execute(request);
assertTrue(result.success());
}
- Author:
- Jason van Zyl, Brett Porter
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Deprecated.to be removed useVerifier(String basedir)Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings fileDeprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings fileDeprecated.to be removed useVerifier(String)setSettingsFile(String)to set settings filesetForkJvm(boolean)to set forkJvm statusVerifier(String basedir, String settingsFile, boolean debug, boolean forkJvm, String[] defaultCliArguments) Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetForkJvm(boolean)to set forkJvm status andsetDefaultCliArguments(String[] defaultCliArguments)to set settings fileDeprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetMavenHome(String mavenHome)to set maven homeDeprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetDefaultCliArguments(String[] defaultCliArguments)to set default cliArgumentsVerifier(String basedir, String settingsFile, boolean debug, String mavenHome, String[] defaultCliArguments) Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetMavenHome(String mavenHome)to set maven homesetDefaultCliArguments(String[] defaultCliArguments)to set settings file -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCliArgument(String cliArgument) Deprecated.Add a command line argument, each argument must be set separately one by one.voidaddCliArguments(String... cliArguments) Deprecated.Add a command line arguments, each argument must be set separately one by one.voidaddCliOption(String option) Deprecated.please useaddCliArgument(String)voiddeleteArtifact(String org, String name, String version, String ext) Deprecated.voiddeleteArtifacts(String gid) Deprecated.Deletes all artifacts in the specified group id from the local repository.voiddeleteArtifacts(String gid, String aid, String version) Deprecated.Deletes all artifacts in the specified g:a:v from the local repository.voiddeleteDirectory(String path) Deprecated.Deletes the specified directory.voidDeprecated.will be removed without replacementvoidexecute()Deprecated.Execute Maven.voidexecuteGoal(String goal) Deprecated.will be removed.voidexecuteGoal(String goal, Map<String, String> envVars) Deprecated.will be removed.voidexecuteGoals(List<String> goals) Deprecated.will be removedvoidDeprecated.will be removedfilterFile(String srcPath, String dstPath, String fileEncoding) Deprecated.Filters a text file by replacing some user-defined tokens.Deprecated.Filters a text file by replacing some user-defined tokens.filterFile(String srcPath, String dstPath, String fileEncoding, Properties filterProperties) Deprecated.getArtifactFileNameList(String org, String name, String version, String ext) Deprecated.getArtifactMetadataPath(String gid, String aid) Deprecated.Gets the path to the local artifact metadata.getArtifactMetadataPath(String gid, String aid, String version) Deprecated.Gets the path to the local artifact metadata.getArtifactMetadataPath(String gid, String aid, String version, String filename) Deprecated.Gets the path to a file in the local artifact directory.getArtifactPath(String groupId, String artifactId, String version, String ext) Deprecated.Deprecated.Returns the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier.Deprecated.Deprecated.will be removed without replacement, for arguments adding please useaddCliArgument(String),addCliArguments(String...)Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.Gets the name of the file used to log build output.protected org.apache.maven.shared.verifier.MavenLaunchergetMavenLauncher(Map<String, String> envVars) Deprecated.Deprecated.Deprecated.Deprecated.booleanDeprecated.booleanDeprecated.booleanDeprecated.will be removed without replacementDeprecated.Deprecated.Deprecated.Loads the (non-empty) lines of the specified text file.loadProperties(String filename) Deprecated.Deprecated.Gets a new copy of the default filter map.Deprecated.voidDeprecated.will be removed without replacementvoidsetAutoclean(boolean autoclean) Deprecated.Clean project before execution by addingCLEAN_CLI_ARGUMENTto command line.voidsetCliOptions(List<String> cliOptions) Deprecated.will be removedvoidsetDebug(boolean debug) Deprecated.will be removed without replacementvoidsetDebugJvm(boolean debugJvm) Deprecated.voidsetDefaultCliArguments(String[] defaultCliArguments) Deprecated.voidsetEnvironmentVariable(String key, String value) Deprecated.voidsetEnvironmentVariables(Map<String, String> environmentVariables) Deprecated.voidsetForkJvm(boolean forkJvm) Deprecated.voidsetForkMode(String forkMode) Deprecated.voidsetLocalRepo(String localRepo) Deprecated.voidsetLocalRepoLayout(String localRepoLayout) Deprecated.voidsetLogFile(File logFile) Deprecated.voidsetLogFileName(String logFileName) Deprecated.Sets the name of the file used to log build output.voidsetMavenDebug(boolean mavenDebug) Deprecated.will be removed without replacement.voidsetMavenHome(String mavenHome) Deprecated.voidsetSettingsFile(String settingsFile) Deprecated.voidsetSystemProperties(Properties systemProperties) Deprecated.voidsetSystemProperty(String key, String value) Deprecated.voidsetUseWrapper(boolean useWrapper) Deprecated.voidsetVerifierProperties(Properties verifierProperties) Deprecated.static StringDeprecated.voidverify(boolean chokeOnErrorOutput) Deprecated.voidverifyArtifactContent(String groupId, String artifactId, String version, String ext, String content) Deprecated.Verifies that the artifact given by its Maven coordinates exists and contains the given content.voidverifyArtifactNotPresent(String groupId, String artifactId, String version, String ext) Deprecated.Verifies that the artifact given through its Maven coordinates does not exist.voidverifyArtifactPresent(String groupId, String artifactId, String version, String ext) Deprecated.Verifies that the artifact given through its Maven coordinates exists.voidDeprecated.voidverifyFileContentMatches(String file, String regex) Deprecated.Verifies the given file's content matches an regular expression.voidverifyFileNotPresent(String file) Deprecated.Verifies that the given file does not exist.voidverifyFilePresent(String file) Deprecated.Verifies that the given file exists.voidverifyTextInLog(String text) Deprecated.Throws an exception if the text is not present in the log.voidDeprecated.Writes a text file with the specified contents.
-
Field Details
-
USER_HOME
Deprecated. -
USER_MAVEN_CONFIGURATION_HOME
Deprecated. -
DEFAULT_USER_SETTINGS_FILE
Deprecated. -
DEFAULT_GLOBAL_SETTINGS_FILE
Deprecated.
-
-
Constructor Details
-
Verifier
Deprecated.- Throws:
VerificationException
-
Verifier
Deprecated.to be removed use- Throws:
VerificationException
-
Verifier
Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings file
- Throws:
VerificationException
-
Verifier
@Deprecated public Verifier(String basedir, String settingsFile, boolean debug) throws VerificationException Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings file
- Throws:
VerificationException
-
Verifier
@Deprecated public Verifier(String basedir, String settingsFile, boolean debug, String[] defaultCliArguments) throws VerificationException Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetDefaultCliArguments(String[] defaultCliArguments)to set default cliArguments
- Throws:
VerificationException
-
Verifier
@Deprecated public Verifier(String basedir, String settingsFile, boolean debug, boolean forkJvm) throws VerificationException Deprecated.to be removed useVerifier(String)setSettingsFile(String)to set settings filesetForkJvm(boolean)to set forkJvm status
- Throws:
VerificationException
-
Verifier
@Deprecated public Verifier(String basedir, String settingsFile, boolean debug, boolean forkJvm, String[] defaultCliArguments) throws VerificationException Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetForkJvm(boolean)to set forkJvm status andsetDefaultCliArguments(String[] defaultCliArguments)to set settings file
- Throws:
VerificationException
-
Verifier
@Deprecated public Verifier(String basedir, String settingsFile, boolean debug, String mavenHome) throws VerificationException Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetMavenHome(String mavenHome)to set maven home
- Throws:
VerificationException
-
Verifier
@Deprecated public Verifier(String basedir, String settingsFile, boolean debug, String mavenHome, String[] defaultCliArguments) throws VerificationException Deprecated.to be removed useVerifier(String basedir)setSettingsFile(String settingsFile)to set settings filesetMavenHome(String mavenHome)to set maven homesetDefaultCliArguments(String[] defaultCliArguments)to set settings file
- Throws:
VerificationException
-
-
Method Details
-
setLocalRepo
Deprecated. -
resetStreams
Deprecated.will be removed without replacement -
displayStreamBuffers
Deprecated.will be removed without replacement -
verify
Deprecated.- Throws:
VerificationException
-
verifyErrorFreeLog
Deprecated.- Throws:
VerificationException
-
verifyTextInLog
Deprecated.Throws an exception if the text is not present in the log.- Parameters:
text- the text to assert present- Throws:
VerificationException- if text is not found in log
-
stripAnsi
Deprecated. -
loadProperties
Deprecated.- Throws:
VerificationException
-
loadLines
Deprecated.Loads the (non-empty) lines of the specified text file.- Parameters:
filename- The path to the text file to load, relative to the base directory, must not benull.encoding- The character encoding of the file, may benullor empty to use the platform default encoding.- Returns:
- The list of (non-empty) lines from the text file, can be empty but never
null. - Throws:
IOException- If the file could not be loaded.- Since:
- 1.2
-
loadFile
public List<String> loadFile(String basedir, String filename, boolean hasCommand) throws VerificationException Deprecated.- Throws:
VerificationException
-
loadFile
Deprecated.- Throws:
VerificationException
-
getArtifactPath
Deprecated. -
getArtifactPath
public String getArtifactPath(String gid, String aid, String version, String ext, String classifier) Deprecated.Returns the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier.- Parameters:
gid- The groupId, must not be null.aid- The artifactId, must not be null.version- The version, must not be null.ext- The extension, must not be null.classifier- The classifier, may be null to be omitted.- Returns:
- the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier, never null.
-
getArtifactFileNameList
Deprecated. -
getArtifactMetadataPath
Deprecated.Gets the path to the local artifact metadata. Note that the method does not check whether the returned path actually points to existing metadata.- Parameters:
gid- The group id, must not benull.aid- The artifact id, must not benull.version- The artifact version, may benull.- Returns:
- The (absolute) path to the local artifact metadata, never
null.
-
getArtifactMetadataPath
Deprecated.Gets the path to a file in the local artifact directory. Note that the method does not check whether the returned path actually points to an existing file.- Parameters:
gid- The group id, must not benull.aid- The artifact id, may benull.version- The artifact version, may benull.filename- The filename to use, must not benull.- Returns:
- The (absolute) path to the local artifact metadata, never
null.
-
getArtifactMetadataPath
Deprecated.Gets the path to the local artifact metadata. Note that the method does not check whether the returned path actually points to existing metadata.- Parameters:
gid- The group id, must not benull.aid- The artifact id, must not benull.- Returns:
- The (absolute) path to the local artifact metadata, never
null.
-
deleteArtifact
Deprecated.- Throws:
IOException
-
deleteArtifacts
Deprecated.Deletes all artifacts in the specified group id from the local repository.- Parameters:
gid- The group id whose artifacts should be deleted, must not benull.- Throws:
IOException- If the artifacts could not be deleted.- Since:
- 1.2
-
deleteArtifacts
Deprecated.Deletes all artifacts in the specified g:a:v from the local repository.- Parameters:
gid- The group id whose artifacts should be deleted, must not benull.aid- The artifact id whose artifacts should be deleted, must not benull.version- The (base) version whose artifacts should be deleted, must not benull.- Throws:
IOException- If the artifacts could not be deleted.- Since:
- 1.3
-
deleteDirectory
Deprecated.Deletes the specified directory.- Parameters:
path- The path to the directory to delete, relative to the base directory, must not benull.- Throws:
IOException- If the directory could not be deleted.- Since:
- 1.2
-
writeFile
Deprecated.Writes a text file with the specified contents. The contents will be encoded using UTF-8.- Parameters:
path- The path to the file, relative to the base directory, must not benull.contents- The contents to write, must not benull.- Throws:
IOException- If the file could not be written.- Since:
- 1.2
-
filterFile
Deprecated.Filters a text file by replacing some user-defined tokens. This method is equivalent to:filterFile( srcPath, dstPath, fileEncoding, verifier.newDefaultFilterMap() )- Parameters:
srcPath- The path to the input file, relative to the base directory, must not benull.dstPath- The path to the output file, relative to the base directory and possibly equal to the input file, must not benull.fileEncoding- The file encoding to use, may benullor empty to use the platform's default encoding.- Returns:
- The path to the filtered output file, never
null. - Throws:
IOException- If the file could not be filtered.- Since:
- 2.0
-
filterFile
public File filterFile(String srcPath, String dstPath, String fileEncoding, Map<String, String> filterMap) throws IOExceptionDeprecated.Filters a text file by replacing some user-defined tokens.- Parameters:
srcPath- The path to the input file, relative to the base directory, must not benull.dstPath- The path to the output file, relative to the base directory and possibly equal to the input file, must not benull.fileEncoding- The file encoding to use, may benullor empty to use the platform's default encoding.filterMap- The mapping from tokens to replacement values, must not benull.- Returns:
- The path to the filtered output file, never
null. - Throws:
IOException- If the file could not be filtered.- Since:
- 1.2
-
filterFile
@Deprecated public File filterFile(String srcPath, String dstPath, String fileEncoding, Properties filterProperties) throws IOException Deprecated.There are 226 references to this method in Maven core ITs. In most (all?) cases it is used together withnewDefaultFilterProperties(). Need to remove both methods and update all clients eventually/- Parameters:
srcPath- The path to the input file, relative to the base directory, must not benull.dstPath- The path to the output file, relative to the base directory and possibly equal to the input file, must not benull.fileEncoding- The file encoding to use, may benullor empty to use the platform's default encoding.filterProperties- The mapping from tokens to replacement values, must not benull.- Returns:
- The path to the filtered output file, never
null. - Throws:
IOException- If the file could not be filtered.
-
newDefaultFilterProperties
Deprecated.Gets a new copy of the default filter properties. These default filter properties map the tokens "@basedir@" and "@baseurl@" to the test's base directory and its basefile:URL, respectively.- Returns:
- The (modifiable) map with the default filter properties, never
null. - Since:
- 1.2
-
newDefaultFilterMap
Deprecated.Gets a new copy of the default filter map. These default filter map, contains the tokens "@basedir@" and "@baseurl@" to the test's base directory and its basefile:URL, respectively.- Returns:
- The (modifiable) map with the default filter map, never
null. - Since:
- 2.0
-
verifyFilePresent
Deprecated.Verifies that the given file exists.- Parameters:
file- the path of the file to check- Throws:
VerificationException- in case the given file does not exist
-
verifyFileContentMatches
Deprecated.Verifies the given file's content matches an regular expression. Note this method also checks that the file exists and is readable.- Parameters:
file- the path of the file to checkregex- a regular expression- Throws:
VerificationException- in case the file was not found or its content does not match the given pattern- See Also:
-
verifyFileNotPresent
Deprecated.Verifies that the given file does not exist.- Parameters:
file- the path of the file to check- Throws:
VerificationException- if the given file exists
-
verifyArtifactPresent
public void verifyArtifactPresent(String groupId, String artifactId, String version, String ext) throws VerificationException Deprecated.Verifies that the artifact given through its Maven coordinates exists.- Parameters:
groupId- the groupId of the artifact (must not be null)artifactId- the artifactId of the artifact (must not be null)version- the version of the artifact (must not be null)ext- the extension of the artifact (must not be null)- Throws:
VerificationException- if the given artifact does not exist
-
verifyArtifactNotPresent
public void verifyArtifactNotPresent(String groupId, String artifactId, String version, String ext) throws VerificationException Deprecated.Verifies that the artifact given through its Maven coordinates does not exist.- Parameters:
groupId- the groupId of the artifact (must not be null)artifactId- the artifactId of the artifact (must not be null)version- the version of the artifact (must not be null)ext- the extension of the artifact (must not be null)- Throws:
VerificationException- if the given artifact exists
-
executeGoal
Deprecated.will be removed.For replacement please use:
verifier.addCliArgument( "goal" ); verifier.execute();
Execute Maven.- Throws:
VerificationException
-
executeGoal
@Deprecated public void executeGoal(String goal, Map<String, String> envVars) throws VerificationExceptionDeprecated.will be removed.For replacement please use:
verifier.addCliArgument( "goal" ); verifier.setEnvironmentVariable( "key1", "value1" ); verifier.setEnvironmentVariable( "key2", "value2" ); verifier.execute();
Execute Maven.- Throws:
VerificationException
-
executeGoals
Deprecated.will be removedFor replacement please use:
verifier.addCliArguments( "goal1", "goal2" ); verifier.execute();
Execute Maven.- Throws:
VerificationException
-
getExecutable
Deprecated. -
executeGoals
@Deprecated public void executeGoals(List<String> goals, Map<String, String> envVars) throws VerificationExceptionDeprecated.will be removedFor replacement please use:
verifier.addCliArguments( "goal1", "goal2" ); verifier.setEnvironmentVariable( "key1", "value1" ); verifier.setEnvironmentVariable( "key2", "value2" ); verifier.execute();
Execute Maven.- Throws:
VerificationException
-
execute
Deprecated.Execute Maven.- Throws:
VerificationException
-
getMavenLauncher
protected org.apache.maven.shared.verifier.MavenLauncher getMavenLauncher(Map<String, String> envVars) throws org.apache.maven.shared.verifier.LauncherExceptionDeprecated.- Throws:
org.apache.maven.shared.verifier.LauncherException
-
getMavenVersion
Deprecated.- Throws:
VerificationException
-
verifyArtifactContent
public void verifyArtifactContent(String groupId, String artifactId, String version, String ext, String content) throws IOException, VerificationException Deprecated.Verifies that the artifact given by its Maven coordinates exists and contains the given content.- Parameters:
groupId- the groupId of the artifact (must not be null)artifactId- the artifactId of the artifact (must not be null)version- the version of the artifact (must not be null)ext- the extension of the artifact (must not be null)content- the expected content- Throws:
IOException- if reading from the artifact failsVerificationException- if the content of the artifact differs
-
getCliOptions
Deprecated.will be removed without replacement, for arguments adding please useaddCliArgument(String),addCliArguments(String...) -
setCliOptions
Deprecated.will be removed -
addCliOption
Deprecated.please useaddCliArgument(String)Add a command line argument, each argument must be set separately one by one.${basedir}in argument will be replaced by value ofgetBasedir()during execution.- Parameters:
option- an argument to add
-
addCliArgument
Deprecated.Add a command line argument, each argument must be set separately one by one.${basedir}in argument will be replaced by value ofgetBasedir()during execution.- Parameters:
cliArgument- an argument to add
-
addCliArguments
Deprecated.Add a command line arguments, each argument must be set separately one by one.${basedir}in argument will be replaced by value ofgetBasedir()during execution.- Parameters:
cliArguments- an arguments list to add
-
getSystemProperties
Deprecated. -
setSystemProperties
Deprecated. -
setSystemProperty
Deprecated. -
getEnvironmentVariables
Deprecated. -
setEnvironmentVariables
Deprecated. -
setEnvironmentVariable
Deprecated. -
getVerifierProperties
Deprecated. -
setVerifierProperties
Deprecated. -
isAutoclean
public boolean isAutoclean()Deprecated. -
setAutoclean
public void setAutoclean(boolean autoclean) Deprecated.Clean project before execution by addingCLEAN_CLI_ARGUMENTto command line.By default, options is enabled.
- Parameters:
autoclean- indicate if option is enabled
-
getBasedir
Deprecated. -
getLogFileName
Deprecated.Gets the name of the file used to log build output.- Returns:
- The name of the log file, relative to the base directory, never
null. - Since:
- 1.2
-
setLogFileName
Deprecated.Sets the name of the file used to log build output.- Parameters:
logFileName- The name of the log file, relative to the base directory, must not be empty ornull.- Since:
- 1.2
-
setLogFile
Deprecated.- Parameters:
logFile- configure the log file used to log build output- Since:
- 2.0 ish (not really sure if this will be this)
-
getLogFile
Deprecated.- Returns:
- The log file used to log build output
- Since:
- 2.0 ish (not really sure if this will be this)
-
setDebug
Deprecated.will be removed without replacement -
isMavenDebug
Deprecated.will be removed without replacement -
setMavenDebug
Deprecated.will be removed without replacement.For replacement please use:verifier.addCliArgument( "-X" ); -
setForkJvm
public void setForkJvm(boolean forkJvm) Deprecated. -
isDebugJvm
public boolean isDebugJvm()Deprecated. -
setDebugJvm
public void setDebugJvm(boolean debugJvm) Deprecated. -
getLocalRepoLayout
Deprecated. -
setLocalRepoLayout
Deprecated. -
getLocalRepository
Deprecated. -
setMavenHome
Deprecated. -
setForkMode
Deprecated. -
setUseWrapper
public void setUseWrapper(boolean useWrapper) Deprecated. -
setSettingsFile
Deprecated.- Throws:
VerificationException
-
setDefaultCliArguments
Deprecated.
-
org.apache.maven.executor:maven-executor) instead. See Migration Guide.