Package org.apache.maven.archiva.model

Examples of org.apache.maven.archiva.model.Dependency


    private void addDependencies( List dependencies )
    {
        Iterator it = dependencies.iterator();
        while ( it.hasNext() )
        {
            Dependency dep = (Dependency) it.next();
            String key = DependencyGraphKeys.toManagementKey( dep );

            Rules merged = (Rules) depMap.get( key );
            if ( merged == null )
            {
                // New map entry.
                merged = new Rules();
                merged.artifact = new ArtifactReference();
                merged.artifact.setGroupId( dep.getGroupId() );
                merged.artifact.setArtifactId( dep.getArtifactId() );
                merged.artifact.setClassifier( dep.getClassifier() );
                merged.artifact.setType( dep.getType() );
            }

            merged.artifact.setVersion( dep.getVersion() );
            if ( StringUtils.isNotBlank( dep.getScope() ) )
            {
                merged.scope = dep.getScope();
            }

            merged.addAllExclusions( dep.getExclusions() );

            depMap.put( key, merged );
        }
    }
View Full Code Here


        if ( deps != null )
        {
            for ( int i = 0; i < deps.length; i++ )
            {
                ArtifactReference artiref = toArtifactReference( deps[i] );
                Dependency dep = new Dependency();
                dep.setGroupId( artiref.getGroupId() );
                dep.setArtifactId( artiref.getArtifactId() );
                dep.setVersion( artiref.getVersion() );
                dep.setClassifier( artiref.getClassifier() );
                dep.setClassifier( artiref.getType() );

                model.addDependency( dep );
            }
        }
View Full Code Here

        if ( CollectionUtils.isNotEmpty( model.getDependencyManagement() ) )
        {
            it = model.getDependencyManagement().iterator();
            while ( it.hasNext() )
            {
                Dependency dependency = (Dependency) it.next();
                fromNode.addDependencyManagement( dependency );
            }
        }

        if ( CollectionUtils.isNotEmpty( model.getDependencies() ) )
        {
            it = model.getDependencies().iterator();
            while ( it.hasNext() )
            {
                Dependency dependency = (Dependency) it.next();

                String scope = dependency.getScope();

                // Test scopes *NOT* from root node can be skipped.
                if ( DependencyScope.TEST.equals( scope ) && !isRootNode )
                {
                    // skip add of test scope
                    continue;
                }

                ArtifactReference artifactRef = new ArtifactReference();
                artifactRef.setGroupId( dependency.getGroupId() );
                artifactRef.setArtifactId( dependency.getArtifactId() );
                artifactRef.setVersion( dependency.getVersion() );
                artifactRef.setClassifier( dependency.getClassifier() );
                artifactRef.setType( dependency.getType() );

                DependencyGraphNode toNode = new DependencyGraphNode( artifactRef );

                if ( CollectionUtils.isNotEmpty( dependency.getExclusions() ) )
                {
                    Iterator itexclusion = dependency.getExclusions().iterator();
                    while ( itexclusion.hasNext() )
                    {
                        Exclusion exclusion = (Exclusion) itexclusion.next();
                        toNode.addExclude( exclusion );
                    }
                }

                if ( dependency.isFromParent() )
                {
                    toNode.setFromParent( true );
                }

                // Add node (to)
                graph.addNode( toNode );

                DependencyGraphEdge edge = new DependencyGraphEdge( fromNode.getArtifact(), toNode.getArtifact() );
                edge.setScope( StringUtils.defaultIfEmpty( dependency.getScope(), DependencyScope.COMPILE ) );

                if ( dependency.isOptional() )
                {
                    edge.setDisabled( true );
                    edge.setDisabledType( DependencyGraph.DISABLED_OPTIONAL );
                    edge.setDisabledReason( "Optional Dependency" );
                }
View Full Code Here

        Iterator<Element> it = depsParent.elementIterator( "dependency" );
        while ( it.hasNext() )
        {
            Element elemDependency = it.next();
            Dependency dependency = new Dependency();

            dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) );
            dependency.setArtifactId( elemDependency.elementTextTrim( "artifactId" ) );
            dependency.setVersion( elemDependency.elementTextTrim( "version" ) );

            dependency.setClassifier( StringUtils.defaultString( elemDependency.elementTextTrim( "classifier" ) ) );
            dependency.setType( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "type" ), "jar" ) );
            dependency.setScope( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "scope" ), "compile" ) );
            // Not for v4.0.0 -> dependency.setUrl( elemDependency.elementTextTrim("url") );
            dependency.setOptional( toBoolean( elemDependency.elementTextTrim( "optional" ), false ) );
            if ( DependencyScope.isSystemScoped( dependency ) )
            {
                dependency.setSystemPath( elemDependency.elementTextTrim( "systemPath" ) );
            }

            dependency.setExclusions( getExclusions( elemDependency ) );

            if ( dependencyList.contains( dependency ) )
            {
                // TODO: throw into monitor as "duplicate dependency" issue.
            }
