Package net.microfalx.talos.core
Class MavenUtils
java.lang.Object
net.microfalx.talos.core.MavenUtils
Various Maven utilities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDuration(long duration) Formats duration Maven style.static StringformatDuration(Duration duration) Formats duration Maven style.static StringformatDuration(Duration duration, boolean brackets) Formats duration Maven style.static StringformatDuration(Duration duration, boolean brackets, boolean padding) Formats duration Maven style.static StringformatInteger(int value, int length) Returns a formatted integer, left padded.static StringformatInteger(int value, int length, boolean digits) Returns a formatted integer, left padded.static StringformatMemory(long used, long maximum) Formats memory usage as a string.static StringgetGoal(org.apache.maven.plugin.MojoExecution execution) Returns the goal executed for a given Mojo.static StringgetId(org.apache.maven.artifact.Artifact artifact) Returns the identifier of an artifact.static StringgetId(org.apache.maven.model.Dependency dependency) Returns the identifier of a dependency.static StringgetId(org.apache.maven.model.Plugin plugin) Returns the identifier of a plugin.static StringgetId(org.apache.maven.plugin.Mojo mojo) Returns the identifier of a mojo.static StringgetId(org.apache.maven.project.MavenProject project) Returns the identifier of a project.static StringgetId(org.eclipse.aether.artifact.Artifact artifact) Returns the identifier of an artifact.static StringgetId(org.eclipse.aether.metadata.Metadata metadata) Returns the identifier of an artifact.static StringgetName(org.apache.maven.plugin.Mojo mojo) Returns the name of the Mojo.static booleangetProperty(org.apache.maven.execution.MavenSession session, String name, boolean defaultValue) Returns a property value as a boolean.static intgetProperty(org.apache.maven.execution.MavenSession session, String name, int defaultValue) Returns a property value as an integer.static StringgetProperty(org.apache.maven.execution.MavenSession session, String name, String defaultValue) Returns a property or environment variable value.static DurationgetProperty(org.apache.maven.execution.MavenSession session, String name, Duration defaultValue) Returns a property value as a Duration.static Collection<URI> getRemoteRepositories(org.apache.maven.execution.MavenSession session) Returns the remote repositories.static booleanReturns whether a known logger to intercept is available.static booleanReturns whether the Maven logger is available.static booleanReturns whether the name indicates a property which stores secrets.static StringReturns a left padded (with spaces) text.static StringReturns a left padded (with spaces) text.static StringmaskSecret(String name, String value) Masks the value the name indicates a property which stores secrets.static voidregisterName(String mojoClass, String name) Registers a name for a Mojo.
-
Field Details
-
METRICS
public static net.microfalx.metrics.Metrics METRICS -
ZERO_DURATION
- See Also:
-
-
Constructor Details
-
MavenUtils
public MavenUtils()
-
-
Method Details
-
isLoggerAvailable
public static boolean isLoggerAvailable()Returns whether a known logger to intercept is available.- Returns:
trueif Maven logger,falseotherwise
-
isMavenLoggerAvailable
public static boolean isMavenLoggerAvailable()Returns whether the Maven logger is available.- Returns:
trueif Maven logger,falseotherwise
-
getId
Returns the identifier of an artifact.- Parameters:
artifact- the artifact- Returns:
- a non-null instance
-
getId
Returns the identifier of an artifact.- Parameters:
artifact- the artifact- Returns:
- a non-null instance
-
getId
Returns the identifier of a dependency.- Parameters:
dependency- the dependency- Returns:
- a non-null instance
-
getId
Returns the identifier of a plugin.- Parameters:
plugin- the plugin- Returns:
- a non-null instance
-
getId
Returns the identifier of a mojo.- Parameters:
mojo- the Mojo- Returns:
- a non-null instance
-
getId
Returns the identifier of a project.- Parameters:
project- the project- Returns:
- a non-null instance
-
getId
Returns the identifier of an artifact.- Parameters:
metadata- the artifact- Returns:
- a non-null instance
-
formatInteger
Returns a formatted integer, left padded.- Parameters:
value- the value to formatlength- the minimum length- Returns:
- a padded number
-
formatInteger
Returns a formatted integer, left padded.- Parameters:
value- the value to formatlength- the minimum length- Returns:
- a padded number
-
leftPad
Returns a left padded (with spaces) text.- Parameters:
text- the text to padlength- the minimum length- Returns:
- a non null padded string
-
leftPad
Returns a left padded (with spaces) text.- Parameters:
text- the text to padlength- the minimum lengthfill- the character to be used to fill the empty space- Returns:
- a non null padded string
-
formatDuration
Formats duration Maven style.- Parameters:
duration- the duration- Returns:
- the duration as string
-
formatDuration
Formats duration Maven style.- Parameters:
duration- the duration- Returns:
- the duration as string
-
formatDuration
Formats duration Maven style.- Parameters:
duration- the duration- Returns:
- the duration as string
-
formatDuration
Formats duration Maven style.- Parameters:
duration- the duration- Returns:
- the duration as string
-
formatMemory
Formats memory usage as a string.- Parameters:
used- the used memorymaximum- the maximum memory- Returns:
- a non-null instance
-
getProperty
public static Duration getProperty(org.apache.maven.execution.MavenSession session, String name, Duration defaultValue) Returns a property value as a Duration.- Parameters:
session- the sessionname- the property namedefaultValue- the default value- Returns:
- the value
- See Also:
-
getProperty
public static boolean getProperty(org.apache.maven.execution.MavenSession session, String name, boolean defaultValue) Returns a property value as a boolean.- Parameters:
session- the sessionname- the property namedefaultValue- the default value- Returns:
- the value
-
getProperty
public static int getProperty(org.apache.maven.execution.MavenSession session, String name, int defaultValue) Returns a property value as an integer.- Parameters:
session- the sessionname- the property namedefaultValue- the default value- Returns:
- the value
-
getProperty
public static String getProperty(org.apache.maven.execution.MavenSession session, String name, String defaultValue) Returns a property or environment variable value.The environment variable is created out of full property name, upper case and replacing "." with "_".
- Parameters:
session- the sessionname- the property namedefaultValue- the default value- Returns:
- the value
-
registerName
Registers a name for a Mojo.- Parameters:
mojoClass- the Mojo class.name- the name
-
getName
Returns the name of the Mojo.- Parameters:
mojo- the mojo- Returns:
- a non-null string
-
getGoal
Returns the goal executed for a given Mojo.- Parameters:
execution- the mojo execution- Returns:
- a non-null string
-
getRemoteRepositories
public static Collection<URI> getRemoteRepositories(org.apache.maven.execution.MavenSession session) Returns the remote repositories.- Parameters:
session- the session- Returns:
- a non-null collection
-
maskSecret
Masks the value the name indicates a property which stores secrets.- Parameters:
name- the property namevalue- the property value- Returns:
- the original value or a masked one
-
isSecret
Returns whether the name indicates a property which stores secrets.- Parameters:
name- the property name- Returns:
trueif it stores a secret,falseotherwise
-