Example usage for org.apache.maven.project MavenProject getDependencyArtifacts

List of usage examples for org.apache.maven.project MavenProject getDependencyArtifacts

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getDependencyArtifacts.

Prototype

@Deprecated
public Set<Artifact> getDependencyArtifacts() 

Source Link

Document

Direct dependencies that this project has.

Usage

From source file:io.fabric8.maven.AbstractFabric8Mojo.java

License:Apache License

Set<File> getDependencies() throws IOException {
    Set<File> dependnencies = new LinkedHashSet<>();
    MavenProject project = getProject();

    Path dir = Paths.get(project.getBuild().getOutputDirectory(), "deps");
    if (!dir.toFile().exists() && !dir.toFile().mkdirs()) {
        throw new IOException("Cannot create temp directory at:" + dir.toAbsolutePath());
    }//from   w ww  .  j a va 2 s .  c o m

    for (Artifact candidate : project.getDependencyArtifacts()) {
        File f = candidate.getFile();
        if (f == null) {
            continue;
        } else if (f.getName().endsWith("jar") && hasKubernetesJson(f)) {
            getLog().info("Found file:" + f.getAbsolutePath());
            try (FileInputStream fis = new FileInputStream(f); JarInputStream jis = new JarInputStream(fis)) {
                Zips.unzip(new FileInputStream(f), dir.toFile());
                File jsonPath = dir.resolve(DEFAULT_CONFIG_FILE_NAME).toFile();
                if (jsonPath.exists()) {
                    dependnencies.add(jsonPath);
                }
            }
        } else if (isKubernetesJsonArtifact(candidate.getClassifier(), candidate.getType())) {
            dependnencies.add(f);
        }
    }
    return dependnencies;
}

From source file:io.fabric8.maven.JsonMojo.java

License:Apache License

protected void combineDependentJsonFiles(File json) throws MojoExecutionException {
    try {//w w  w. j av  a  2 s. c o  m
        MavenProject project = getProject();
        Set<File> jsonFiles = new LinkedHashSet<>();
        Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
        for (Artifact artifact : dependencyArtifacts) {
            String classifier = artifact.getClassifier();
            String type = artifact.getType();
            File file = artifact.getFile();

            if (isKubernetesJsonArtifact(classifier, type)) {
                if (file != null) {
                    System.out.println("Found kubernetes JSON dependency: " + artifact);
                    jsonFiles.add(file);
                } else {
                    Set<Artifact> artifacts = resolveArtifacts(artifact);
                    for (Artifact resolvedArtifact : artifacts) {
                        classifier = resolvedArtifact.getClassifier();
                        type = resolvedArtifact.getType();
                        file = resolvedArtifact.getFile();
                        if (isKubernetesJsonArtifact(classifier, type) && file != null) {
                            System.out.println("Resolved kubernetes JSON dependency: " + artifact);
                            jsonFiles.add(file);
                        }
                    }
                }
            }
        }
        List<Object> jsonObjectList = new ArrayList<>();
        for (File file : jsonFiles) {
            addKubernetesJsonFileToList(jsonObjectList, file);
        }
        if (jsonObjectList.isEmpty()) {
            if (failOnMissingJsonFiles) {
                throw new MojoExecutionException("Could not find any dependent kubernetes JSON files!");
            } else {
                getLog().warn("Could not find any dependent kubernetes JSON files");
                return;
            }
        }
        Object combinedJson;
        if (jsonObjectList.size() == 1) {
            combinedJson = jsonObjectList.get(0);
        } else {
            combinedJson = KubernetesHelper.combineJson(jsonObjectList.toArray());
        }
        if (combinedJson instanceof Template) {
            Template template = (Template) combinedJson;
            String templateName = getProjectName();
            setName(template, templateName);
            configureTemplateDescriptionAndIcon(template, getIconUrl());

            addLabelIntoObjects(template.getObjects(), "package", templateName);

            if (pureKubernetes) {
                combinedJson = applyTemplates(template);
            }
        }
        if (pureKubernetes) {
            combinedJson = filterPureKubernetes(combinedJson);
        }
        json.getParentFile().mkdirs();
        KubernetesHelper.saveJson(json, combinedJson);
        getLog().info("Saved as :" + json.getAbsolutePath());
    } catch (Exception e) {
        throw new MojoExecutionException("Failed to save combined JSON files " + json + " and "
                + kubernetesExtraJson + " as " + json + ". " + e, e);
    }
}

