eu.lindenbaum.maven.util
Class MavenUtils

java.lang.Object
  extended by eu.lindenbaum.maven.util.MavenUtils

public final class MavenUtils
extends Object

Containing utilities related to maven plugins/projects.

Author:
Tobias Schlager , Olle Törnström

Nested Class Summary
static class MavenUtils.LogLevel
          Corresponds to the log levels of Log.
 
Field Summary
static String FAT_SEPARATOR
           
static String SEPARATOR
           
 
Constructor Summary
MavenUtils()
           
 
Method Summary
static org.apache.maven.artifact.versioning.VersionRange createVersionRange(String versionSpec)
          Returns a VersionRange from a given string specification.
static org.apache.maven.artifact.Artifact getArtifact(org.apache.maven.artifact.Artifact from, String version, MavenComponents components)
          Returns an Artifact object of a specific Artifact with a specific version.
static File getArtifactFile(org.apache.maven.artifact.Artifact artifact, MavenComponents components)
          Returns an (existing) file pointing to an Artifact of an ArtifactRepository.
static Set<String> getArtifactIds(Collection<org.apache.maven.artifact.Artifact> artifacts)
          Converts a Collection of Artifacts into a Set containing their artifactIds.
static Set<org.apache.maven.artifact.Artifact> getArtifacts(org.apache.maven.project.MavenProject project)
          Returns the transitive dependency artifacts of a project using MavenProject.getArtifacts().
static Set<org.apache.maven.artifact.versioning.ArtifactVersion> getAvailableVersions(org.apache.maven.artifact.Artifact artifact, MavenComponents components)
          Returns a Set of available versions for an artifact in the given repositories.
static Set<org.apache.maven.artifact.Artifact> getDependencies(org.apache.maven.project.MavenProject project)
          Returns the direct dependency artifacts of a project using MavenProject.getDependencyArtifacts().
static Set<org.apache.maven.artifact.Artifact> getErlangArtifacts(org.apache.maven.project.MavenProject project)
          Returns the transitive erlang artifacts of a project using MavenProject.getArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects.
static Set<org.apache.maven.artifact.Artifact> getErlangDependencies(org.apache.maven.project.MavenProject project)
          Returns the direct erlang dependencies of a project using MavenProject.getDependencyArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects.
static Set<org.apache.maven.artifact.Artifact> getErlangDependenciesToPackage(org.apache.maven.project.MavenProject project)
          Returns the direct erlang dependencies of a project using MavenProject.getDependencyArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects.
static Set<org.apache.maven.artifact.Artifact> getErlangReleaseArtifacts(org.apache.maven.project.MavenProject project)
          Returns the transitive erlang artifacts of a project using MavenProject.getArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects.
static Set<org.apache.maven.artifact.Artifact> getForeignDependencies(org.apache.maven.project.MavenProject project)
          Returns the direct non-erlang dependencies of a project using MavenProject.getDependencyArtifacts().
static Set<org.apache.maven.artifact.Artifact> getForeignDependenciesToPackage(org.apache.maven.project.MavenProject project)
          Returns the direct non-erlang dependencies of a project using MavenProject.getDependencyArtifacts().
static String getReleaseName(org.apache.maven.artifact.Artifact artifact)
          Returns the release name for the given Artifact.
static void logContent(org.apache.maven.plugin.logging.Log log, MavenUtils.LogLevel level, File file)
          Logs the absolute path of a file along with its content using a specific logger.
static void logMultiLineString(org.apache.maven.plugin.logging.Log log, MavenUtils.LogLevel level, String multiLineString)
          Logs a multi line string containing either unix or windows style line breaks using a specific logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static String SEPARATOR

FAT_SEPARATOR

public static String FAT_SEPARATOR
Constructor Detail

MavenUtils

public MavenUtils()
Method Detail

getAvailableVersions

public static Set<org.apache.maven.artifact.versioning.ArtifactVersion> getAvailableVersions(org.apache.maven.artifact.Artifact artifact,
                                                                                             MavenComponents components)
                                                                                      throws org.apache.maven.plugin.MojoExecutionException
Returns a Set of available versions for an artifact in the given repositories.

Parameters:
artifact - to lookup in the repository
components - a bean holding maven specific components
Returns:
a non-null Set of ArtifactVersions
Throws:
org.apache.maven.plugin.MojoExecutionException

getArtifactFile

public static File getArtifactFile(org.apache.maven.artifact.Artifact artifact,
                                   MavenComponents components)
                            throws org.apache.maven.plugin.MojoExecutionException
