Package org.apache.maven.artifact

Examples of org.apache.maven.artifact.DefaultArtifact


        return createArtifact( groupId, artifactId, version, null, packaging );
    }

    public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
    {
        return new DefaultArtifact( groupId, artifactId, version, scope, type, null, new TestArtifactHandler( type ) );
    }
View Full Code Here


    }

    public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type,
                                                  String classifier )
    {
        return new DefaultArtifact( groupId, artifactId, version, null, type, classifier,
                                    new TestArtifactHandler( type ) );
    }
View Full Code Here

    }

    public Artifact createDependencyArtifact( Dependency dependency )
    {
        Artifact artifact =
            new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(),
                                 dependency.getScope(), dependency.getType(), dependency.getClassifier(),
                                 new TestArtifactHandler( dependency.getType() ) );

        if ( Artifact.SCOPE_SYSTEM.equals( dependency.getScope() ) )
        {
            artifact.setFile( new File( dependency.getSystemPath() ) );
            artifact.setResolved( true );
        }

        return artifact;
    }
View Full Code Here

                                            new ArtifactRepositoryPolicy() );
    }

    public Artifact createPluginArtifact( Plugin plugin )
    {
        return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null,
                                    "maven-plugin", null, new TestArtifactHandler( "maven-plugin", "jar" ) );
    }
View Full Code Here

               && artifact.getType().equals(type)
               && ((classifier == null && artifact.getClassifier() == null) || (classifier != null && classifier.equals(artifact.getClassifier()))) ) {
                return artifact;
            }
        }
        final Artifact prjArtifact = new DefaultArtifact(groupId,
                artifactId,
                VersionRange.createFromVersion(version),
                Artifact.SCOPE_PROVIDED,
                type,
                classifier,
View Full Code Here

                File tmpFile = File.createTempFile("slingClipseTmp", fileExtension);
                FileOutputStream fos = new FileOutputStream(tmpFile);

                try {
                    IOUtils.copy(in, fos);
                    Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, version, "", fileExtension, "",
                            new DefaultArtifactHandler());
                    dai.install(tmpFile, jarArtifact, maven.getLocalRepository());
                } finally {
                    IOUtils.closeQuietly(in);
                    IOUtils.closeQuietly(fos);
View Full Code Here

            final ArtifactResolver resolver,
            final MavenProject project,
            final MavenSession session,
            final Dependency d)
    throws MavenExecutionException {
        final Artifact prjArtifact = new DefaultArtifact(d.getGroupId(),
                d.getArtifactId(),
                VersionRange.createFromVersion(d.getVersion()),
                Artifact.SCOPE_PROVIDED,
                d.getType(),
                d.getClassifier(),
                artifactHandlerManager.getArtifactHandler(d.getType()));
        try {
            resolver.resolve(prjArtifact, project.getRemoteArtifactRepositories(), session.getLocalRepository());
        } catch (final ArtifactResolutionException e) {
            throw new MavenExecutionException("Unable to get artifact for " + d, e);
        } catch (final ArtifactNotFoundException e) {
            throw new MavenExecutionException("Unable to get artifact for " + d, e);
        }
        return prjArtifact.getFile();
    }
View Full Code Here

  private Artifact getArtifact(MavenProject parent) {
      Artifact art = parent.getArtifact();
      if (art == null) {
          // happens for Maven 2.x
          DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler("pom");
          art = new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(), VersionRange.createFromVersion(parent.getVersion()),
                  null, "pom", "", artifactHandler);
      }
        return art;
    }
View Full Code Here

                                          ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
        ArtifactRepository repo =
            new DefaultArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy );

        Artifact artifact =
            new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ), "scope",
                                 "jar", "classifier", null );
        artifact.setFile( getTestFile( "target/sample-art" ) );           

        StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
       
        artifact.getFile().delete();
        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "lower-case-checksum" );
        wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" );

        try
        {
            wagonManager.getArtifact( artifact, repo );
        }
        catch ( ChecksumFailedException e )
        {
            fail( "Checksum verification did not pass: " + e.getMessage() );
        }

        artifact.getFile().delete();
        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "upper-case-checksum" );
        wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" );

        try
        {
            wagonManager.getArtifact( artifact, repo );
        }
        catch ( ChecksumFailedException e )
        {
            fail( "Checksum verification did not pass: " + e.getMessage() );
        }

        artifact.getFile().delete();
        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "expected-failure" );
        wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" );

        try
        {
            wagonManager.getArtifact( artifact, repo );
            fail( "Checksum verification did not fail" );
        }
        catch ( ChecksumFailedException e )
        {
            // expected
        }

        artifact.getFile().delete();
        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "lower-case-checksum" );
        wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" );

        try
        {
            wagonManager.getArtifact( artifact, repo );
        }
        catch ( ChecksumFailedException e )
        {
            fail( "Checksum verification did not pass: " + e.getMessage() );
        }

        artifact.getFile().delete();
        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "upper-case-checksum" );
        wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" );

        try
        {
            wagonManager.getArtifact( artifact, repo );
        }
        catch ( ChecksumFailedException e )
        {
            fail( "Checksum verification did not pass: " + e.getMessage() );
        }

        artifact.getFile().delete();
        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "expected-failure" );
        wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" );

        try
View Full Code Here

    }


    private Artifact convertDependencyToArtifact(Dependency dependency)
    {
        return new DefaultArtifact(dependency.getGroupId(),
                                   dependency.getArtifactId(),
                                   VersionRange.createFromVersion(dependency.getVersion()),
                                   dependency.getScope(),
                                   dependency.getType(),
                                   dependency.getClassifier(),
View Full Code Here

TOP

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

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.