public final class Utils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Utils.CLI |
| Modifier and Type | Field and Description |
|---|---|
static String |
EXTENSION_ARTIFACT_ID |
static String |
EXTENSION_FLATTEN |
static String |
EXTENSION_FORCE_COMPUTATION |
static String |
EXTENSION_GROUP_ID |
static String |
EXTENSION_PREFIX |
static String |
EXTENSION_SKIP |
static String |
EXTENSION_USE_VERSION |
static String |
PROJECT_VERSION |
static String |
SESSION_MAVEN_PROPERTIES_KEY |
| Modifier and Type | Method and Description |
|---|---|
static void |
attachModifiedPomFilesToTheProject(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 void |
changeBaseDir(org.apache.maven.project.MavenProject project,
File initialBaseDir)
Changes basedir(dangerous).
|
static File |
createPomDumpFile()
Creates temporary file to save updated pom mode.
|
static void |
failAsOldMechanism(Consumer<? super CharSequence> logger)
fail the build by throwing a
MavenExecutionException and logging a failure message. |
static void |
fillPropertiesFromMetadatas(Properties properties,
gg.nils.semanticrelease.versioncontrol.VersionControlProvider provider,
org.codehaus.plexus.logging.Logger logger)
Fill properties from meta data.
|
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()). |
static org.apache.maven.model.Model |
loadInitialModel(File pomFile)
Loads initial model from pom file.
|
static String |
normalizeSystemPropertyName(String mavenPropertyName)
Derives an IEEE Std 1003.1-2001 compliant property name by replacing all non-compliant
characters with underscore.
|
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.
|
static boolean |
shouldSkip(org.apache.maven.execution.MavenSession session)
Tells if this semantic-release extension should be skipped for the given maven session execution.
|
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.
|
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.
|
static void |
writeModelPom(org.apache.maven.model.Model mavenModel,
File pomFile)
Writes updated model to temporary pom file.
|
public static final String EXTENSION_PREFIX
public static final String EXTENSION_GROUP_ID
public static final String EXTENSION_ARTIFACT_ID
public static final String EXTENSION_SKIP
public static final String EXTENSION_FORCE_COMPUTATION
public static final String EXTENSION_FLATTEN
public static final String EXTENSION_USE_VERSION
public static final String SESSION_MAVEN_PROPERTIES_KEY
public static final String PROJECT_VERSION
public static org.apache.maven.model.Model loadInitialModel(File pomFile) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException
pomFile - pomFile.IOException - IOException.org.codehaus.plexus.util.xml.pull.XmlPullParserException - XmlPullParserException.public static File createPomDumpFile() throws IOException
IOException - IOException.public static void writeModelPom(org.apache.maven.model.Model mavenModel,
File pomFile)
throws IOException
mavenModel - mavenModel.pomFile - pomFile.IOException - IOException.public static void changeBaseDir(org.apache.maven.project.MavenProject project,
File initialBaseDir)
throws NoSuchFieldException,
IllegalAccessException
project - project.initialBaseDir - initialBaseDir.NoSuchFieldException - NoSuchFieldException.IllegalAccessException - IllegalAccessException.public static void setProjectPomFile(org.apache.maven.project.MavenProject project,
File newPom,
org.codehaus.plexus.logging.Logger logger)
project - the project to change the pomnewPom - the pom file to set on the projectlogger - a logger to usepublic static void fillPropertiesFromMetadatas(Properties properties, gg.nils.semanticrelease.versioncontrol.VersionControlProvider provider, org.codehaus.plexus.logging.Logger logger)
properties - properties.provider - logger - logger.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
projects - projects.gavs - list of registered GAVs of modified projects.version - the version to setlogger - the logger to report toIOException - if project model cannot be read correctlyorg.codehaus.plexus.util.xml.pull.XmlPullParserException - if project model cannot be interpreted correctlypublic static void failAsOldMechanism(Consumer<? super CharSequence> logger) throws org.apache.maven.MavenExecutionException
MavenExecutionException and logging a failure message.logger - the logger to log informationorg.apache.maven.MavenExecutionException - to make the build failpublic static boolean shouldSkip(org.apache.maven.execution.MavenSession session)
mvn -Dsemantic-release.skip=true/false
The value of the property is evaluated using @Boolean.parseBoolean(String).
session - a running maven sessionpublic static boolean shouldUseFlattenPlugin(org.apache.maven.execution.MavenSession session)
mvn -Dsemantic-release.flatten=true/false
The value of the property is evaluated using @Boolean.parseBoolean(String).
session - a running maven sessionpublic static Optional<String> versionOverride(org.apache.maven.execution.MavenSession session, org.codehaus.plexus.logging.Logger logger)
session - a running maven sessionlogger - loggerpublic static Optional<String> getProperty(org.apache.maven.execution.MavenSession session, String propertyName, org.codehaus.plexus.logging.Logger logger)
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.
session - A running maven session.propertyName - The name of the property to retrieve.logger - logger.public static String normalizeSystemPropertyName(String mavenPropertyName)
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_]*`.
Copyright © 2021. All rights reserved.