Returns an (existing) file pointing to an Artifact of an ArtifactRepository. The artifact will first be resolved.

Parameters:
artifact - to lookup in the repository
components - a bean holding maven specific components
Returns:
an existing file pointing to an artifact
Throws:
org.apache.maven.plugin.MojoExecutionException

getArtifact

public static org.apache.maven.artifact.Artifact getArtifact(org.apache.maven.artifact.Artifact from,
                                                             String version,
                                                             MavenComponents components)
Returns an Artifact object of a specific Artifact with a specific version.

Parameters:
from - to clone
version - of the returned artifact
components - a bean holding maven specific components
Returns:
a new Artifact with the requested version

createVersionRange

public static org.apache.maven.artifact.versioning.VersionRange createVersionRange(String versionSpec)
                                                                            throws org.apache.maven.plugin.MojoExecutionException
Returns a VersionRange from a given string specification.

Parameters:
versionSpec - to create a VersionRange from
Returns:
a version range object
Throws:
org.apache.maven.plugin.MojoExecutionException - if specification is invalid

getArtifactIds

public static Set<String> getArtifactIds(Collection<org.apache.maven.artifact.Artifact> artifacts)
Converts a Collection of Artifacts into a Set containing their artifactIds.

Parameters:
artifacts - to get the artifactIds from
Returns:
a non-null Set object containing artifactIds.

getReleaseName

public static String getReleaseName(org.apache.maven.artifact.Artifact artifact)
Returns the release name for the given Artifact. The release name consists of the artifacts id and its version.

Parameters:
artifact - to retrieve the release name from
Returns:
a string containing the release name

getErlangReleaseArtifacts

public static Set<org.apache.maven.artifact.Artifact> getErlangReleaseArtifacts(org.apache.maven.project.MavenProject project)
Returns the transitive erlang artifacts of a project using MavenProject.getArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects. This will return all Artifact with scopes other than test and provided.

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getErlangDependenciesToPackage

public static Set<org.apache.maven.artifact.Artifact> getErlangDependenciesToPackage(org.apache.maven.project.MavenProject project)
Returns the direct erlang dependencies of a project using MavenProject.getDependencyArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects. This will return all Artifact with scopes other than test and provided.

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getErlangArtifacts

public static Set<org.apache.maven.artifact.Artifact> getErlangArtifacts(org.apache.maven.project.MavenProject project)
Returns the transitive erlang artifacts of a project using MavenProject.getArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects.

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getErlangDependencies

public static Set<org.apache.maven.artifact.Artifact> getErlangDependencies(org.apache.maven.project.MavenProject project)
Returns the direct erlang dependencies of a project using MavenProject.getDependencyArtifacts() filtered for PackagingType.ERLANG_OTP and PackagingType.ERLANG_STD packaged projects.

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getForeignDependenciesToPackage

public static Set<org.apache.maven.artifact.Artifact> getForeignDependenciesToPackage(org.apache.maven.project.MavenProject project)
Returns the direct non-erlang dependencies of a project using MavenProject.getDependencyArtifacts(). All erlang artifacts will be filtered out. This will return all Artifact with scopes other than test and provided.

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getForeignDependencies

public static Set<org.apache.maven.artifact.Artifact> getForeignDependencies(org.apache.maven.project.MavenProject project)
Returns the direct non-erlang dependencies of a project using MavenProject.getDependencyArtifacts(). All erlang artifacts will be filtered out.

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getDependencies

public static Set<org.apache.maven.artifact.Artifact> getDependencies(org.apache.maven.project.MavenProject project)
Returns the direct dependency artifacts of a project using MavenProject.getDependencyArtifacts().

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

getArtifacts

public static Set<org.apache.maven.artifact.Artifact> getArtifacts(org.apache.maven.project.MavenProject project)
Returns the transitive dependency artifacts of a project using MavenProject.getArtifacts().

Parameters:
project - to get the dependencies for
Returns:
a non-null Set of dependency artifacts

logContent

public static void logContent(org.apache.maven.plugin.logging.Log log,
                              MavenUtils.LogLevel level,
                              File file)
Logs the absolute path of a file along with its content using a specific logger.

Parameters:
log - logger to use
level - priority to log the file
file - to read the content from

logMultiLineString

public static void logMultiLineString(org.apache.maven.plugin.logging.Log log,
                                      MavenUtils.LogLevel level,
                                      String multiLineString)
Logs a multi line string containing either unix or windows style line breaks using a specific logger.

Parameters:
log - logger to use.
level - priority to log the message
multiLineString - to log


Copyright © 2011 Lindenbaum GmbH. All Rights Reserved.