From source file:io.github.wanghuayao.maven.plugin.oaktree.CreateTreeMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    log = getLog();/*  ww w .  jav a  2  s  .  c  o  m*/
    try {
        OakProperties properties = new OakProperties();
        dependencyArtifacts = "io.github.wanghuayao:maven-plugin-oaktree:" + properties.getVersion()
                + ":dependency-artifacts";

        filter = new ProcessingFilter(likePatten, hitePatten, deep);

        MavenProject mp = (MavenProject) this.getPluginContext().get("project");
        String mavenHomeStr = removeUnusedCharInPath(mavenHome.getPath());
        File mvnExecFile = new File(mavenHomeStr + "/bin/mvn");
        mvnExec = mvnExecFile.getPath();
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            mvnExec = mvnExec + ".cmd";
            isWindwos = true;
        }

        File okaBaseDir = new File(outputDirectory, "oaktree");
        File okadependencyDir = new File(okaBaseDir, "dependency");
        if (!okadependencyDir.exists()) {
            okadependencyDir.mkdirs();
        }
        okadependencyOutputDir = okadependencyDir.getPath();

        ArtifactItem rootItem = new ArtifactItem(mp.getGroupId(), mp.getArtifactId(), mp.getPackaging(),
                mp.getVersion());

        File rootPom = mp.getFile();
        int startDeep = 2;
        for (Object obj : mp.getDependencyArtifacts()) {
            DefaultArtifact artifact = (DefaultArtifact) obj;
            ArtifactItem chieldern = ArtifactItem.valueOf(artifact);
            if (filter.isGoOnProcessing(chieldern, startDeep)) {
                calcDependancy(chieldern, startDeep);
                rootItem.addChildren(chieldern);
            }
        }

        FileWriter w = null;
        try {
            File okaFile = new File(okaBaseDir, "okatree.txt");
            if (okaFile.exists()) {
                okaFile.delete();
            }
            w = new FileWriter(okaFile);
            log.info("writing file :  " + okaFile.getPath());
            printArtifactItem(w, rootItem, "");
            log.info("writing complete.");
        } finally {
            StreamUtils.quiteClose(w);
        }
    } catch (Exception ex) {
        getLog().error(ex.getMessage(), ex);
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}

