Package org.apache.maven.artifact.resolver.filter

Examples of org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter


            Map managedDependencies = Collections.EMPTY_MAP;

            ArtifactFilter filter = null;
            if ( useScope != null )
            {
                filter = new ScopeArtifactFilter( useScope );
            }
            if ( type != null )
            {
                TypeArtifactFilter typeArtifactFilter = new TypeArtifactFilter( type );
                if ( filter != null )
View Full Code Here


    // Dependencies (mapped to the AMP file "lib" directory)
    getLog().info("Adding JAR dependencies");
    Set<Artifact> artifacts = project.getArtifacts();
    for (Iterator<Artifact> iter = artifacts.iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();
      ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
      if (!artifact.isOptional() && filter.include(artifact) && "jar".equals(artifact.getType())) {
        zipArchiver.addFile(artifact.getFile(), "lib/" + artifact.getFile().getName());
      }
    }

    File ampFile = new File(targetDirectory, project.getBuild().getFinalName() + ".amp");
View Full Code Here

    }

    private void checkScopeUpdate( ArtifactSpec a, ArtifactSpec b, String expectedScope, String expectedVersion )
        throws ArtifactResolutionException, InvalidVersionSpecificationException
    {
        ScopeArtifactFilter filter;
        if ( Artifact.SCOPE_PROVIDED.equals( expectedScope ) )
        {
            filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
        }
        else if ( Artifact.SCOPE_SYSTEM.equals( expectedScope ) )
        {
            filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
        }
        else
        {
            filter = new ScopeArtifactFilter( expectedScope );
        }

        ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ), filter );
        Artifact artifact = getArtifact( "d", res.getArtifacts() );
        assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact );
View Full Code Here

    // Dependencies (mapped to the AMP file "lib" directory)
    getLog().info("Adding JAR dependencies");
    Set<Artifact> artifacts = project.getArtifacts();
    for (Iterator<Artifact> iter = artifacts.iterator(); iter.hasNext();) {
      Artifact artifact = (Artifact) iter.next();
      ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
      if (!artifact.isOptional() && filter.include(artifact) && "jar".equals(artifact.getType())) {
        zipArchiver.addFile(artifact.getFile(), "lib/" + artifact.getFile().getName());
      }
    }

    File ampFile = new File(targetDirectory, project.getBuild().getFinalName() + ".amp");
View Full Code Here

        MavenProject rootArtifactProject = builder.buildFromRepository( rootArtifactPom, remote, local );

        // load all the artifacts.
        transitiveArtifacts =
            rootArtifactProject.createArtifacts( this.factory, Artifact.SCOPE_TEST,
                                                 new ScopeArtifactFilter( Artifact.SCOPE_TEST ) );

    }
View Full Code Here

        MavenProject rootArtifactProject = builder.buildFromRepository( rootArtifactPom, remote, local );

        // load all the artifacts.
        transitiveArtifacts =
            rootArtifactProject.createArtifacts( this.factory, Artifact.SCOPE_TEST,
                                                 new ScopeArtifactFilter( Artifact.SCOPE_TEST ) );

    }
View Full Code Here

            {
                results = includeSingleScope( artifacts, includeScope );
            }
            else
            {
                ScopeArtifactFilter saf = new ScopeArtifactFilter( includeScope );

                Iterator iter = artifacts.iterator();
                while ( iter.hasNext() )
                {
                    Artifact artifact = (Artifact) iter.next();
                    if ( saf.include( artifact ) )
                    {
                        results.add( artifact );
                    }
                }
            }
        }
        else if ( StringUtils.isNotEmpty( excludeScope ) )
        {
            if ( !Artifact.SCOPE_COMPILE.equals( excludeScope ) && !Artifact.SCOPE_TEST.equals( excludeScope )
                && !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_RUNTIME.equals( excludeScope )
                && !Artifact.SCOPE_SYSTEM.equals( excludeScope ) )
            {
                throw new ArtifactFilterException( "Invalid Scope in excludeScope: " + excludeScope );
            }
            results = new HashSet();
            // plexus ScopeArtifactFilter doesn't handle the provided scope so
            // we
            // need special handling for it.
            if ( Artifact.SCOPE_TEST.equals( excludeScope ) )
            {
                throw new ArtifactFilterException( " Can't exclude Test scope, this will exclude everything." );
            }
            else if ( !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_SYSTEM.equals( excludeScope ) )
            {
                ScopeArtifactFilter saf = new ScopeArtifactFilter( excludeScope );

                Iterator iter = artifacts.iterator();
                while ( iter.hasNext() )
                {
                    Artifact artifact = (Artifact) iter.next();
                    if ( !saf.include( artifact ) )
                    {
                        results.add( artifact );
                    }
                }
            }
View Full Code Here

            Map managedDependencies = pom.getMavenProject().getManagedVersionMap();

            ArtifactFilter filter = null;
            if ( useScope != null )
            {
                filter = new ScopeArtifactFilter( useScope );
            }
            if ( scopes != null )
            {
                filter = new SpecificScopesArtifactFilter( scopes );
            }
View Full Code Here

   * resolve dependencies for the given artifact details using Maven, on the fly
   */
  private Collection resolveDependencies(String groupId, String artifactId, String version) throws Exception {
      Artifact pomArtifact = getArtifact(groupId, artifactId, version);
      MavenProject pomProject = mavenProjectBuilder.buildFromRepository(pomArtifact, remoteArtifactRepositories, localRepository);   
      Collection artifacts = pomProject.createArtifacts(artifactFactory, Artifact.SCOPE_TEST, new ScopeArtifactFilter(Artifact.SCOPE_TEST));
      Iterator i = artifacts.iterator();
      while(i.hasNext()) {
        Artifact a = (Artifact) i.next();
          resolveArtifact(a);
      }
View Full Code Here

                                + targetFileName;
                        getLog().debug("Renamed to: " + targetFileName);
                    }

                    // TODO: utilise appropriate methods from project builder
                    ScopeArtifactFilter filter = new ScopeArtifactFilter(
                            Artifact.SCOPE_RUNTIME);
                    if (!artifact.isOptional() && filter.include(artifact)) {
                        String type = artifact.getType();
                        if ("jar".equals(type)) {
                            copyFileIfModified(artifact.getFile(), new File(
                                    libDir, targetFileName));
                        }
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter

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.