Package org.apache.maven.artifact.repository

Examples of org.apache.maven.artifact.repository.ArtifactRepositoryFactory


    public void testSourceAndTargetRepositoriesMatch()
        throws Exception
    {
        // test that it fails if the same

        ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );

        sourceRepository = factory.createArtifactRepository( "source", targetRepository.getUrl(), targetRepository
            .getLayout(), null, null );

        Artifact artifact = createArtifact( "test", "repository-artifact", "1.0" );

        try
View Full Code Here


    }

    private void createModernSourceRepository()
        throws Exception
    {
        ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );

        ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );

        File sourceBase = getTestFile( "src/test/source-modern-repository" );
        sourceRepository = factory.createArtifactRepository( "source", sourceBase.toURL().toString(), layout, null,
                                                             null );
    }
View Full Code Here

        String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
        ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag,
                                                                                 checksumPolicyFlag );
        ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag,
                                                                                checksumPolicyFlag );
        ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
        ArtifactRepositoryLayout defaultArtifactRepositoryLayout = (ArtifactRepositoryLayout) lookup(
                                                                                                      ArtifactRepositoryLayout.ROLE,
                                                                                                      "default" );
        return artifactRepositoryFactory.createArtifactRepository( "local", getTestFile( "target/local-repo" ).toURI().toURL()
            .toString(), defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
    }
View Full Code Here

        // TODO: release
        // TODO: something in plexus to show all active hooks?
        ArtifactRepositoryLayout repositoryLayout =
            (ArtifactRepositoryLayout) embedder.lookup( ArtifactRepositoryLayout.ROLE, "default" );

        ArtifactRepositoryFactory artifactRepositoryFactory =
            (ArtifactRepositoryFactory) embedder.lookup( ArtifactRepositoryFactory.ROLE );

        String url = settings.getLocalRepository();

        if ( !url.startsWith( "file:" ) )
        {
            url = "file://" + url;
        }

        ArtifactRepository localRepository = new DefaultArtifactRepository( "local", url, repositoryLayout );

        boolean snapshotPolicySet = false;

        if ( commandLine.hasOption( CLIManager.OFFLINE ) )
        {
            settings.setOffline( true );

            snapshotPolicySet = true;
        }

        if ( !snapshotPolicySet && commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) )
        {
            artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
        }

        if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) )
        {
            System.out.println( "+ Enabling strict checksum verification on all artifact downloads." );

            artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
        }
        else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) )
        {
            System.out.println( "+ Disabling strict checksum verification on all artifact downloads." );

            artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
        }

        return localRepository;
    }
