public class Verifier extends Object
Constructor and Description |
---|
Verifier(String basedir) |
Verifier(String basedir,
boolean debug) |
Verifier(String basedir,
String settingsFile) |
Verifier(String basedir,
String settingsFile,
boolean debug) |
Verifier(String basedir,
String settingsFile,
boolean debug,
boolean forkJvm) |
Verifier(String basedir,
String settingsFile,
boolean debug,
boolean forkJvm,
String[] defaultCliArguments) |
Verifier(String basedir,
String settingsFile,
boolean debug,
String mavenHome) |
Verifier(String basedir,
String settingsFile,
boolean debug,
String[] defaultCliArguments) |
Verifier(String basedir,
String settingsFile,
boolean debug,
String mavenHome,
String[] defaultCliArguments) |
Modifier and Type | Method and Description |
---|---|
void |
addCliArgument(String cliArgument)
Add a command line argument, each argument must be set separately one by one.
|
void |
addCliArguments(String... cliArguments)
Add a command line arguments, each argument must be set separately one by one.
|
void |
addCliOption(String option)
Deprecated.
please use
addCliArgument(String) |
void |
deleteArtifact(String org,
String name,
String version,
String ext) |
void |
deleteArtifacts(String gid)
Deletes all artifacts in the specified group id from the local repository.
|
void |
deleteArtifacts(String gid,
String aid,
String version)
Deletes all artifacts in the specified g:a:v from the local repository.
|
void |
deleteDirectory(String path)
Deletes the specified directory.
|
void |
displayStreamBuffers()
Deprecated.
will be removed without replacement
|
void |
execute()
Execute Maven.
|
void |
executeGoal(String goal)
Deprecated.
will be removed.
For replacement please use: verifier.addCliArgument( "goal" ); verifier.execute(); |
void |
executeGoal(String goal,
Map<String,String> envVars)
Deprecated.
will be removed.
For replacement please use: verifier.addCliArgument( "goal" ); verifier.setEnvironmentVariable( "key1", "value1" ); verifier.setEnvironmentVariable( "key2", "value2" ); verifier.execute(); |
void |
executeGoals(List<String> goals)
Deprecated.
will be removed
For replacement please use: verifier.addCliArguments( "goal1", "goal2" ); verifier.execute(); |
void |
executeGoals(List<String> goals,
Map<String,String> envVars)
Deprecated.
will be removed
For replacement please use: verifier.addCliArguments( "goal1", "goal2" ); verifier.setEnvironmentVariable( "key1", "value1" ); verifier.setEnvironmentVariable( "key2", "value2" ); verifier.execute(); |
File |
filterFile(String srcPath,
String dstPath,
String fileEncoding)
Filters a text file by replacing some user-defined tokens.
|
File |
filterFile(String srcPath,
String dstPath,
String fileEncoding,
Map<String,String> filterMap)
Filters a text file by replacing some user-defined tokens.
|
File |
filterFile(String srcPath,
String dstPath,
String fileEncoding,
Properties filterProperties)
Deprecated.
|
List<String> |
getArtifactFileNameList(String org,
String name,
String version,
String ext) |
String |
getArtifactMetadataPath(String gid,
String aid)
Gets the path to the local artifact metadata.
|
String |
getArtifactMetadataPath(String gid,
String aid,
String version)
Gets the path to the local artifact metadata.
|
String |
getArtifactMetadataPath(String gid,
String aid,
String version,
String filename)
Gets the path to a file in the local artifact directory.
|
String |
getArtifactPath(String groupId,
String artifactId,
String version,
String ext) |
String |
getArtifactPath(String gid,
String aid,
String version,
String ext,
String classifier)
Returns the absolute path to the artifact denoted by groupId, artifactId, version, extension and classifier.
|
String |
getBasedir() |
List<String> |
getCliOptions()
Deprecated.
will be removed without replacement,
for arguments adding please use
addCliArgument(String) , addCliArguments(String...) |
Map<String,String> |
getEnvironmentVariables() |
String |
getExecutable() |
String |
getLocalRepoLayout() |
String |
getLocalRepository() |
String |
getLogFileName()
Gets the name of the file used to log build output.
|
protected org.apache.maven.shared.verifier.MavenLauncher |
getMavenLauncher(Map<String,String> envVars) |
String |
getMavenVersion() |
Properties |
getSystemProperties() |
Properties |
getVerifierProperties() |
boolean |
isAutoclean() |
boolean |
isDebugJvm() |
boolean |
isMavenDebug()
Deprecated.
will be removed without replacement
|
List<String> |
loadFile(File file,
boolean hasCommand) |
List<String> |
loadFile(String basedir,
String filename,
boolean hasCommand) |
List<String> |
loadLines(String filename,
String encoding)
Loads the (non-empty) lines of the specified text file.
|
Properties |
loadProperties(String filename) |
Map<String,String> |
newDefaultFilterMap()
Gets a new copy of the default filter map.
|
Properties |
newDefaultFilterProperties()
Deprecated.
|
void |
resetStreams()
Deprecated.
will be removed without replacement
|
void |
setAutoclean(boolean autoclean)
Clean project before execution by adding
CLEAN_CLI_ARGUMENT to command line. |
void |
setCliOptions(List<String> cliOptions)
Deprecated.
will be removed
|
void |
setDebug(boolean debug)
Deprecated.
will be removed without replacement
|
void |
setDebugJvm(boolean debugJvm) |
void |
setEnvironmentVariable(String key,
String value) |
void |
setEnvironmentVariables(Map<String,String> environmentVariables) |
void |
setForkJvm(boolean forkJvm) |
void |
setLocalRepo(String localRepo) |
void |
setLocalRepoLayout(String localRepoLayout) |
void |
setLogFileName(String logFileName)
Sets the name of the file used to log build output.
|
void |
setMavenDebug(boolean mavenDebug)
Deprecated.
will be removed without replacement.
|
void |
setSystemProperties(Properties systemProperties) |
void |
setSystemProperty(String key,
String value) |
void |
setVerifierProperties(Properties verifierProperties) |
static String |
stripAnsi(String msg) |
void |
verify(boolean chokeOnErrorOutput) |
void |
verifyArtifactContent(String groupId,
String artifactId,
String version,
String ext,
String content)
Verifies that the artifact given by its Maven coordinates exists and contains the given content.
|
void |
verifyArtifactNotPresent(String groupId,
String artifactId,
String version,
String ext)
Verifies that the artifact given through its Maven coordinates does not exist.
|
void |
verifyArtifactPresent(String groupId,
String artifactId,
String version,
String ext)
Verifies that the artifact given through its Maven coordinates exists.
|
void |
verifyErrorFreeLog() |
void |
verifyFileContentMatches(String file,
String regex)
Verifies the given file's content matches an regular expression.
|
void |
verifyFileNotPresent(String file)
Verifies that the given file does not exist.
|
void |
verifyFilePresent(String file)
Verifies that the given file exists.
|
void |
verifyTextInLog(String text)
Throws an exception if the text is not present in the log.
|
void |
writeFile(String path,
String contents)
Writes a text file with the specified contents.
|
public Verifier(String basedir) throws VerificationException
VerificationException
public Verifier(String basedir, boolean debug) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile, boolean debug) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile, boolean debug, String[] defaultCliArguments) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile, boolean debug, boolean forkJvm) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile, boolean debug, boolean forkJvm, String[] defaultCliArguments) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile, boolean debug, String mavenHome) throws VerificationException
VerificationException
public Verifier(String basedir, String settingsFile, boolean debug, String mavenHome, String[] defaultCliArguments) throws VerificationException
VerificationException
public void setLocalRepo(String localRepo)
@Deprecated public void resetStreams()
@Deprecated public void displayStreamBuffers()
public void verify(boolean chokeOnErrorOutput) throws VerificationException
VerificationException
public void verifyErrorFreeLog() throws VerificationException
VerificationException
public void verifyTextInLog(String text) throws VerificationException
text
- the text to assert presentVerificationException
- if text is not found in logpublic Properties loadProperties(String filename) throws VerificationException
VerificationException
public List<String> loadLines(String filename, String encoding) throws IOException
filename
- The path to the text file to load, relative to the base directory, must not be null
.encoding
- The character encoding of the file, may be null
or empty to use the platform default
encoding.null
.IOException
- If the file could not be loaded.public List<String> loadFile(String basedir, String filename, boolean hasCommand) throws VerificationException
VerificationException
public List<String> loadFile(File file, boolean hasCommand) throws VerificationException
VerificationException
public String getArtifactPath(String groupId, String artifactId, String version, String ext)
public String getArtifactPath(String gid, String aid, String version, String ext, String classifier)
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.public List<String> getArtifactFileNameList(String org, String name, String version, String ext)
public String getArtifactMetadataPath(String gid, String aid, String version)
gid
- The group id, must not be null
.aid
- The artifact id, must not be null
.version
- The artifact version, may be null
.null
.public String getArtifactMetadataPath(String gid, String aid, String version, String filename)
gid
- The group id, must not be null
.aid
- The artifact id, may be null
.version
- The artifact version, may be null
.filename
- The filename to use, must not be null
.null
.public String getArtifactMetadataPath(String gid, String aid)
gid
- The group id, must not be null
.aid
- The artifact id, must not be null
.null
.public void deleteArtifact(String org, String name, String version, String ext) throws IOException
IOException
public void deleteArtifacts(String gid) throws IOException
gid
- The group id whose artifacts should be deleted, must not be null
.IOException
- If the artifacts could not be deleted.public void deleteArtifacts(String gid, String aid, String version) throws IOException
gid
- The group id whose artifacts should be deleted, must not be null
.aid
- The artifact id whose artifacts should be deleted, must not be null
.version
- The (base) version whose artifacts should be deleted, must not be null
.IOException
- If the artifacts could not be deleted.public void deleteDirectory(String path) throws IOException
path
- The path to the directory to delete, relative to the base directory, must not be null
.IOException
- If the directory could not be deleted.public void writeFile(String path, String contents) throws IOException
path
- The path to the file, relative to the base directory, must not be null
.contents
- The contents to write, must not be null
.IOException
- If the file could not be written.public File filterFile(String srcPath, String dstPath, String fileEncoding) throws IOException
filterFile( srcPath, dstPath, fileEncoding, verifier.newDefaultFilterMap() )
srcPath
- The path to the input file, relative to the base directory, must not be
null
.dstPath
- The path to the output file, relative to the base directory and possibly equal to the
input file, must not be null
.fileEncoding
- The file encoding to use, may be null
or empty to use the platform's default
encoding.null
.IOException
- If the file could not be filtered.public File filterFile(String srcPath, String dstPath, String fileEncoding, Map<String,String> filterMap) throws IOException
srcPath
- The path to the input file, relative to the base directory, must not be
null
.dstPath
- The path to the output file, relative to the base directory and possibly equal to the
input file, must not be null
.fileEncoding
- The file encoding to use, may be null
or empty to use the platform's default
encoding.filterMap
- The mapping from tokens to replacement values, must not be null
.null
.IOException
- If the file could not be filtered.@Deprecated public File filterFile(String srcPath, String dstPath, String fileEncoding, Properties filterProperties) throws IOException
filterFile(String, String, String, Map)
newDefaultFilterProperties()
. Need to remove both methods and update all clients eventually/srcPath
- The path to the input file, relative to the base directory, must not be
null
.dstPath
- The path to the output file, relative to the base directory and possibly equal to the
input file, must not be null
.fileEncoding
- The file encoding to use, may be null
or empty to use the platform's default
encoding.filterProperties
- The mapping from tokens to replacement values, must not be null
.null
.IOException
- If the file could not be filtered.@Deprecated public Properties newDefaultFilterProperties()
newDefaultFilterMap()
file:
URL, respectively.null
.public Map<String,String> newDefaultFilterMap()
file:
URL, respectively.null
.public void verifyFilePresent(String file) throws VerificationException
file
- the path of the file to checkVerificationException
- in case the given file does not existpublic void verifyFileContentMatches(String file, String regex) throws VerificationException
file
- the path of the file to checkregex
- a regular expressionVerificationException
- in case the file was not found or its content does not match the given patternPattern
public void verifyFileNotPresent(String file) throws VerificationException
file
- the path of the file to checkVerificationException
- if the given file existspublic void verifyArtifactPresent(String groupId, String artifactId, String version, String ext) throws VerificationException
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)VerificationException
- if the given artifact does not existpublic void verifyArtifactNotPresent(String groupId, String artifactId, String version, String ext) throws VerificationException
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)VerificationException
- if the given artifact exists@Deprecated public void executeGoal(String goal) throws VerificationException
For replacement please use:
verifier.addCliArgument( "goal" ); verifier.execute();
VerificationException
@Deprecated public void executeGoal(String goal, Map<String,String> envVars) throws VerificationException
For replacement please use:
verifier.addCliArgument( "goal" ); verifier.setEnvironmentVariable( "key1", "value1" ); verifier.setEnvironmentVariable( "key2", "value2" ); verifier.execute();
VerificationException
@Deprecated public void executeGoals(List<String> goals) throws VerificationException
For replacement please use:
verifier.addCliArguments( "goal1", "goal2" ); verifier.execute();
VerificationException
public String getExecutable()
@Deprecated public void executeGoals(List<String> goals, Map<String,String> envVars) throws VerificationException
For replacement please use:
verifier.addCliArguments( "goal1", "goal2" ); verifier.setEnvironmentVariable( "key1", "value1" ); verifier.setEnvironmentVariable( "key2", "value2" ); verifier.execute();
VerificationException
public void execute() throws VerificationException
VerificationException
protected org.apache.maven.shared.verifier.MavenLauncher getMavenLauncher(Map<String,String> envVars) throws org.apache.maven.shared.verifier.LauncherException
org.apache.maven.shared.verifier.LauncherException
public String getMavenVersion() throws VerificationException
VerificationException
public void verifyArtifactContent(String groupId, String artifactId, String version, String ext, String content) throws IOException, VerificationException
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 contentIOException
- if reading from the artifact failsVerificationException
- if the content of the artifact differs@Deprecated public List<String> getCliOptions()
addCliArgument(String)
, addCliArguments(String...)
@Deprecated public void setCliOptions(List<String> cliOptions)
@Deprecated public void addCliOption(String option)
addCliArgument(String)
${basedir}
in argument will be replaced by value of getBasedir()
during execution.
option
- an argument to addpublic void addCliArgument(String cliArgument)
${basedir}
in argument will be replaced by value of getBasedir()
during execution.
cliArgument
- an argument to addpublic void addCliArguments(String... cliArguments)
${basedir}
in argument will be replaced by value of getBasedir()
during execution.
cliArguments
- an arguments list to addpublic Properties getSystemProperties()
public void setSystemProperties(Properties systemProperties)
public void setEnvironmentVariables(Map<String,String> environmentVariables)
public Properties getVerifierProperties()
public void setVerifierProperties(Properties verifierProperties)
public boolean isAutoclean()
public void setAutoclean(boolean autoclean)
CLEAN_CLI_ARGUMENT
to command line.
By default, options is enabled.
autoclean
- indicate if option is enabledpublic String getBasedir()
public String getLogFileName()
null
.public void setLogFileName(String logFileName)
logFileName
- The name of the log file, relative to the base directory, must not be empty or
null
.@Deprecated public void setDebug(boolean debug)
@Deprecated public boolean isMavenDebug()
@Deprecated public void setMavenDebug(boolean mavenDebug)
verifier.addCliArgument( "-X" );
public void setForkJvm(boolean forkJvm)
public boolean isDebugJvm()
public void setDebugJvm(boolean debugJvm)
public String getLocalRepoLayout()
public void setLocalRepoLayout(String localRepoLayout)
public String getLocalRepository()
Copyright © 2002–2022 The Apache Software Foundation. All rights reserved.