Class Utils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidattachModifiedPomFilesToTheProject(List<org.apache.maven.project.MavenProject> projects, Set<GAV> gavs, String version, Boolean resolveProjectVersion, org.codehaus.plexus.logging.Logger logger) Attach modified POM files to the projects so install/deployed files contains new version.static voidchangeBaseDir(org.apache.maven.project.MavenProject project, File initialBaseDir) Changes basedir(dangerous).static FileCreates temporary file to save updated pom mode.static voidfailAsOldMechanism(Consumer<? super CharSequence> logger) fail the build by throwing aMavenExecutionExceptionand logging a failure message.static voidfillPropertiesFromMetadatas(Properties properties, gg.nils.semanticrelease.versioncontrol.VersionControlProvider provider, org.codehaus.plexus.logging.Logger logger) Fill properties from meta data.getProperty(org.apache.maven.execution.MavenSession session, String propertyName, org.codehaus.plexus.logging.Logger logger) Tries to get the property from the user properties (MavenSession.getUserProperties()) or from the system properties (MavenSession.getSystemProperties()).static org.apache.maven.model.ModelloadInitialModel(File pomFile) Loads initial model from pom file.static StringnormalizeSystemPropertyName(String mavenPropertyName) Derives an IEEE Std 1003.1-2001 compliant property name by replacing all non-compliant characters with underscore.static voidsetProjectPomFile(org.apache.maven.project.MavenProject project, File newPom, org.codehaus.plexus.logging.Logger logger) Changes the pom file of the given project.static booleanshouldSkip(org.apache.maven.execution.MavenSession session) Tells if this semantic-release extension should be skipped for the given maven session execution.static booleanshouldUseFlattenPlugin(org.apache.maven.execution.MavenSession session) Tells if this semantic-release extension should use maven-flatten-plugin instead of its own mechanism.versionOverride(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.logging.Logger logger) Provides the version to use if defined as user or system property.static voidwriteModelPom(org.apache.maven.model.Model mavenModel, File pomFile) Writes updated model to temporary pom file.
-
Field Details
-
EXTENSION_PREFIX
- See Also:
-
EXTENSION_GROUP_ID
- See Also:
-
EXTENSION_ARTIFACT_ID
- See Also:
-
EXTENSION_SKIP
- See Also:
-
EXTENSION_FORCE_COMPUTATION
- See Also:
-
EXTENSION_FLATTEN
- See Also:
-
EXTENSION_USE_VERSION
- See Also:
-
SESSION_MAVEN_PROPERTIES_KEY
- See Also:
-
PROJECT_VERSION
- See Also:
-
-
Method Details
-
loadInitialModel
public static org.apache.maven.model.Model loadInitialModel(File pomFile) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException Loads initial model from pom file.- Parameters:
pomFile- pomFile.- Returns:
- Model.
- Throws:
IOException- IOException.org.codehaus.plexus.util.xml.pull.XmlPullParserException- XmlPullParserException.
-
createPomDumpFile
Creates temporary file to save updated pom mode.- Returns:
- File.
- Throws:
IOException- IOException.
-
writeModelPom
public static void writeModelPom(org.apache.maven.model.Model mavenModel, File pomFile) throws IOException Writes updated model to temporary pom file.- Parameters:
mavenModel- mavenModel.pomFile- pomFile.- Throws:
IOException- IOException.
-
changeBaseDir
public static void changeBaseDir(org.apache.maven.project.MavenProject project, File initialBaseDir) throws NoSuchFieldException, IllegalAccessException Changes basedir(dangerous).- Parameters:
project- project.initialBaseDir- initialBaseDir.- Throws:
NoSuchFieldException- NoSuchFieldException.IllegalAccessException- IllegalAccessException.
-
setProjectPomFile
public static void setProjectPomFile(org.apache.maven.project.MavenProject project, File newPom, org.codehaus.plexus.logging.Logger logger) Changes the pom file of the given project.- Parameters:
project- the project to change the pomnewPom- the pom file to set on the projectlogger- a logger to use
-
fillPropertiesFromMetadatas
public static void fillPropertiesFromMetadatas(Properties properties, gg.nils.semanticrelease.versioncontrol.VersionControlProvider provider, org.codehaus.plexus.logging.Logger logger) Fill properties from meta data.- Parameters:
properties- properties.provider-logger- logger.
-
attachModifiedPomFilesToTheProject
public static void attachModifiedPomFilesToTheProject(List<org.apache.maven.project.MavenProject> projects, Set<GAV> gavs, String version, Boolean resolveProjectVersion, org.codehaus.plexus.logging.Logger logger) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException Attach modified POM files to the projects so install/deployed files contains new version.- Parameters:
projects- projects.gavs- list of registered GAVs of modified projects.version- the version to setlogger- the logger to report to- Throws:
IOException- if project model cannot be read correctlyorg.codehaus.plexus.util.xml.pull.XmlPullParserException- if project model cannot be interpreted correctly
-
failAsOldMechanism
public static void failAsOldMechanism(Consumer<? super CharSequence> logger) throws org.apache.maven.MavenExecutionException fail the build by throwing aMavenExecutionExceptionand logging a failure message.- Parameters:
logger- the logger to log information- Throws:
org.apache.maven.MavenExecutionException- to make the build fail
-
shouldSkip
public static boolean shouldSkip(org.apache.maven.execution.MavenSession session) Tells if this semantic-release extension should be skipped for the given maven session execution. To skip execution launch maven with a user propertymvn -Dsemantic-release.skip=true/falseThe value of the property is evaluated using @
Boolean.parseBoolean(String).- Parameters:
session- a running maven session- Returns:
- true if semantic-release extension should be skipped
-
shouldUseFlattenPlugin
public static boolean shouldUseFlattenPlugin(org.apache.maven.execution.MavenSession session) Tells if this semantic-release extension should use maven-flatten-plugin instead of its own mechanism. To activate flatten pluginmvn -Dsemantic-release.flatten=true/falseThe value of the property is evaluated using @
Boolean.parseBoolean(String).- Parameters:
session- a running maven session- Returns:
- true if semantic-release extension should use flatten
-
versionOverride
public static Optional<String> versionOverride(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.logging.Logger logger) Provides the version to use if defined as user or system property.- Parameters:
session- a running maven sessionlogger- logger- Returns:
- an Optional containing the version to use if the corresponding user or system property has been defined
-
getProperty
public static Optional<String> getProperty(org.apache.maven.execution.MavenSession session, String propertyName, org.codehaus.plexus.logging.Logger logger) Tries to get the property from the user properties (MavenSession.getUserProperties()) or from the system properties (MavenSession.getSystemProperties()).The variable can be defined with it's exact name or with it's IEEE Std 1003.1-2001 compliant version (
normalizeSystemPropertyName(String)).User properties have higher priority than all other properties. Environment properties have higher priority than system properties. Exact matches have higher priority than IEEE Std 1003.1-2001 compliant versions.
- Parameters:
session- A running maven session.propertyName- The name of the property to retrieve.logger- logger.- Returns:
- The value of the property of empty if it has not been defined.
-
normalizeSystemPropertyName
Derives an IEEE Std 1003.1-2001 compliant property name by replacing all non-compliant characters with underscore.In IEEE Std 1003.1-2001 it was defined that the variable name consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. Although IEEE Std 1003.1-2008 / IEEE POSIX P1003.2/ISO 9945.2 doesn't define a lexical convention for variable names, most bash implementations use `[a-zA-Z_]+[a-zA-Z0-9_]*`.
- Returns:
- A derived IEEE Std 1003.1-2001 compliant property name.
-