Class MavenProjectHelper


  • public class MavenProjectHelper
    extends java.lang.Object
    MavenProjectHelper A class to facilitate interacting with the build time maven environment.
    • Constructor Summary

      Constructors 
      Constructor Description
      MavenProjectHelper​(org.apache.maven.project.MavenProject project, org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver artifactResolver, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories, org.apache.maven.execution.MavenSession session)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.maven.project.MavenProject getMavenProjectFor​(org.apache.maven.artifact.Artifact artifact)
      Gets the maven project represented by the artifact iff it is in the reactor.
      OverlayManager getOverlayManager()  
      java.nio.file.Path getPathFor​(org.apache.maven.artifact.Artifact artifact)
      Gets path to artifact.
      org.apache.maven.project.MavenProject getProject()  
      WarPluginInfo getWarPluginInfo()  
      java.io.File resolveArtifact​(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String type)
      Given the coordinates for an artifact, resolve the artifact from the remote repositories.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MavenProjectHelper

        public MavenProjectHelper​(org.apache.maven.project.MavenProject project,
                                  org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver artifactResolver,
                                  java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories,
                                  org.apache.maven.execution.MavenSession session)
        Parameters:
        project - the project being built
        artifactResolver - a resolve for artifacts
        remoteRepositories - repositories from which to resolve artifacts
        session - the current maven build session
    • Method Detail

      • getProject

        public org.apache.maven.project.MavenProject getProject()
      • getMavenProjectFor

        public org.apache.maven.project.MavenProject getMavenProjectFor​(org.apache.maven.artifact.Artifact artifact)
        Gets the maven project represented by the artifact iff it is in the reactor.
        Parameters:
        artifact - the artifact of the project to get
        Returns:
        MavenProject if artifact is referenced in reactor, otherwise null
      • getPathFor

        public java.nio.file.Path getPathFor​(org.apache.maven.artifact.Artifact artifact)
        Gets path to artifact. If the artifact is referenced in the reactor, returns path to ${project.build.outputDirectory}. Otherwise, returns path to location in local m2 repo. Cannot return null - maven will complain about unsatisfied dependency during project build.
        Parameters:
        artifact - maven artifact to check
        Returns:
        path to artifact
      • resolveArtifact

        public java.io.File resolveArtifact​(java.lang.String groupId,
                                            java.lang.String artifactId,
                                            java.lang.String version,
                                            java.lang.String type)
                                     throws org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException
        Given the coordinates for an artifact, resolve the artifact from the remote repositories.
        Parameters:
        groupId - the groupId of the artifact to resolve
        artifactId - the artifactId of the artifact to resolve
        version - the version of the artifact to resolve
        type - the type of the artifact to resolve
        Returns:
        a File representing the location of the artifact or null if not resolved
        Throws:
        org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException