Package org.apache.maven.artifact.repository

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


    private Artifact getArtifact(
        final Dependency dependency,
        final String scope)
    {
        Artifact artifact = null;
        final ArtifactRepository localRepository = this.localRepository;
        final MavenProject project = this.project;
        if (project != null && localRepository != null)
        {
            if (dependency != null)
            {
                artifact =
                    this.factory.createArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getVersion(),
                        scope,
                        dependency.getType());
                final File file = new File(
                        localRepository.getBasedir(),
                        localRepository.pathOf(artifact));
                artifact.setFile(file);
            }
        }
        return artifact;
    }
View Full Code Here


     */
    private void addDependency(
        final Dependency dependency,
        final String scope)
    {
        final ArtifactRepository localRepository = this.getLocalRepository();
        final MavenProject project = this.getProject();
        if (project != null && localRepository != null)
        {
            if (dependency != null)
            {
                final Artifact artifact =
                    this.getFactory().createArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getVersion(),
                        scope,
                        dependency.getType());
                final File file = new File(
                        localRepository.getBasedir(),
                        localRepository.pathOf(artifact));
                artifact.setFile(file);
                project.getDependencies().add(dependency);
                project.getArtifacts().add(artifact);
            }
        }
View Full Code Here

        if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
        {
            return;
        }

        ArtifactRepository localRepo = request.getLocalRepository();

        File localFile = new File( localRepo.getBasedir(), localRepo.pathOf( artifact ) );

        artifact.setFile( localFile );

        if ( !localFile.exists() )
        {
            if ( request.getRemoteRepositories().isEmpty() )
            {
                throw new IOException( localFile + " does not exist and no remote repositories are configured" );
            }

            ArtifactRepository remoteRepo = request.getRemoteRepositories().get( 0 );

            File remoteFile = new File( remoteRepo.getBasedir(), remoteRepo.pathOf( artifact ) );

            FileUtils.copyFile( remoteFile, localFile );
        }

        artifact.setResolved( true );
View Full Code Here

                return;
            }
        }

        ArtifactRepository localRepository = request.getLocalRepository();
        List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();

        if ( !request.isOffline() )
        {
            Date localCopyLastModified = getLocalCopyLastModified( localRepository, metadata );

            for ( ArtifactRepository repository : remoteRepositories )
            {
                ArtifactRepositoryPolicy policy = metadata.getPolicy( repository );

                File file =
                    new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata,
                                                                                                           repository ) );
                boolean update;

                if ( !policy.isEnabled() )
                {
View Full Code Here

        // snapshot timestamp, or some other timestamp later encoded into the metadata.
        // TODO: this needs to be repeated here so the merging doesn't interfere with the written metadata
        //  - we'd be much better having a pristine input, and an ongoing metadata for merging instead

        Map<ArtifactRepository, Metadata> previousMetadata = new HashMap<ArtifactRepository, Metadata>();
        ArtifactRepository selected = null;
        for ( ArtifactRepository repository : remoteRepositories )
        {
            ArtifactRepositoryPolicy policy = metadata.getPolicy( repository );

            if ( policy.isEnabled() && loadMetadata( metadata, repository, localRepository, previousMetadata ) )
View Full Code Here

                    {
                        return false;
                    }
                    break;
                }
                ArtifactRepository repo1 = it1.next();
                ArtifactRepository repo2 = it2.next();
                if ( !repoEquals( repo1, repo2 ) )
                {
                    return false;
                }
            }