View Full Code Here

        Iterator<Element> it = depsParent.elementIterator( "dependency" );
        while ( it.hasNext() )
        {
            Element elemDependency = it.next();
            Dependency dependency = new Dependency();

            dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) );
            dependency.setArtifactId( elemDependency.elementTextTrim( "artifactId" ) );
            dependency.setVersion( elemDependency.elementTextTrim( "version" ) );

            dependency.setType( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "type" ), "jar" ) );
            dependency.setUrl( elemDependency.elementTextTrim( "url" ) );
            /* Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files.
             *
             * dependency.setClassifier( StringUtils.defaultString( elemDependency.elementTextTrim( "classifier" ) ) );
             * dependency.setScope( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "scope" ), "compile" ) );
             * dependency.setOptional( toBoolean( elemDependency.elementTextTrim( "optional" ), false ) );
             */

            dependency.setSystemPath( elemDependency.elementTextTrim( "jar" ) );

            if ( dependencyList.contains( dependency ) )
            {
                // TODO: throw into monitor as "duplicate dependency" issue.
            }
View Full Code Here

        Map ret = new HashMap();

        Iterator it = dependencies.iterator();
        while ( it.hasNext() )
        {
            Dependency dep = (Dependency) it.next();
            String key = toVersionlessDependencyKey( dep );
            ret.put( key, dep );
        }

        return ret;
View Full Code Here

            return mainDep;
        }

        if ( mainDep == null )
        {
            Dependency dep = ArchivaModelCloner.clone( parentDep );
            dep.setFromParent( true );
            return dep;
        }

        Dependency merged = new Dependency();

        merged.setFromParent( true );

        // Unmerged.
        merged.setGroupId( mainDep.getGroupId() );
        merged.setArtifactId( mainDep.getArtifactId() );

        // Merged.
        merged.setVersion( merge( mainDep.getVersion(), parentDep.getVersion() ) );
        merged.setClassifier( merge( mainDep.getClassifier(), parentDep.getClassifier() ) );
        merged.setType( merge( mainDep.getType(), parentDep.getType() ) );
        merged.setScope( merge( mainDep.getScope(), parentDep.getScope() ) );
        if ( parentDep.isOptional() )
        {
            merged.setOptional( true );
        }

        merged.setSystemPath( merge( mainDep.getSystemPath(), parentDep.getSystemPath() ) );
        merged.setUrl( merge( mainDep.getUrl(), parentDep.getUrl() ) );
        merged.setExclusions( mergeExclusions( mainDep.getExclusions(), parentDep.getExclusions() ) );

        return merged;
    }
View Full Code Here

        {
            List merged = ArchivaModelCloner.cloneDependencies( parentDependencies );
            Iterator it = merged.iterator();
            while ( it.hasNext() )
            {
                Dependency dep = (Dependency) it.next();
                dep.setFromParent( true );
            }
            return merged;
        }

        List merged = new ArrayList();

        Map mainDepMap = createDependencyMap( mainDependencies );
        Map parentDepMap = createDependencyMap( parentDependencies );
        Set uniqueKeys = new HashSet();
        uniqueKeys.addAll( mainDepMap.keySet() );
        uniqueKeys.addAll( parentDepMap.keySet() );

        Iterator it = uniqueKeys.iterator();
        while ( it.hasNext() )
        {
            String key = (String) it.next();
            Dependency parentDep = (Dependency) parentDepMap.get( key );
            Dependency mainDep = (Dependency) mainDepMap.get( key );

            if ( parentDep == null )
            {
                // Means there is no parent dep to override main dep.
                merged.add( mainDep );
View Full Code Here

        {
            List merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt );
            Iterator it = merged.iterator();
            while ( it.hasNext() )
            {
                Dependency dep = (Dependency) it.next();
                dep.setFromParent( true );
            }
            return merged;
        }

        List merged = new ArrayList();

        Map mainDepMap = createDependencyMap( mainDepMgmt );
        Map parentDepMap = createDependencyMap( parentDepMgmt );
        Set uniqueKeys = new HashSet();
        uniqueKeys.addAll( mainDepMap.keySet() );
        uniqueKeys.addAll( parentDepMap.keySet() );

        Iterator it = uniqueKeys.iterator();
        while ( it.hasNext() )
        {
            String key = (String) it.next();
            Dependency parentDep = (Dependency) parentDepMap.get( key );
            Dependency mainDep = (Dependency) mainDepMap.get( key );

            if ( parentDep == null )
            {
                // Means there is no parent depMan entry to override main depMan.
                merged.add( mainDep );
View Full Code Here

        assertNull( "Has no parent project.", project.getParentProject() );

        assertNotNull( "Dependencies", project.getDependencies() );
        assertEquals( "Dependencies.size", 1, project.getDependencies().size() );

        Dependency dep = (Dependency) project.getDependencies().get( 0 );
        assertNotNull( dep );
        assertEquals( "dep.groupId", "org.codehaus.plexus", dep.getGroupId() );
        assertEquals( "dep.artifactId", "plexus-utils", dep.getArtifactId() );
        assertEquals( "dep.version", "1.0.4", dep.getVersion() );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.archiva.model.Dependency

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.