Package org.apache.maven.artifact

Examples of org.apache.maven.artifact.Artifact


                return true;
            }

            public boolean visit(DependencyNode node) {
                if (node.getState() != DependencyNode.OMITTED_FOR_CONFLICT) {
                    Artifact artifact = node.getArtifact();
                    info("    scanning %s for exports", artifact);
                    if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !artifact.getType().equals("pom")) {
                        try {
                            for (Clause clause : ManifestUtils.getExports(getManifest("", artifact))) {
                                getLog().debug(" adding " + clause.getName() + " to list of available packages");
                                systemExports.add(clause.getName());
                            }
View Full Code Here


                if (is != null) { // just in case when we did not open bundle
                    is.close();
                }
            }
        } else {
            Artifact mvnArtifact = (Artifact) artifact;
            File localFile = new File(localRepo.pathOf(mvnArtifact));
            if (localFile.exists()) {
                // avoid going over to the repository if the file is already on
                // the disk
                file = new ZipFile(localFile);
            } else {
                resolver.resolve(mvnArtifact, remoteRepos, localRepo);
                file = new ZipFile(mvnArtifact.getFile());
            }
            // let's replace syserr for now to hide warnings being issues by the Manifest reading process
            PrintStream original = System.err;
            try {
                System.setErr(new PrintStream(new ByteArrayOutputStream()));
View Full Code Here

     */
    private Object resolve(String bundle) throws Exception, ArtifactNotFoundException {
        if (!isMavenProtocol(bundle)) {
            return bundle;
        }
        Artifact artifact = getArtifact(bundle);
        if (bundle.indexOf(MVN_REPO_SEPARATOR) >= 0) {
            if (bundle.startsWith(MVN_URI_PREFIX)) {
                bundle = bundle.substring(MVN_URI_PREFIX.length());
            }
            String repo = bundle.substring(0, bundle.indexOf(MVN_REPO_SEPARATOR));
            ArtifactRepository repository = new DefaultArtifactRepository(artifact.getArtifactId() + "-repo", repo,
                    new DefaultRepositoryLayout());
            List<ArtifactRepository> repos = new LinkedList<ArtifactRepository>();
            repos.add(repository);
            resolver.resolve(artifact, repos, localRepo);
        } else {
View Full Code Here

        Set set = new HashSet();
        for (Iterator i = resolvedArtifacts.values().iterator(); i.hasNext();) {
            List nodes = (List) i.next();
            for (Iterator j = nodes.iterator(); j.hasNext();) {
                ResolutionNode node = (ResolutionNode) j.next();
                Artifact artifact = node.getArtifact();
                if (!node.equals(root) && node.isActive() && node.filterTrail(filter)
                        // If it was optional and not a direct dependency,
                        // we don't add it or its children, just allow the
                        // update of the version and scope
                        && (node.isChildOfRootNode() || !artifact.isOptional())) {
                    artifact.setDependencyTrail(node.getDependencyTrail());
                    set.add(node);
                }
            }
        }
View Full Code Here

        fireEvent(ResolutionListener.TEST_ARTIFACT, listeners, node);

        // TODO: use as a conflict resolver
        Object key = node.getKey();
        if (managedVersions.containsKey(key)) {
            Artifact artifact = (Artifact) managedVersions.get(key);
            fireEvent(ResolutionListener.MANAGE_ARTIFACT, listeners, node, artifact);
            if (artifact.getVersion() != null) {
                node.getArtifact().setVersion(artifact.getVersion());
            }
            if (artifact.getScope() != null) {
                node.getArtifact().setScope(artifact.getScope());
            }
        }

        List previousNodes = (List) resolvedArtifacts.get(key);
        if (previousNodes != null) {
            node = checkPreviousNodes(node, listeners, previousNodes);
        }
        else {
            previousNodes = new ArrayList();
            resolvedArtifacts.put(key, previousNodes);
        }
        previousNodes.add(node);

        if (node.isActive()) {
            fireEvent(ResolutionListener.INCLUDE_ARTIFACT, listeners, node);
        }

        // don't pull in the transitive deps of a system-scoped dependency.
        if (node.isActive() && !Artifact.SCOPE_SYSTEM.equals(node.getArtifact().getScope())) {
            fireEvent(ResolutionListener.PROCESS_CHILDREN, listeners, node);
            for (Iterator i = node.getChildrenIterator(); i.hasNext();) {
                ResolutionNode child = (ResolutionNode) i.next();
                // We leave in optional ones, but don't pick up its dependencies
                if (!child.isResolved()
                        && (!child.getArtifact().isOptional() || child.isChildOfRootNode())) {
                    Artifact artifact = child.getArtifact();
                    try {
                        if (artifact.getVersion() == null) {
                            // set the recommended version
                            // TODO: maybe its better to just pass the range
                            // through to retrieval and use a transformation?
                            ArtifactVersion version;
                            version = getArtifactVersion(localRepository, remoteRepositories, source, artifact);

                            artifact.selectVersion(version.toString());
                            fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE,
                                    listeners, child);
                        }

                        ResolutionGroup rGroup = source.retrieve(artifact,
                                localRepository, remoteRepositories);

                        // TODO might be better to have source.retreive() throw
                        // a specific exception for this situation
                        // and catch here rather than have it return null
                        if (rGroup == null) {
                            // relocated dependency artifact is declared
                            // excluded, no need to add and recurse further
                            continue;
                        }

                        child.addDependencies(rGroup.getArtifacts(),
                                rGroup.getResolutionRepositories(), filter);
                    }
                    catch (CyclicDependencyException e) {
                        // would like to throw this, but we have crappy stuff in
                        // the repo

                        fireEvent(ResolutionListener.OMIT_FOR_CYCLE, listeners,
                                new ResolutionNode(e.getArtifact(), remoteRepositories, child));
                    }
                    catch (ArtifactMetadataRetrievalException e) {
                        artifact.setDependencyTrail(node.getDependencyTrail());
                        throw new ArtifactResolutionException(
                                "Unable to get dependency information: "
                                        + e.getMessage(), artifact, e);
                    }
View Full Code Here

                    // appropriate POM
                    // But it was reset by the call to setVersionRange on
                    // restricting the version
                    ResolutionNode[] resetNodes = {previous, node};
                    for (int j = 0; j < 2; j++) {
                        Artifact resetArtifact = resetNodes[j]
                                .getArtifact();
                        if (resetArtifact.getVersion() == null
                                && resetArtifact.getVersionRange() != null
                                && resetArtifact.getAvailableVersions() != null) {

                            resetArtifact
                                    .selectVersion(resetArtifact
                                            .getVersionRange()
                                            .matchVersion(
                                                    resetArtifact
                                                            .getAvailableVersions())
                                            .toString());
                            fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE,
                                    listeners, resetNodes[j]);
                        }
View Full Code Here

    }

    private void checkScopeUpdate(ResolutionNode farthest,
            ResolutionNode nearest, List listeners) {
        boolean updateScope = false;
        Artifact farthestArtifact = farthest.getArtifact();
        Artifact nearestArtifact = nearest.getArtifact();

        if (Artifact.SCOPE_RUNTIME.equals(farthestArtifact.getScope())
                && (Artifact.SCOPE_TEST.equals(nearestArtifact.getScope()) || Artifact.SCOPE_PROVIDED
                .equals(nearestArtifact.getScope()))) {
            updateScope = true;
        }

        if (Artifact.SCOPE_COMPILE.equals(farthestArtifact.getScope())
                && !Artifact.SCOPE_COMPILE.equals(nearestArtifact.getScope())) {
            updateScope = true;
        }

        // current POM rules all
        if (nearest.getDepth() < 2 && updateScope) {
            updateScope = false;

            fireEvent(ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners,
                    nearest, farthestArtifact);
        }

        if (updateScope) {
            fireEvent(ResolutionListener.UPDATE_SCOPE, listeners, nearest,
                    farthestArtifact);

            // previously we cloned the artifact, but it is more effecient to
            // just update the scope
            // if problems are later discovered that the original object needs
            // its original scope value, cloning may
            // again be appropriate
            nearestArtifact.setScope(farthestArtifact.getScope());
        }
    }
View Full Code Here

        archiver.setArchiver(jarArchiver);
        archiver.setOutputFile(archiveFile);

        try {
            // include the features XML file
            Artifact featureArtifact = factory.createArtifactWithClassifier(project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", KarArtifactInstaller.FEATURES_CLASSIFIER);
            jarArchiver.addFile(featuresFile, repositoryPath + layout.pathOf(featureArtifact));

            for (Artifact artifact : bundles) {
                resolver.resolve(artifact, remoteRepos, localRepo);
                File localFile = artifact.getFile();
View Full Code Here

       
        StringBuffer buf = new StringBuffer();
        StringBuffer keyBuf = new StringBuffer();
        for ( Iterator ii = project.getDependencyArtifacts().iterator(); ii.hasNext(); /**/)
        {
            Artifact dep = ( Artifact ) ii.next();
            keyBuf.setLength( 0 );
            keyBuf.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() );
            String depKey = keyBuf.toString();
           
            // -------------------------------------------------------------------
            // Add only provided dependent artifacts that have not been excluded
            // -------------------------------------------------------------------
           
            if ( dep.getScope().equalsIgnoreCase( "provided" ) )
            {
                if ( dep.getArtifactId().equalsIgnoreCase( "org.osgi.core" ) ||
                     exclusions.contains( depKey ) )
                {
                    excluded.add( depKey );
                    continue;
                }
               
                included.add( depKey );
                buf.append( dep.getFile().toURL() );
                buf.append( " " );
            }
        }
       
        keyBuf.setLength( 0 );
View Full Code Here

        } else {
            // Look from attached artifacts.
            @SuppressWarnings("unchecked")
            List<Artifact> attached = m_project.getAttachedArtifacts();
            for (int i = 0; in == null && attached != null && i < attached.size(); i++) {
                Artifact artifact = attached.get(i);
                if (artifact.hasClassifier() && m_inputClassifier.equals(artifact.getClassifier())) {
                    in = artifact.getFile();
                }
            }

            if (in == null) {
                throw new MojoExecutionException("Cannot find the file to manipulate, " +
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.Artifact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.