View Full Code Here

            artifact.setResolved( true );

            return;
        }

        ArtifactRepository localRepository = request.getLocalRepository();

        List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();

        if ( !artifact.isResolved() )
        {
            // ----------------------------------------------------------------------
            // Check for the existence of the artifact in the specified local
            // ArtifactRepository. If it is present then simply return as the
            // request for resolution has been satisfied.
            // ----------------------------------------------------------------------

            artifact = localRepository.find( artifact );

            if ( artifact.isResolved() )
            {
                return;
            }

            transformationManager.transformForResolve( artifact, request );

            destination = artifact.getFile();

            if ( !request.isOffline() && ( force || !destination.exists() || isMutable( artifact ) ) )
            {
                try
                {
                    if ( artifact.getRepository() != null )
                    {
                        // the transformations discovered the artifact - so use it exclusively
                        wagonManager.getArtifact( artifact, artifact.getRepository(), downloadMonitor,
                                                  request.isForceUpdate() );
                    }
                    else
                    {
                        wagonManager.getArtifact( artifact, remoteRepositories, downloadMonitor,
                                                  request.isForceUpdate() );
                    }

                    if ( localRepositoryMaintainer != null )
                    {
                        LocalRepositoryMaintainerEvent event =
                            new DefaultLocalRepositoryMaintainerEvent( localRepository, artifact, null );
                        localRepositoryMaintainer.artifactDownloaded( event );
                    }

                }
                catch ( ResourceDoesNotExistException e )
                {
                    throw new ArtifactNotFoundException( e.getMessage(), artifact, remoteRepositories, e );
                }
                catch ( TransferFailedException e )
                {
                    throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
                }
            }

            if ( destination.exists() )
            {
                artifact.setResolved( true );
            }
            else
            {
                if ( request.isOffline() )
                {
                    throw new ArtifactResolutionException( "The repository system is offline"
                        + " and the requested artifact is not locally available at " + destination, artifact,
                                                           remoteRepositories );
                }
                else
                {
                    throw new ArtifactResolutionException( "Failed to resolve artifact, possibly due to a "
                        + "repository list that is not appropriately equipped for this artifact's metadata.", artifact,
                                                           remoteRepositories );
                }
            }

            // 1.0-SNAPSHOT
            //
            // 1)         pom = 1.0-SNAPSHOT
            // 2)         pom = 1.0-yyyymmdd.hhmmss
            // 3) baseVersion = 1.0-SNAPSHOT
            if ( artifact.isSnapshot() && isTimestamped( artifact ) )
            {
                String version = artifact.getVersion();

                // 1.0-SNAPSHOT
                artifact.selectVersion( artifact.getBaseVersion() );

                // Make a file with a 1.0-SNAPSHOT format
                File copy = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );

                // if the timestamped version was resolved or the copy doesn't exist then copy a version
                // of the file like 1.0-SNAPSHOT. Even if there is a timestamped version the non-timestamped
                // version will be created.
                if ( !copy.exists() || copy.lastModified() != destination.lastModified()
View Full Code Here

            {
                if ( repository instanceof Repository )
                {
                    try
                    {
                        ArtifactRepository repo = repositorySystem.buildArtifactRepository( (Repository) repository );
                        repositorySystem.injectMirror( Arrays.asList( repo ), configuration.getMirrors() );
                        repositorySystem.injectProxy( Arrays.asList( repo ), configuration.getProxies() );
                        repositorySystem.injectAuthentication( Arrays.asList( repo ), configuration.getServers() );
                        repos.add( repo );
                    }
View Full Code Here

        return null;
    }

    private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request )
    {
        ArtifactRepository localRepository = request.getLocalRepository();

        // Process all plugin groups in the local repository first to see if we get a hit. A developer may have been
        // developing a plugin locally and installing.
        //
        for ( String pluginGroup : request.getPluginGroups() )
        {
            String localPath = getLocalMetadataPath( pluginGroup, localRepository );

            File groupMetadataFile = new File( localRepository.getBasedir(), localPath );

            PluginPrefixResult result =
                resolveFromRepository( request, pluginGroup, groupMetadataFile, localRepository );

            if ( result != null )
            {
                return result;
            }
        }

        Map<String, List<ArtifactRepository>> recheck = new HashMap<String, List<ArtifactRepository>>();

        // Process all the remote repositories.
        //
        for ( String pluginGroup : request.getPluginGroups() )
        {
            for ( ArtifactRepository repository : request.getRemoteRepositories() )
            {
                String localPath = getLocalMetadataPath( pluginGroup, repository );

                File groupMetadataFile = new File( localRepository.getBasedir(), localPath );

                if ( !request.isOffline() && ( !groupMetadataFile.exists() || request.isForceUpdate() ) )
                {
                    String remotePath = getRemoteMetadataPath( pluginGroup, repository );

                    try
                    {
                        repositorySystem.retrieve( repository, groupMetadataFile, remotePath,
                                                   request.getTransferListener() );
                    }
                    catch ( ArtifactTransferFailedException e )
                    {
                        if ( logger.isDebugEnabled() )
                        {
                            logger.warn( "Failed to retrieve " + remotePath + " from " + repository.getId() + ": "
                                + e.getMessage(), e );
                        }
                        else
                        {
                            logger.warn( "Failed to retrieve " + remotePath + " from " + repository.getId() + ": "
                                + e.getMessage() );
                        }
                    }
                    catch ( ArtifactDoesNotExistException e )
                    {
                        continue;
                    }
                }
                else if ( !request.isOffline() && !request.isForceUpdate() )
                {
                    List<ArtifactRepository> repos = recheck.get( pluginGroup );
                    if ( repos == null )
                    {
                        repos = new ArrayList<ArtifactRepository>();
                        recheck.put( pluginGroup, repos );
                    }
                    repos.add( repository );
                }

                PluginPrefixResult result = resolveFromRepository( request, pluginGroup, groupMetadataFile,
                                                                   repository );

                if ( result != null )
                {
                    return result;
                }
            }
        }

        // Retry the remote repositories for which we previously only consulted the possibly outdated local cache.
        //
        for ( String pluginGroup : request.getPluginGroups() )
        {
            List<ArtifactRepository> repos = recheck.get( pluginGroup );
            if ( repos == null )
            {
                continue;
            }

            for ( ArtifactRepository repository : repos )
            {
                String localPath = getLocalMetadataPath( pluginGroup, repository );

                File groupMetadataFile = new File( localRepository.getBasedir(), localPath );

                String remotePath = getRemoteMetadataPath( pluginGroup, repository );

                try
                {
View Full Code Here

      return;
    }
   
        try {
          ArchetypeManager archetypeManager = MavenPluginActivator.getDefault().getArchetypeManager();
          ArtifactRepository remoteArchetypeRepository = archetypeManager.getArchetypeRepository(archetype);
      properties = (List<RequiredProperty>) archetypeManager.getRequiredProperties(archetype, remoteArchetypeRepository, null);
     
      Table table = propertiesViewer.getTable();
      table.setItemCount(properties.size());
      int i = 0;
View Full Code Here

TOP

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

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.