Package org.apache.maven.artifact

Examples of org.apache.maven.artifact.DefaultArtifact


    public void testFileNameClassifier()
        throws MojoExecutionException
    {
        ArtifactHandler ah = new DefaultArtifactHandlerStub( "jar", "sources" );
        VersionRange vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
        Artifact artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "jar", "sources", ah,
                                                 false );

        String name = DependencyUtil.getFormattedFileName( artifact, false );
        String expectedResult = "two-1.1-SNAPSHOT-sources.jar";
        assertEquals( expectedResult, name );

        name = DependencyUtil.getFormattedFileName( artifact, true );
        expectedResult = "two-sources.jar";
        assertEquals( expectedResult, name );

        ah = new DefaultArtifactHandlerStub( "war", null );
        artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false );
        name = DependencyUtil.getFormattedFileName( artifact, true );
        expectedResult = "two.war";
        assertEquals( expectedResult, name );

    }
View Full Code Here


        // returns
        // the actual name of the file if available unless remove version is
        // set.
        ArtifactHandler ah = new DefaultArtifactHandlerStub( "war", "sources" );
        VersionRange vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
        Artifact artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "sources", ah,
                                                 false );
        File file = new File( "/target", "test-file-name.jar" );
        artifact.setFile( file );

        String name = DependencyUtil.getFormattedFileName( artifact, false );
        String expectedResult = "two-1.1-SNAPSHOT-sources.war";
        assertEquals( expectedResult, name );

        name = DependencyUtil.getFormattedFileName( artifact, true );
        expectedResult = "two-sources.war";
        assertEquals( expectedResult, name );

        artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false );
        name = DependencyUtil.getFormattedFileName( artifact, true );
        expectedResult = "two.war";
        assertEquals( expectedResult, name );

        // test that we pickup the correct extension in the file name if set.
        ah = new DefaultArtifactHandlerStub( "jar", null );
        artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false );
        name = DependencyUtil.getFormattedFileName( artifact, true );
        expectedResult = "two.jar";
        assertEquals( expectedResult, name );

    }
View Full Code Here

   
    //Fetch "org.inframesh.boot-jar"
    if(bootable) {
      VersionRange range = null;
      range = VersionRange.createFromVersion("1.0.0");
      Artifact bootJarArtifact = new DefaultArtifact("org.inframesh", "boot-jar", range, null, "jar", null, new DefaultArtifactHandler());
      String bootjarPath = localRepository.getBasedir() + File.separator + localRepository.pathOf(bootJarArtifact) + ".jar";
      try {
        JarUtil.decompress(bootjarPath, classesDirectory, "org.*");
      } catch (IOException e1) {
        e1.printStackTrace();
View Full Code Here

        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

        ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );

        ArtifactRepository repo = artifactRepositoryFactory.createArtifactRepository( "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" );

        wagon.clearExpectedContent();
        wagon.addExpectedContent( "path", "lower-case-checksum" );
View Full Code Here

                                                                        } );

        setupDefaultProject( project );

        ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
        String path = repo.pathOf( new DefaultArtifact( "test",
                                                        "test",
                                                        VersionRange.createFromVersion( "1.0" ),
                                                        null,
                                                        "jar",
                                                        "",
View Full Code Here

                                                                        } );

        setupDefaultProject( project );

        ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject( mojo, "localRepository" );
        String path = repo.pathOf( new DefaultArtifact( "test",
                                                        "test",
                                                        VersionRange.createFromVersion( "1.2" ),
                                                        null,
                                                        "jar",
                                                        "",
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.