Package org.apache.maven.model

Examples of org.apache.maven.model.Dependency


        return createMavenDependency(dependency, dependency.getName(), null, scope, null, configurations);
    }

    private Dependency createMavenDependency(ModuleDependency dependency, String name, String type, String scope, String classifier,
            Set<Configuration> configurations) {
        Dependency mavenDependency =  new Dependency();
        mavenDependency.setGroupId(dependency.getGroup());
        mavenDependency.setArtifactId(name);
        mavenDependency.setVersion(dependency.getVersion());
        mavenDependency.setType(type);
        mavenDependency.setScope(scope);
        mavenDependency.setOptional(false);
        mavenDependency.setClassifier(classifier);
        mavenDependency.setExclusions(getExclusions(dependency, configurations));
        return mavenDependency;
    }
View Full Code Here


                    if (dependencies != null)
                    {
                        for (final Iterator dependencyIterator = plugin.getDependencies().iterator();
                            dependencyIterator.hasNext();)
                        {
                            final Dependency dependency = (Dependency)dependencyIterator.next();
                            dependency.setScope(Artifact.SCOPE_RUNTIME);
                            this.addDependency(dependency);
                        }
                    }
                }
            }
        }

        // - get all test dependencies, change the scope and add them to them to the dependencies of this
        //   project as runtime scope so that the AndroMDA plugin can see them.
        for (final Iterator iterator = this.project.getTestDependencies().iterator(); iterator.hasNext();)
        {
            final Dependency dependency = (Dependency)iterator.next();
            dependency.setScope(Artifact.SCOPE_RUNTIME);
            this.project.getDependencies().add(dependency);
        }
        for (final Iterator iterator = this.project.getTestArtifacts().iterator(); iterator.hasNext();)
        {
            final Artifact artifact = (Artifact)iterator.next();
View Full Code Here

        final List dependencies = this.project.getDependencies();
        if (dependencies != null && !dependencies.isEmpty())
        {
            for (final Iterator iterator = dependencies.iterator(); iterator.hasNext();)
            {
                final Dependency dependency = (Dependency)iterator.next();
                if (Artifact.SCOPE_PROVIDED.equals(dependency.getScope()))
                {
                    final String file = this.getDependencyFile(dependency);
                    if (file != null)
                    {
                        classpathElements.add(file);
View Full Code Here

        List<DependencyManagement> importMngts = null;

        for ( Iterator<Dependency> it = depMngt.getDependencies().iterator(); it.hasNext(); )
        {
            Dependency dependency = it.next();

            if ( !"pom".equals( dependency.getType() ) || !"import".equals( dependency.getScope() ) )
            {
                continue;
            }

            it.remove();

            String groupId = dependency.getGroupId();
            String artifactId = dependency.getArtifactId();
            String version = dependency.getVersion();

            String imported = groupId + ':' + artifactId + ':' + version;

            if ( importIds.contains( imported ) )
            {
                String message = "The dependencies of type=pom and with scope=import form a cycle: ";
                for ( String modelId : importIds )
                {
                    message += modelId + " -> ";
                }
                message += imported;
                problems.add( Severity.ERROR, message, null, null );

                continue;
            }

            DependencyManagement importMngt =
                getCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT );

            if ( importMngt == null )
            {
                if ( modelResolver == null )
                {
                    throw new IllegalArgumentException( "no model resolver provided, cannot resolve import POM "
                        + ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
                        + ModelProblemUtils.toSourceHint( model ) );
                }

                ModelSource importSource;
                try
                {
                    importSource = modelResolver.resolveModel( groupId, artifactId, version );
                }
                catch ( UnresolvableModelException e )
                {
                    StringBuilder buffer = new StringBuilder( 256 );
                    buffer.append( "Non-resolvable import POM" );
                    if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
                    {
                        buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) );
                    }
                    buffer.append( ": " ).append( e.getMessage() );

                    problems.add( Severity.ERROR, buffer.toString(), dependency.getLocation( "" ), e );
                    continue;
                }

                if ( importRequest == null )
                {
View Full Code Here

        return createDependency( project.getGroupId(), project.getArtifactId(), project.getVersion() );
    }

    private Dependency createDependency( String groupId, String artifactId, String version )
    {
        Dependency depdendency = new Dependency();
        depdendency.setGroupId( groupId );
        depdendency.setArtifactId( artifactId );
        depdendency.setVersion( version );
        return depdendency;
    }
View Full Code Here

        Build build = project.getModel().getBuild();

        Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" );

        Dependency dep = createDependency( "group", "artifact", "1.0" );

        plugin.addDependency( dep );

        build.addPlugin( plugin );
View Full Code Here

        PluginManagement pMgmt = new PluginManagement();

        Plugin plugin = createPlugin( "other.group", "other-artifact", "1.0" );

        Dependency dep = createDependency( "group", "artifact", "1.0" );

        plugin.addDependency( dep );

        pMgmt.addPlugin( plugin );
View Full Code Here

                                          + " will be unresolvable by dependent projects", dependency );
                    }
                }
            }

            Dependency existing = index.get( key );

            if ( existing != null )
            {
                String msg;
                if ( equals( existing.getVersion(), dependency.getVersion() ) )
                {
                    msg =
                        "duplicate declaration of version "
                            + StringUtils.defaultString( dependency.getVersion(), "(?)" );
                }
                else
                {
                    msg =
                        "version " + StringUtils.defaultString( existing.getVersion(), "(?)" ) + " vs "
                            + StringUtils.defaultString( dependency.getVersion(), "(?)" );
                }

                addViolation( problems, errOn31, prefix + ".(groupId:artifactId:type:classifier)", null,
                              "must be unique: " + key + " -> " + msg, dependency );
View Full Code Here

        throws Exception
    {
        Model model = new Model();
        model.setVersion( "3.8.1" );

        Dependency dep = new Dependency();
        dep.setVersion( "${version}" );

        model.addDependency( dep );

        ModelInterpolator interpolator = createInterpolator();
View Full Code Here

        throws Exception
    {
        Model model = new Model();
        model.setVersion( "3.8.1" );

        Dependency dep = new Dependency();
        dep.setVersion( "${something}" );

        model.addDependency( dep );

        /*
         // This is the desired behaviour, however there are too many crappy poms in the repo and an issue with the
View Full Code Here

TOP

Related Classes of org.apache.maven.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.