From source file:io.github.wanghuayao.maven.plugin.oaktree.DependencyArtifactsMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    try {//from   w w w  .j a  v a 2 s.  c om
        MavenProject mp = (MavenProject) this.getPluginContext().get("project");

        if (outputFile == null) {
            outputFile = new File(outputDirectory,
                    mp.getGroupId() + "." + mp.getArtifactId() + "." + mp.getVersion() + ".txt");
        }

        // delete old file
        if (outputFile.exists()) {
            return;
        }

        FileWriter w = null;
        try {
            w = new FileWriter(outputFile);
            for (Object obj : mp.getDependencyArtifacts()) {
                DefaultArtifact artifact = (DefaultArtifact) obj;
                ArtifactWriter.artifactToWriter(artifact, w);
                w.write('\n');
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Error writing file " + outputFile, e);
        } finally {
            StreamUtils.quiteClose(w);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}

From source file:io.treefarm.plugins.haxe.AbstractCompileMojo.java

License:Apache License

@Override
protected void initialize(MavenProject project, ArtifactRepository localRepository) throws Exception {
    if (openflIsActive()) {
        File nmmlFile = new File(outputDirectory.getParentFile(), nmml);
        if (nmmlFile.exists()) {
            nmml = nmmlFile.getAbsolutePath();
            Document dom;/*from w  ww  .  j  a v  a2  s  .co  m*/
            // Make an  instance of the DocumentBuilderFactory
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            try {
                // use the factory to take an instance of the document builder
                DocumentBuilder db = dbf.newDocumentBuilder();
                // parse using the builder to get the DOM mapping of the    
                // XML file
                dom = db.parse(nmmlFile.getAbsolutePath());

                Element doc = dom.getDocumentElement();

                NodeList nl;

                nl = doc.getElementsByTagName("haxelib");
                String haxelibName;
                String haxelibVersion;
                if (nl.getLength() > 0) {
                    Set<Artifact> dependencies = project.getDependencyArtifacts();

                    for (int i = 0; i < nl.getLength(); i++) {
                        haxelibVersion = "";
                        Node node = nl.item(i);
                        if (node.getNodeType() == Node.ELEMENT_NODE) {
                            Element element = (Element) node;
                            haxelibName = element.getAttribute("name");
                            if (element.hasAttribute("version")) {
                                haxelibVersion = element.getAttribute("version");
                            }
                            Artifact artifact = new DefaultArtifact("org.haxe.lib", haxelibName, haxelibVersion,
                                    Artifact.SCOPE_COMPILE, "haxelib", "", haxelibHandler);

                            //dependencies.add(artifact);
                        }
                    }
                }
            } catch (ParserConfigurationException pce) {
                System.out.println(pce.getMessage());
            } catch (SAXException se) {
                System.out.println(se.getMessage());
            } catch (IOException ioe) {
                System.err.println(ioe.getMessage());
            }
        } else {
            nmml = null;
        }
    }

    super.initialize(project, localRepository);
}

From source file:io.treefarm.plugins.haxe.components.NativeBootstrap.java

License:Apache License

private void initializePrograms(MavenProject project, File pluginHome, List<Dependency> pluginDependencies)
        throws Exception {
    Map<String, Artifact> artifactsMap = new HashMap<String, Artifact>();
    Set<String> path = new HashSet<String>();
    File outputDirectory = getOutputDirectory();

    // Add java to PATH
    path.add(new File(System.getProperty("java.home"), "bin").getAbsolutePath());

    for (Dependency dependency : pluginDependencies) {
        String artifactKey = dependency.getGroupId() + ":" + dependency.getArtifactId();

        if (artifactKey.equals(HAXE_COMPILER_KEY) || artifactKey.equals(NEKO_KEY) || artifactKey.equals(NME_KEY)
                || artifactKey.equals(HXCPP_KEY) || StringUtils.startsWith(artifactKey, OPENFL_KEY)) {
            /*    String classifier = OSClassifiers.getDefaultClassifier();
                String packaging = PackageTypes.getSDKArtifactPackaging(classifier);
                if (artifactKey.equals(OPENFL_KEY)) classifier = null;
                    //from ww w .jav a2  s  .c om
                Artifact artifact = repositorySystem.createArtifactWithClassifier(
                dependency.getGroupId(), 
                dependency.getArtifactId(), 
                dependency.getVersion(),
                packaging,
                classifier
                );
                    
                Artifact resolvedArtifact = resolveArtifact(artifact, true);
                boolean resolvedLocally = (resolvedArtifact != null);
                if (!resolvedLocally) {
            resolvedArtifact = resolveArtifact(artifact, false);
                }
                if (resolvedArtifact != null) {
            resolvedArtifact.setVersion(artifact.getVersion());
            artifactsMap.put(artifactKey, resolvedArtifact);
                }*/

            Artifact artifact = repositorySystem.createArtifactWithClassifier(dependency.getGroupId(),
                    dependency.getArtifactId(), dependency.getVersion(), dependency.getType(),
                    dependency.getClassifier());
            Artifact resolvedArtifact = resolveArtifact(artifact, false);
            if (resolvedArtifact != null) {
                artifactsMap.put(artifactKey, resolvedArtifact);
            }
        }
    }

    if (artifactsMap.get(NEKO_KEY) == null) {
        throw new Exception(String.format(
                "Neko Runtime dependency (%s) not found in haxebuildr-maven-plugin dependencies", NEKO_KEY));
    }

    if (artifactsMap.get(HAXE_COMPILER_KEY) == null) {
        throw new Exception(
                String.format("Haxe Compiler dependency (%s) not found in haxebuildr-maven-plugin dependencies",
                        HAXE_COMPILER_KEY));
    }

    neko.initialize(artifactsMap.get(NEKO_KEY), outputDirectory, pluginHome, path);
    haxe.initialize(artifactsMap.get(HAXE_COMPILER_KEY), outputDirectory, pluginHome, path);
    haxelib.initialize(artifactsMap.get(HAXE_COMPILER_KEY), outputDirectory, pluginHome, path);
    HaxelibHelper.setHaxelib(haxelib);

    Iterator<Artifact> iterator;
    Set<Artifact> projectDependencies = project.getDependencyArtifacts();
    if (projectDependencies != null) {
        iterator = projectDependencies.iterator();
        while (iterator.hasNext()) {
            Artifact a = iterator.next();

            if (a.getType().equals(HaxeFileExtensions.HAXELIB)) {
                File haxelibDirectory = HaxelibHelper.getHaxelibDirectoryForArtifact(a.getArtifactId(),
                        a.getVersion());

                if (haxelibDirectory != null && haxelibDirectory.exists()) {
                    iterator.remove();
                }
            } else {
                if (a.getGroupId().equals(HaxelibHelper.HAXELIB_GROUP_ID)) {
                    /*String packaging = PackageTypes.getSDKArtifactPackaging(OSClassifiers.getDefaultClassifier());
                    Artifact artifact = repositorySystem.createArtifactWithClassifier(
                    a.getGroupId(), a.getArtifactId(), a.getVersion(),
                    packaging, null
                    );
                    Artifact resolvedArtifact = resolveArtifact(artifact, true);
                    boolean resolvedLocally = (resolvedArtifact != null);
                    if (!resolvedLocally) {
                    resolvedArtifact = resolveArtifact(artifact, false);
                    }
                    if (resolvedArtifact != null) {
                    HaxelibHelper.injectPomHaxelib(resolvedArtifact, outputDirectory, logger, resolvedLocally);
                    iterator.remove();
                    }*/
                    /*Artifact resolvedArtifact = resolveArtifact(a, false);
                    if (resolvedArtifact != null) {
                    HaxelibHelper.injectPomHaxelib(a, outputDirectory, logger);
                    }*/

                    Artifact artifact = repositorySystem.createArtifactWithClassifier(a.getGroupId(),
                            a.getArtifactId(), a.getVersion(), a.getType(), null);

                    Artifact resolvedArtifact = resolveArtifact(artifact, false);
                    if (resolvedArtifact != null && resolvedArtifact.getFile() != null) {
                        HaxelibHelper.injectPomHaxelib(a.getArtifactId(), a.getVersion(), a.getType(),
                                a.getFile(), logger);
                    }
                }
            }

            if (a.getArtifactId().equals(MUNIT_ID)) {
                munit.initialize(a, outputDirectory, pluginHome, path);
            }

            if (a.getArtifactId().equals(CHXDOC_ID)) {
                chxdoc.initialize(a, outputDirectory, pluginHome, path);
            }
        }
    }

    Iterator<String> mapIterator = artifactsMap.keySet().iterator();
    while (mapIterator.hasNext()) {
        String key = mapIterator.next();
        if (key.equals(NME_KEY) || StringUtils.startsWith(key, OPENFL_KEY)) {
            if (projectDependencies != null) {
                iterator = projectDependencies.iterator();
                while (iterator.hasNext()) {
                    Artifact a = iterator.next();
                    if (a.getType().equals(HaxeFileExtensions.HAXELIB)
                            && StringUtils.startsWith(a.getArtifactId(), OPENFL_ARTIFACT_ID_PREFIX)
                            && (a.getVersion() == null || a.getVersion().equals("")
                                    || a.getVersion().equals(artifactsMap.get(key).getVersion()))) {
                        iterator.remove();
                    }
                }
            }
            // inject all openfl accessory libs
            Artifact a = artifactsMap.get(key);
            Artifact resolvedArtifact = resolveArtifact(a, false);
            if (resolvedArtifact != null && resolvedArtifact.getFile() != null) {
                HaxelibHelper.injectPomHaxelib(a.getArtifactId(), a.getVersion(), a.getType(), a.getFile(),
                        logger);
            }
        }
    }

    if (artifactsMap.get(OPENFL_KEY) != null) {
        File nmeDirectory = null;
        Artifact nmeArtifact = artifactsMap.get(NME_KEY);
        if (nmeArtifact != null) {
            nmeDirectory = HaxelibHelper.getHaxelibDirectoryForArtifact(nmeArtifact.getArtifactId(),
                    nmeArtifact.getVersion());
        }

        File openflNativeDirectory = null;
        Artifact openflNativeArtifact = artifactsMap
                .get(OPENFL_GROUP + OPENFL_ARTIFACT_ID_PREFIX + OPENFL_NATIVE_SUFFIX);
        if (openflNativeArtifact != null) {
            openflNativeDirectory = HaxelibHelper.getHaxelibDirectoryForArtifact(
                    openflNativeArtifact.getArtifactId(), openflNativeArtifact.getVersion());
        }

        openfl.initialize(artifactsMap.get(OPENFL_KEY), outputDirectory, pluginHome, path, nmeDirectory,
                openflNativeDirectory);
    }

    if (artifactsMap.get(HXCPP_KEY) != null) {
        hxcpp.initialize(artifactsMap.get(HXCPP_KEY), outputDirectory, pluginHome, path);
    }
}

From source file:net.ubos.tools.pacmanpkgmavenplugin.PacmanPkgMavenPlugin.java

License:Open Source License

/**
 * {@inheritDoc}// w w  w . j a v a 2  s  .  c om
 * 
 * @throws MojoExecutionException
 */
@Override
public void execute() throws MojoExecutionException {
    MavenProject project = (MavenProject) getPluginContext().get("project");
    String packaging = project.getPackaging();

    if (!"jar".equals(packaging) && !"ear".equals(packaging) && !"war".equals(packaging)) {
        return;
    }

    getLog().info("Generating PKGBUILD @ " + project.getName());

    // pull stuff out of MavenProject
    String artifactId = project.getArtifactId();
    String version = project.getVersion();
    String url = project.getUrl();
    String description = project.getDescription();
    Set<Artifact> dependencies = project.getDependencyArtifacts();
    File artifactFile = project.getArtifact().getFile();

    if (artifactFile == null || !artifactFile.exists()) {
        throw new MojoExecutionException("pacmanpkg must be executed as part of a build, not standalone,"
                + " otherwise it can't find the main JAR file");
    }
    // translate to PKGBUILD fields
    String pkgname = artifactId;
    String pkgver = version.replaceAll("-SNAPSHOT", "a"); // alpha
    String pkgdesc = "A Java package available on UBOS";
    if (description != null) {
        if (description.length() > 64) {
            pkgdesc = description.substring(0, 64) + "...";
        } else {
            pkgdesc = description;
        }
    }

    ArrayList<String> depends = new ArrayList<>(dependencies.size());
    for (Artifact a : dependencies) {
        if (!"test".equals(a.getScope())) {
            depends.add(a.getArtifactId());
        }
    }
    // write to PKGBUILD
    try {
        File baseDir = project.getBasedir();
        File pkgBuild = new File(baseDir, "target/PKGBUILD");
        PrintWriter out = new PrintWriter(pkgBuild);

        getLog().debug("Writing PKGBUILD to " + pkgBuild.getAbsolutePath());

        out.println("#");
        out.println(" * Automatically generated by pacman-pkg-maven-plugin; do not modify.");
        out.println("#");

        out.println();

        out.println("pkgname=" + pkgname);
        out.println("pkgver=" + pkgver);
        out.println("pkgrel=" + pkgrel);
        out.println("pkgdesc='" + pkgdesc + "'");
        out.println("arch=('any')");
        out.println("url='" + url + "'");
        out.println("license=('" + license + "')");

        out.print("depends=(");
        String sep = "";
        for (String d : depends) {
            out.print(sep);
            sep = ",";
            out.print("'");
            out.print(d);
            out.print("'");
        }
        out.println(")");

        out.println();

        out.println("package() (");
        out.println("   mkdir -p ${pkgdir}/usr/share/java");
        out.println("   install -m644 ${startdir}/" + artifactFile.getName() + " ${pkgdir}/usr/share/java/");
        out.println(")");

        out.close();

    } catch (IOException ex) {
        throw new MojoExecutionException("Failed to write target/PKGBUILD", ex);
    }
}

From source file:npanday.executable.impl.CompilerContextImpl.java

License:Apache License

public void init(CompilerCapability capability, CompilerConfig config, MavenProject project)
        throws PlatformUnsupportedException {

    this.project = project;
    this.config = config;
    libraries = new ArrayList<Artifact>();
    directLibraries = new ArrayList<Artifact>();
    modules = new ArrayList<Artifact>();
    compilerCapability = capability;/*from   w  w w.  java2s  .  c om*/

    // initialize base class
    super.init(compilerCapability, config);

    Set<Artifact> artifacts = project.getDependencyArtifacts();//Can add WFC deps prior
    if (artifacts != null) {
        for (Artifact artifact : artifacts) {
            String type = artifact.getType();
            logger.debug("NPANDAY-061-006: Artifact Type:" + type);
            logger.debug("NPANDAY-061-007: Artifact Type:" + ArtifactTypeHelper.isDotnetGenericGac(type));
            ArtifactType artifactType = ArtifactType.getArtifactTypeForPackagingName(type);
            if (ArtifactTypeHelper.isDotnetModule(type)) {
                modules.add(artifact);
            } else if (ArtifactTypeHelper.isDotnetAssembly(artifactType)) {
                libraries.add(artifact);
            }

            if (type.equals(ArtifactType.COM_REFERENCE.getPackagingType())) {
                moveInteropDllToBuildDirectory(artifact);
            }
        }
    }

    String basedir = project.getBuild().getDirectory() + File.separator + "assembly-resources" + File.separator;
    linkedResources = new File(basedir, "linkresource").exists()
            ? Arrays.asList(new File(basedir, "linkresource").listFiles())
            : new ArrayList<File>();
    getEmbeddedResources(new File(basedir, "resource"));
    win32resources = new File(basedir, "win32res").exists()
            ? Arrays.asList(new File(basedir, "win32res").listFiles())
            : new ArrayList<File>();
    File win32IconDir = new File(basedir, "win32icon");
    if (win32IconDir.exists()) {
        File[] icons = win32IconDir.listFiles();
        if (icons.length > 1) {
            throw new PlatformUnsupportedException(
                    "NPANDAY-061-008: There is more than one win32icon in resource directory: Number = "
                            + icons.length);
        }
        if (icons.length == 1) {
            win32icon = icons[0];
        }
    }
}

From source file:npanday.resolver.NPandayDependencyResolution.java

License:Apache License

public Set<Artifact> require(MavenProject project, ArtifactRepository localRepository, ArtifactFilter filter)
        throws ArtifactResolutionException {
    long startTime = System.currentTimeMillis();

    artifactResolver.initializeWithFilter(filter);

    if (getLogger().isDebugEnabled()) {
        getLogger().debug("NPANDAY-148-007: Resolving dependencies for " + project.getArtifact());
    }//from   w w  w.  jav a2s .co m

    try {
        if (project.getDependencyArtifacts() == null) {
            createArtifactsForMaven2BackCompat(project);
        }

        ArtifactResolutionResult result = artifactResolver.resolveTransitively(project.getDependencyArtifacts(),
                project.getArtifact(), project.getManagedVersionMap(), localRepository,
                project.getRemoteArtifactRepositories(), metaDataSource, filter);

        /*
        * WORKAROUND: transitive dependencies are not cached in MavenProject; in order to let
        * them "live" for following mojo executions, we'll add the custom resolved
        * dependencies to the projects DIRECT dependencies
        * */

        Set<Artifact> dependencyArtifacts = new HashSet<Artifact>(project.getDependencyArtifacts());
        addResolvedSpecialsToProjectDependencies(result, dependencyArtifacts);

        // Add custom contribute dependencies to maven project dependencies
        dependencyArtifacts.addAll(artifactResolver.getCustomDependenciesCache());
        project.setDependencyArtifacts(dependencyArtifacts);

        Set<Artifact> resultRequire = Sets.newLinkedHashSet(result.getArtifacts());
        resultRequire.addAll(artifactResolver.getCustomDependenciesCache());

        if (getLogger().isInfoEnabled()) {
            long endTime = System.currentTimeMillis();
            getLogger()
                    .info("NPANDAY-148-009: Took " + (endTime - startTime) + "ms to resolve dependencies for "
                            + project.getArtifact() + " with filter " + filter.toString());
        }

        return resultRequire;
    } catch (ArtifactResolutionException e) {
        throw new ArtifactResolutionException("NPANDAY-148-001: Could not resolve project dependencies",
                project.getArtifact(), e);
    } catch (ArtifactNotFoundException e) {
        throw new ArtifactResolutionException("NPANDAY-148-002: Could not resolve project dependencies",
                project.getArtifact(), e);
    } catch (InvalidDependencyVersionException e) {
        throw new ArtifactResolutionException("NPANDAY-148-003: Could not resolve project dependencies",
                project.getArtifact(), e);
    }
}

From source file:org.apache.camel.maven.packaging.PackageDataFormatMojo.java

License:Apache License

private static Artifact findCamelCoreArtifact(MavenProject project) {
    // maybe this project is camel-core itself
    Artifact artifact = project.getArtifact();
    if (artifact.getGroupId().equals("org.apache.camel") && artifact.getArtifactId().equals("camel-core")) {
        return artifact;
    }//from  w w w  . j  a  va  2 s  .  c o m

    // or its a component which has a dependency to camel-core
    Iterator it = project.getDependencyArtifacts().iterator();
    while (it.hasNext()) {
        artifact = (Artifact) it.next();
        if (artifact.getGroupId().equals("org.apache.camel") && artifact.getArtifactId().equals("camel-core")) {
            return artifact;
        }
    }
    return null;
}