Example usage for org.apache.maven.model.resolution UnresolvableModelException UnresolvableModelException

List of usage examples for org.apache.maven.model.resolution UnresolvableModelException UnresolvableModelException

Introduction

In this page you can find the example usage for org.apache.maven.model.resolution UnresolvableModelException UnresolvableModelException.

Prototype

public UnresolvableModelException(String message, String groupId, String artifactId, String version,
        Throwable cause) 

Source Link

Document

Creates a new exception with specified detail message and cause.

Usage

From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.SimpleModelResolver.java

License:Apache License

@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {//w  w  w  . j a va2  s  .co  m
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
        pomArtifact = system.resolveArtifact(session, request).getArtifact();
    } catch (ArtifactResolutionException ex) {
        throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId, version, ex);
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}

From source file:com.google.devtools.build.workspace.maven.DefaultModelResolver.java

License:Open Source License

private UrlModelSource getModelSource(String url, String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    try {/*from w  w w  .  ja  v  a  2s . c o  m*/
        if (!url.endsWith("/")) {
            url += "/";
        }
        URL urlUrl = new URL(url + groupId.replaceAll("\\.", "/") + "/" + artifactId + "/" + version + "/"
                + artifactId + "-" + version + ".pom");
        if (pomFileExists(urlUrl)) {
            UrlModelSource urlModelSource = new UrlModelSource(urlUrl);
            ruleNameToModelSource.put(Rule.name(groupId, artifactId), urlModelSource);
            return urlModelSource;
        }
    } catch (MalformedURLException e) {
        throw new UnresolvableModelException("Bad URL " + url + ": " + e.getMessage(), groupId, artifactId,
                version, e);
    }
    return null;
}

From source file:io.tesla.aether.guice.DefaultModelResolver.java

License:Open Source License

public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {//from ww  w. j  a  v a2  s  .  c  o m
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, context);
        request.setTrace(trace);
        pomArtifact = resolver.resolveArtifact(session, request).getArtifact();
    } catch (ArtifactResolutionException e) {
        throw new UnresolvableModelException(e.getMessage(), groupId, artifactId, version, e);
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}

From source file:org.commonjava.maven.ext.manip.io.GalleyModelResolver.java

License:Open Source License

@Override
public ModelSource resolveModel(final String groupId, final String artifactId, final String version)
        throws UnresolvableModelException {
    Transfer transfer;/*from   w w w  .  j  a  v a2  s .c  o m*/
    ArtifactRef ar = new ProjectVersionRef(groupId, artifactId, version).asPomArtifact();
    try {
        transfer = galleyWrapper.resolveArtifact(ar);
    } catch (final TransferException e) {
        throw new UnresolvableModelException("Failed to resolve POM: " + e.getMessage(), groupId, artifactId,
                version, e);
    }
    if (transfer == null) {
        throw new UnresolvableModelException("Failed to resolve POM: " + ar, groupId, artifactId, version);
    }

    return new FileModelSource(transfer.getDetachedFile());
}

From source file:org.eclipse.aether.ant.AntModelResolver.java

License:Open Source License

public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {//  w  w  w. ja v  a 2s  .co  m
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, context);
        pomArtifact = repoSys.resolveArtifact(session, request).getArtifact();
    } catch (ArtifactResolutionException e) {
        throw new UnresolvableModelException("Failed to resolve POM for " + groupId + ":" + artifactId + ":"
                + version + " due to " + e.getMessage(), groupId, artifactId, version, e);
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}

From source file:org.jboss.forge.addon.maven.impl.MavenModelResolver.java

License:Open Source License

@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);
    try {//w w  w. j av a  2 s.  c o  m
        final ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
        pomArtifact = system.resolveArtifact(session, request).getArtifact();

    } catch (ArtifactResolutionException e) {
        throw new UnresolvableModelException("Failed to resolve POM for " + groupId + ":" + artifactId + ":"
                + version + " due to " + e.getMessage(), groupId, artifactId, version, e);
    }

    final File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);

}

From source file:org.jboss.maven.extension.dependency.resolver.BasicModelResolver.java

License:Apache License

@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {//from  w  w w .j  av  a  2s .c  om
        ArtifactRequest request = new ArtifactRequest();
        request.setArtifact(pomArtifact);
        request.setRepositories(repositories);
        pomArtifact = resolver.resolveArtifact(session, request).getArtifact();
    } catch (ArtifactResolutionException e) {
        throw new UnresolvableModelException(e.getMessage(), groupId, artifactId, version, e);
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}

From source file:org.jboss.shrinkwrap.resolver.impl.maven.MavenModelResolver.java

License:Apache License

@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);
    try {/*from w w w  .  j ava  2 s  . c  o m*/
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
        pomArtifact = system.resolveArtifact(session, request).getArtifact();

    } catch (ArtifactResolutionException e) {
        throw new UnresolvableModelException("Failed to resolve POM for " + groupId + ":" + artifactId + ":"
                + version + " due to " + e.getMessage(), groupId, artifactId, version, e);
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);

}

From source file:org.sonatype.sisu.maven.bridge.resolvers.RemoteModelResolver.java

License:Open Source License

public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {/*from  w  w  w.j av  a 2s.  c  o m*/
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
        pomArtifact = repositorySystem.resolveArtifact(session, request).getArtifact();
    } catch (ArtifactResolutionException e) {
        throw new UnresolvableModelException(e.getMessage(), groupId, artifactId, version, e);
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}

From source file:org.vesalainen.test.pom.UrlModelResolver.java

@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    try {// w w w  . j av a  2 s .  c o  m
        String filename = getFilename(groupId, artifactId, version, "pom");
        URL url = new URL(base + filename);
        return new UrlModelSource(url);
    } catch (MalformedURLException ex) {
        throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId, version, ex);
    }
}