Example usage for org.apache.maven.artifact Artifact getDependencyConflictId

List of usage examples for org.apache.maven.artifact Artifact getDependencyConflictId

Introduction

In this page you can find the example usage for org.apache.maven.artifact Artifact getDependencyConflictId.

Prototype

String getDependencyConflictId();

Source Link

Usage

From source file:com.adviser.maven.ResolutionListenerImpl.java

License:Apache License

public void startProcessChildren(Artifact artifact) {
    // getLog().debug("startProcessChildren: " + artifact);
    Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
    if (parents.isEmpty()) {
        rootNode = node;// w w w  . j  a  va  2s .  c  o m
    }
    parents.push(node);
}

From source file:com.adviser.maven.ResolutionListenerImpl.java

License:Apache License

public void omitForNearer(Artifact omitted, Artifact kept) {
    // getLog().debug("omitForNearer: omitted=" + omitted + ", kept=" +
    // kept);//  w  w  w .ja  va 2 s  . co m
    assert omitted.getDependencyConflictId().equals(kept.getDependencyConflictId());
    Node node = (Node) artifacts.get(omitted.getDependencyConflictId());
    assert node != null;
    node.setArtifact(kept);
}

From source file:com.adviser.maven.ResolutionListenerImpl.java

License:Apache License

public void includeArtifact(Artifact artifact) {
    // getLog().debug("includeArtifact: " + artifact);
    Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
    if (node == null) {
        node = new Node();
        artifacts.put(artifact.getDependencyConflictId(), node);
    }/*from   w  ww . j a  v  a 2 s .c  om*/
    node.setArtifact(artifact);
    if (!parents.isEmpty()) {
        Node parent = (Node) parents.peek();
        parent.getChildren().add(node);
        node.getParents().add(parent);
    }
    if (rootNode != null) {
        // print(rootNode, "");
    }
}

From source file:com.adviser.maven.ResolutionListenerImpl.java

License:Apache License

public void updateScope(Artifact artifact, String scope) {
    // getLog().debug("updateScope: " + artifact);
    Node node = (Node) artifacts.get(artifact.getDependencyConflictId());

    node.getArtifact().setScope(scope);/*from  w  w w. j a v a 2 s. co m*/
}

From source file:com.adviser.maven.ResolutionListenerImpl.java

License:Apache License

public void manageArtifact(Artifact artifact, Artifact replacement) {
    // getLog().debug("manageArtifact: artifact=" + artifact + ",
    // replacement=" + replacement);
    Node node = (Node) artifacts.get(artifact.getDependencyConflictId());
    if (node != null) {
        if (replacement.getVersion() != null) {
            node.getArtifact().setVersion(replacement.getVersion());
        }// www.j  av a  2s. c  om
        if (replacement.getScope() != null) {
            node.getArtifact().setScope(replacement.getScope());
        }
    }
}

From source file:com.adviser.maven.ResolutionListenerImpl.java

License:Apache License

public Node getNode(Artifact artifact) {
    return (Node) artifacts.get(artifact.getDependencyConflictId());
}

From source file:com.enonic.cms.maven.plugin.CheckDependenciesMojo.java

License:Apache License

private void checkDependencies(final List<String> set, final String message) throws Exception {
    final List<String> ids = new ArrayList<String>();
    for (final Artifact dep : getIncludedArtifacts()) {
        if (set.contains(dep.getArtifactId())) {
            ids.add(dep.getDependencyConflictId());
        }/*w w  w . j av a  2  s.  c  om*/
    }

    if (ids.isEmpty()) {
        return;
    }

    final String str = getMessage(message, ids);
    getLog().warn(str);
}

From source file:com.enonic.cms.maven.plugin.PackagePluginMojo.java

License:Apache License

private List<String> copyDependencies() throws Exception {
    final List<String> ids = new ArrayList<String>();
    final List<String> libs = new ArrayList<String>();
    final File libDirectory = new File(getAppDirectory(), LIB_DIR);
    final Set<Artifact> artifacts = getNotProvidedDependencies();

    for (final Artifact artifact : artifacts) {
        final String targetFileName = getDefaultFinalName(artifact);
        FileUtils.copyFileIfModified(artifact.getFile(), new File(libDirectory, targetFileName));
        libs.add(LIB_DIR + targetFileName);
        ids.add(artifact.getDependencyConflictId());
    }// ww w.  ja  va  2  s .  co m

    if (!ids.isEmpty()) {
        getLog().info(getMessage("Following dependencies are packaged inside the plugin:", ids));
    }

    return libs;
}

From source file:com.github.veithen.phos.jacoco.InstallDataFileMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (dataFile.exists()) {
        Artifact artifact = artifactFactory.createArtifactWithClassifier(project.getGroupId(),
                project.getArtifactId(), project.getVersion(), "exec", "jacoco");
        try {/*  w ww  .j  av  a  2 s  .co m*/
            installer.install(dataFile, artifact, localRepository);
        } catch (ArtifactInstallationException ex) {
            throw new MojoExecutionException(String.format("Error installing artifact '%s': %s",
                    artifact.getDependencyConflictId(), ex.getMessage()), ex);
        }
    }
}

From source file:com.googlecode.maven.licensevalidator.LicenseValidateMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    if (verbose) {
        getLog().info("Validating licenses");
    }/* w w  w.  j av  a 2s  .c  o m*/

    final Set<Artifact> depArtifacts;
    if (includeTransitiveDependencies) {
        depArtifacts = project.getArtifacts();
    } else {
        depArtifacts = project.getDependencyArtifacts();
    }

    boolean someFailed = false;
    for (Artifact depArtifact : depArtifacts) {
        MavenProject depProject = null;
        try {
            depProject = projectBuilder.buildFromRepository(depArtifact, remoteRepositories, localRepository);
        } catch (ProjectBuildingException e) {
            throw new MojoExecutionException(
                    "Unable to build project: " + depArtifact.getDependencyConflictId(), e);
        }

        List<License> licenses = depProject.getLicenses();
        boolean failed = areLicensesBanned(depProject.getId(), licenses);
        someFailed |= failed;

        if (someFailed && failFast) {
            throw new MojoExecutionException("Failed license checks for dependency " + depProject.getId());
        }
    }

    if (someFailed) {
        throw new MojoExecutionException("Failed license checks for some dependencies");
    }
}