View Full Code Here

        setVariableValueToObject( mojo, "altSnapshotDeploymentRepository", "altSnapshotDeploymentRepository::default::http://localhost" );
       
        ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class );
        setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) );

        ArtifactRepositoryFactory repositoryFactory = mock( ArtifactRepositoryFactory.class );
        ArtifactRepository repository = mock( ArtifactRepository.class);
        when( repositoryFactory.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", repositoryLayout, true ) ).thenReturn( repository );
        setVariableValueToObject( mojo, "repositoryFactory", repositoryFactory );
       
        project.setVersion( "1.0-SNAPSHOT" );
       
        assertEquals( repository, mojo.getDeploymentRepository( project ) );
View Full Code Here

        setVariableValueToObject( mojo, "altReleaseDeploymentRepository", "altReleaseDeploymentRepository::default::http://localhost" );
       
        ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class );
        setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) );

        ArtifactRepositoryFactory repositoryFactory = mock( ArtifactRepositoryFactory.class );
        ArtifactRepository repository = mock( ArtifactRepository.class);
        when( repositoryFactory.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost", repositoryLayout, true ) ).thenReturn( repository );
        setVariableValueToObject( mojo, "repositoryFactory", repositoryFactory );
       
        project.setVersion( "1.0" );
       
        assertEquals( repository, mojo.getDeploymentRepository( project ) );
View Full Code Here

    private static Collection<Artifact> downloadArtifact( PlexusContainer container, String groupId, String artifactId,
                                                          String version )
        throws ComponentLookupException, ArtifactNotFoundException, ArtifactResolutionException, IOException
    {
        ArtifactRepositoryFactory factory =
            (ArtifactRepositoryFactory) container.lookup( ArtifactRepositoryFactory.ROLE );

        DefaultRepositoryLayout layout =
            (DefaultRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, "default" );

        ArtifactRepository localRepository =
            factory.createArtifactRepository( "local", getLocalRepositoryURL( container ), layout, null, null );

        List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
        remoteRepositories.add(
            factory.createArtifactRepository( "central", "http://repo1.maven.org/maven2", layout, null, null ) );
        //Load extra repositories from active profile
       
        Settings settings = getSettings( container );
        List<String> profileIds = settings.getActiveProfiles();
        List<Profile> profiles = settings.getProfiles();
        Map<String, Profile> profilesAsMap = settings.getProfilesAsMap();
        if ( profileIds != null && !profileIds.isEmpty() )
        {
            for ( String profileId : profileIds )
            {
                Profile profile = profilesAsMap.get( profileId );
                List<Repository> repos = profile.getRepositories();
                if ( repos != null && !repos.isEmpty() )
                {
                    for ( Repository repo : repos )
                    {
                        remoteRepositories.add( factory.createArtifactRepository( repo.getId(), repo
                            .getUrl(), layout, null, null ) );
                    }
                }
            }
        }
       
        ArtifactFactory artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
        Artifact artifact =
            artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
        Artifact dummyArtifact = artifactFactory.createProjectArtifact( "dummy", "dummy", "1.0" );

        if ( artifact.isSnapshot() )
        {
            remoteRepositories.add( factory.createArtifactRepository( "apache.snapshots",
                                                                      "http://people.apache.org/repo/m2-snapshot-repository",
                                                                      layout, null, null ) );
        }

        ArtifactResolver resolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
View Full Code Here

        String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
        ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag,
                                                                                 checksumPolicyFlag );
        ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag,
                                                                                checksumPolicyFlag );
        ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
        ArtifactRepositoryLayout defaultArtifactRepositoryLayout = (ArtifactRepositoryLayout) lookup(
                                                                                                      ArtifactRepositoryLayout.ROLE,
                                                                                                      "default" );
        return artifactRepositoryFactory.createArtifactRepository( "local", getTestFile( "target/local-repo" ).toURI().toURL()
            .toString(), defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
    }
View Full Code Here

            {
                setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            }
            else
            {
                ArtifactRepositoryFactory artifactRepositoryFactory = getContainer().lookup( ArtifactRepositoryFactory.class );

                setVariableValueToObject( mojo, "stagingDirectory", inputDirectory );
                setVariableValueToObject( mojo, "reactorProjects", Collections.emptyList() );
                setVariableValueToObject( mojo, "localRepository",
                                          artifactRepositoryFactory.createArtifactRepository( "local", "foo", "default",
                                                                                              null, null ) );
                setVariableValueToObject( mojo, "siteTool", getContainer().lookup( SiteTool.class ) );
                setVariableValueToObject( mojo, "siteDirectory", new File("foo") );
                setVariableValueToObject( mojo, "repositories", Collections.emptyList() );
            }
View Full Code Here

        DeployMojo mojo = new DeployMojo();
       
        ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class );
        setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) );

        ArtifactRepositoryFactory repositoryFactory = mock( ArtifactRepositoryFactory.class );
        ArtifactRepository repository = mock( ArtifactRepository.class);
        when( repositoryFactory.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", repositoryLayout, true ) ).thenReturn( repository );
        setVariableValueToObject( mojo, "repositoryFactory", repositoryFactory );
       
        project.setVersion( "1.0-SNAPSHOT" );
       
        assertEquals( repository, mojo.getDeploymentRepository( project, null, null, "altSnapshotDeploymentRepository::default::http://localhost" ) );
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.repository.ArtifactRepositoryFactory

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.