Class MavenResolver


  • public class MavenResolver
    extends Object
    Resolves Maven Artifacts either from a remote repository or from a local POM file.
    Since:
    10.9
    Version:
    $Id: b8fe2bd39560400ccc1ce8ccfb57aa6d0e4dc864 $
    • Constructor Detail

      • MavenResolver

        public MavenResolver​(List<String> profiles,
                             ArtifactResolver artifactResolver,
                             RepositoryResolver repositoryResolver)
        Parameters:
        profiles - the list of Maven profile to enable when reading/resolving pom files
        artifactResolver - the resolver to resolve artifacts from Maven repositories
        repositoryResolver - the resolver to create Maven repositories and sessions
    • Method Detail

      • getModelFromCurrentPOM

        public org.apache.maven.model.Model getModelFromCurrentPOM()
                                                            throws Exception
        Returns:
        the Maven Model object for the pom.xml file in the current directory (i.e. the POM of the module executing functional tests)
        Throws:
        Exception - if an error occurred during reading and parsing of the POM
      • getPlatformVersion

        public String getPlatformVersion()
                                  throws Exception
        Returns:
        the version of the XWiki platform artifacts to download/resolve
        Throws:
        Exception - if an error occurred during reading and parsing of the POM
      • getPropertyFromCurrentPOM

        public String getPropertyFromCurrentPOM​(String propertyName)
                                         throws Exception
        Parameters:
        propertyName - the maven property name for which to retrieve the value
        Returns:
        the property value
        Throws:
        Exception - if the property doesn't exist
        Since:
        11.7RC1
      • getPropertiesFromCurrentPOM

        public Properties getPropertiesFromCurrentPOM()
                                               throws Exception
        Returns:
        the resolved POM properties
        Throws:
        Exception - if the properties cannot be resolved
        Since:
        15.2RC1
      • getModelFromPOM

        public org.apache.maven.model.Model getModelFromPOM​(File pomFile)
                                                     throws Exception
        Parameters:
        pomFile - the location of the pom file to read
        Returns:
        the Maven Model object for the pom.xml file passed in parameters
        Throws:
        Exception - if an error occurred during reading and parsing of the POM
      • getModelFromPOMArtifact

        public org.apache.maven.model.Model getModelFromPOMArtifact​(org.eclipse.aether.artifact.Artifact artifact)
                                                             throws Exception
        Parameters:
        artifact - the artifact for which to read and parse the POM
        Returns:
        the Maven Model object for the passed artifact
        Throws:
        Exception - if an error occurred during resolving of the artifact or during reading and parsing of the POM
      • convertToArtifact

        public org.eclipse.aether.artifact.Artifact convertToArtifact​(org.apache.maven.model.Dependency dependency)
        Parameters:
        dependency - the dependency to convert to an Artifact instance
        Returns:
        the converted Artifact instance
        Since:
        10.11RC1
      • convertToArtifacts

        public List<org.eclipse.aether.artifact.Artifact> convertToArtifacts​(Collection<org.apache.maven.model.Dependency> dependencies)
        Parameters:
        dependencies - the dependencies to convert to Artifact instances
        Returns:
        the converted Artifact instances
        Since:
        12.5RC1
      • convertToArtifacts

        public List<org.eclipse.aether.artifact.Artifact> convertToArtifacts​(Collection<ArtifactCoordinate> artifactCoordinates,
                                                                             boolean resolveExtraJARs)
                                                                      throws Exception
        Parameters:
        artifactCoordinates - the Maven artifact coordinates to convert to a resolved list of Artifacts
        resolveExtraJARs - whether or not extra JARs without version should get their version resolved from the current POM or not
        Returns:
        the resolved list of artifacts
        Throws:
        Exception - in case the POM model cannot be resolved
        Since:
        12.5RC1
      • addCloverJAR

        public void addCloverJAR​(List<org.eclipse.aether.artifact.Artifact> artifacts)
                          throws Exception
        Parameters:
        artifacts - the list of artifacts to which to add the Clover JAR
        Throws:
        Exception - in case the POM model cannot be resolved
        Since:
        10.11.2, 12.0RC1
      • getDependencies

        public Collection<org.eclipse.aether.artifact.Artifact> getDependencies​(org.apache.maven.model.Model model)
                                                                         throws Exception
        Parameters:
        model - the model from which to find the current artifact and its transitive dependencies
        Returns:
        the full transitive dependencies for the current POM
        Throws:
        Exception - in case an error occurred during resolving
        Since:
        12.5RC1
      • replacePropertiesFromCurrentPOM

        public String replacePropertiesFromCurrentPOM​(String value)
        Parameters:
        value - the value in which to resolve Maven properties
        Returns:
        the resolved value