当前位置: 首页>>代码示例>>Java>>正文


Java RepositorySystem类代码示例

本文整理汇总了Java中org.apache.maven.repository.RepositorySystem的典型用法代码示例。如果您正苦于以下问题:Java RepositorySystem类的具体用法?Java RepositorySystem怎么用?Java RepositorySystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RepositorySystem类属于org.apache.maven.repository包,在下文中一共展示了RepositorySystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getArchetypes

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
public @Override List<Archetype> getArchetypes() {
    List<Archetype> lst = new ArrayList<Archetype>();
        List<NBVersionInfo> archs = RepositoryQueries.findArchetypesResult(Collections.singletonList(RepositoryPreferences.getInstance().getLocalRepository())).getResults();
        if (archs == null) {
            return lst;
        }
        for (NBVersionInfo art : archs) {
            Archetype arch = new Archetype(!"maven-archetype".equalsIgnoreCase(art.getPackaging())); //NOI18N
            arch.setArtifactId(art.getArtifactId());
            arch.setGroupId(art.getGroupId());
            arch.setVersion(art.getVersion());
            arch.setName(art.getProjectName());
            arch.setDescription(art.getProjectDescription());
            arch.setRepository(RepositorySystem.DEFAULT_LOCAL_REPO_ID);
            lst.add(arch);
        }
   
    return lst;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:LocalRepoProvider.java

示例2: checkCentral

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
private void checkCentral() {
    String sel = (String)comMirrorOf.getSelectedItem();
    urlmodel.removeAllElements();
    if (RepositorySystem.DEFAULT_REMOTE_REPO_ID.equals(sel)) {
        //see http://docs.codehaus.org/display/MAVENUSER/Mirrors+Repositories
        // for a list of central mirrors.
        //TODO might be worth to externalize somehow.
        urlmodel.addElement("http://mirrors.ibiblio.org/pub/mirrors/maven2"); //NOI18N
        urlmodel.addElement("http://www.ibiblio.net/pub/packages/maven2");//NOI18N
        urlmodel.addElement("http://ftp.cica.es/mirrors/maven2");//NOI18N
        urlmodel.addElement("http://repo1.sonatype.net/maven2");//NOI18N
        urlmodel.addElement("http://repo.exist.com/maven2");//NOI18N
        urlmodel.addElement("http://mirrors.redv.com/maven2");//NOI18N
        urlmodel.addElement("http://mirrors.dotsrc.org/maven2");//NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NewMirrorPanel.java

示例3: onEvent

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
@Override
public void onEvent(Object event) throws Exception {
    if (event instanceof SettingsBuildingResult) {
        logger.debug("[LocalRepositoryDirectorySpy]: Received a " + SettingsBuildingResult.class.getSimpleName());
        String localRepositoryPath = ((SettingsBuildingResult) event).getEffectiveSettings().getLocalRepository();
        if (localRepositoryPath == null) {
            logger.debug("[LocalRepositoryDirectorySpy]: No local repository folder configured in effective settings");
            localRepositoryPath = RepositorySystem.defaultUserLocalRepository.getAbsolutePath();
        }
        File localRepositoryFile = new File(localRepositoryPath);
        if (localRepositoryFile.exists() && localRepositoryFile.isDirectory()) {
            this.localRepositoryDirectory = localRepositoryFile;
            logger.info("[LocalRepositoryDirectorySpy]: LocalRepositoryDirectory is initialized to " + localRepositoryFile.getAbsolutePath());
        } else {
            if (stamper.isEnabled()) {
                throw new FreezeException("[LocalRepositoryDirectorySpy]: Invalid local repository folder " +
                        localRepositoryPath +
                        "in effective settings");
            }
        }
    }
}
 
开发者ID:rvs-fluid-it,项目名称:mvn-fluid-cd,代码行数:23,代码来源:LocalRepositoryDirectorySpy.java

示例4: checkClasspath

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
/**
 * Read current project dependencies and check if it don't grab incorrect
 * artifacts versions which could be in conflict with plugin dependencies.
 *
 * @param project
 *            current project
 * @param repoSystem
 *            repository system
 * @param localRepo
 *            local repository
 * @param remoteRepos
 *            remote repositories
 */
static void checkClasspath(final MavenProject project, final RepositorySystem repoSystem,
        final ArtifactRepository localRepo, final List<ArtifactRepository> remoteRepos) {
    Plugin plugin = project.getPlugin(YangToSourcesMojo.PLUGIN_NAME);
    if (plugin == null) {
        LOG.warn("{} {} not found, dependencies version check skipped", LOG_PREFIX, YangToSourcesMojo.PLUGIN_NAME);
    } else {
        Map<Artifact, Collection<Artifact>> pluginDependencies = new HashMap<>();
        getPluginTransitiveDependencies(plugin, pluginDependencies, repoSystem, localRepo, remoteRepos);

        Set<Artifact> projectDependencies = project.getDependencyArtifacts();
        for (Map.Entry<Artifact, Collection<Artifact>> entry : pluginDependencies.entrySet()) {
            checkArtifact(entry.getKey(), projectDependencies);
            for (Artifact dependency : entry.getValue()) {
                checkArtifact(dependency, projectDependencies);
            }
        }
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:32,代码来源:Util.java

示例5: getPluginTransitiveDependencies

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
/**
 * Read transitive dependencies of given plugin and store them in map.
 *
 * @param plugin
 *            plugin to read
 * @param map
 *            map, where founded transitive dependencies will be stored
 * @param repoSystem
 *            repository system
 * @param localRepository
 *            local repository
 * @param remoteRepos
 *            list of remote repositories
 */
private static void getPluginTransitiveDependencies(final Plugin plugin,
        final Map<Artifact, Collection<Artifact>> map, final RepositorySystem repoSystem,
        final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepos) {

    List<Dependency> pluginDependencies = plugin.getDependencies();
    for (Dependency dep : pluginDependencies) {
        Artifact artifact = repoSystem.createDependencyArtifact(dep);

        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
        request.setArtifact(artifact);
        request.setResolveTransitively(true);
        request.setLocalRepository(localRepository);
        request.setRemoteRepositories(remoteRepos);

        ArtifactResolutionResult result = repoSystem.resolve(request);
        Set<Artifact> pluginDependencyDependencies = result.getArtifacts();
        map.put(artifact, pluginDependencyDependencies);
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:34,代码来源:Util.java

示例6: createLocalRepository

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
private ArtifactRepository createLocalRepository() {
  try {
    return getComponent(RepositorySystem.class).createLocalRepository(new File(myMavenSettings.getLocalRepository()));
  }
  catch (InvalidRepositoryException e) {
    throw new RuntimeException(e);
    // Legacy code.
  }
  //ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
  //ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
  //
  //String url = myMavenSettings.getLocalRepository();
  //if (!url.startsWith("file:")) url = "file://" + url;
  //
  //ArtifactRepository localRepository = factory.createArtifactRepository("local", url, layout, null, null);
  //
  //boolean snapshotPolicySet = myMavenSettings.isOffline();
  //if (!snapshotPolicySet && snapshotUpdatePolicy == MavenServerSettings.UpdatePolicy.ALWAYS_UPDATE) {
  //  factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
  //}
  //factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
  //
  //return localRepository;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:Maven3ServerEmbedderImpl.java

示例7: buildArtifactRepository

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
public static ArtifactRepository buildArtifactRepository( Repository repo,
                                                          ArtifactRepositoryFactory artifactRepositoryFactory,
                                                          PlexusContainer c )
    throws InvalidRepositoryException
{
    RepositorySystem repositorySystem = rs( c );
    RepositorySystemSession session = rss( c );

    ArtifactRepository repository = repositorySystem.buildArtifactRepository( repo );

    if ( session != null )
    {
        repositorySystem.injectMirror( session, Arrays.asList( repository ) );
        repositorySystem.injectProxy( session, Arrays.asList( repository ) );
        repositorySystem.injectAuthentication( session, Arrays.asList( repository ) );
    }

    return repository;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:ProjectUtils.java

示例8: setUp

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
protected void setUp()
    throws Exception
{
    super.setUp();
    
    if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) )
    {
        projectBuilder = lookup( ProjectBuilder.class, "test" );
    }
    else
    {
        // default over to the main project builder...
        projectBuilder = lookup( ProjectBuilder.class );
    }
    
    repositorySystem = lookup( RepositorySystem.class );        
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:AbstractMavenProjectTestCase.java

示例9: getRemoteRepositories

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
protected List<ArtifactRepository> getRemoteRepositories()
    throws Exception
{
    File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile();

    RepositoryPolicy policy = new RepositoryPolicy();
    policy.setEnabled( true );
    policy.setChecksumPolicy( "ignore" );
    policy.setUpdatePolicy( "always" );

    Repository repository = new Repository();
    repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID );
    repository.setUrl( "file://" + repoDir.toURI().getPath() );
    repository.setReleases( policy );
    repository.setSnapshots( policy );

    return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:19,代码来源:LegacyRepositorySystemTest.java

示例10: injectDefaultRepositories

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
private void injectDefaultRepositories( MavenExecutionRequest request )
    throws MavenExecutionRequestPopulationException
{
    Set<String> definedRepositories = getRepoIds( request.getRemoteRepositories() );

    if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) )
    {
        try
        {
            request.addRemoteRepository( repositorySystem.createDefaultRemoteRepository() );
        }
        catch ( InvalidRepositoryException e )
        {
            throw new MavenExecutionRequestPopulationException( "Cannot create default remote repository.", e );
        }
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:DefaultMavenExecutionRequestPopulator.java

示例11: injectDefaultPluginRepositories

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
private void injectDefaultPluginRepositories( MavenExecutionRequest request )
    throws MavenExecutionRequestPopulationException
{
    Set<String> definedRepositories = getRepoIds( request.getPluginArtifactRepositories() );

    if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) )
    {
        try
        {
            request.addPluginArtifactRepository( repositorySystem.createDefaultRemoteRepository() );
        }
        catch ( InvalidRepositoryException e )
        {
            throw new MavenExecutionRequestPopulationException( "Cannot create default remote repository.", e );
        }
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:DefaultMavenExecutionRequestPopulator.java

示例12: createLocalRepository

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
public ArtifactRepository createLocalRepository( MavenExecutionRequest request )
    throws MavenExecutionRequestPopulationException
{
    String localRepositoryPath = null;

    if ( request.getLocalRepositoryPath() != null )
    {
        localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath();
    }

    if ( StringUtils.isEmpty( localRepositoryPath ) )
    {
        localRepositoryPath = RepositorySystem.defaultUserLocalRepository.getAbsolutePath();
    }

    try
    {
        return repositorySystem.createLocalRepository( new File( localRepositoryPath ) );
    }
    catch ( InvalidRepositoryException e )
    {
        throw new MavenExecutionRequestPopulationException( "Cannot create local repository.", e );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:25,代码来源:DefaultMavenExecutionRequestPopulator.java

示例13: getRemoteRepositories

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
protected List<ArtifactRepository> getRemoteRepositories()
    throws InvalidRepositoryException
{
    File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile();

    RepositoryPolicy policy = new RepositoryPolicy();
    policy.setEnabled( true );
    policy.setChecksumPolicy( "ignore" );
    policy.setUpdatePolicy( "always" );

    Repository repository = new Repository();
    repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID );
    repository.setUrl( "file://" + repoDir.toURI().getPath() );
    repository.setReleases( policy );
    repository.setSnapshots( policy );

    return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:19,代码来源:AbstractCoreMavenComponentTestCase.java

示例14: addModelRepository

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
/**
 *
 * @param mdl
 * @param url of the repository
 * @param add true == add to model, will not add if the repo is in project but not in model (eg. central repo)
 * @return null if repository with given url exists, otherwise a returned newly created item.
 */
public static Repository addModelRepository(MavenProject project, POMModel mdl, String url) {
    if (url.contains(RepositorySystem.DEFAULT_REMOTE_REPO_URL) || /* #212336 */url.contains("http://repo1.maven.org/maven2")) {
        return null;
    }
    List<Repository> repos = mdl.getProject().getRepositories();
    if (repos != null) {
        for (Repository r : repos) {
            if (url.equals(r.getUrl())) {
                //already in model..either in pom.xml or added in this session.
                return null;
            }
        }
    }
    
    List<org.apache.maven.model.Repository> reps = project.getRepositories();
    org.apache.maven.model.Repository prjret = null;
    Repository ret = null;
    if (reps != null) {
        for (org.apache.maven.model.Repository re : reps) {
            if (url.equals(re.getUrl())) {
                prjret = re;
                break;
            }
        }
    }
    if (prjret == null) {
        ret = mdl.getFactory().createRepository();
        ret.setUrl(url);
        ret.setId(url);
        mdl.getProject().addRepository(ret);
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:ModelUtils.java

示例15: resolveArtifacts

import org.apache.maven.repository.RepositorySystem; //导入依赖的package包/类
/**
     * resolve the artifacts associated with the archetype (ideally downloads them to the local repository)
     * @param hndl
     * @throws ArtifactResolutionException
     * @throws ArtifactNotFoundException 
     */
    public void resolveArtifacts(AggregateProgressHandle hndl) throws ArtifactResolutionException, ArtifactNotFoundException {
        MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
        
        List<ArtifactRepository> repos;
        if (getRepository() == null) {
            repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID));
        } else {
           repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(), "custom-repo"));//NOI18N
           for (RepositoryInfo info : RepositoryPreferences.getInstance().getRepositoryInfos()) {
                if (getRepository().equals(info.getRepositoryUrl())) {
                    repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(), info.getId()));//NOI18N
                    break;
                }
            }
        }
        try {
            ProgressTransferListener.setAggregateHandle(hndl);
            
            hndl.start();

//TODO how to rewrite to track progress?
//            try {
//                WagonManager wagon = online.getPlexusContainer().lookup(WagonManager.class);
//                wagon.setDownloadMonitor(new ProgressTransferListener());
//            } catch (ComponentLookupException ex) {
//                Exceptions.printStackTrace(ex);
//            }
            online.resolve(getPomArtifact(), repos, online.getLocalRepository());
            online.resolve(getArtifact(), repos, online.getLocalRepository());
        } catch (ThreadDeath d) { // download interrupted
        } catch (IllegalStateException ise) { //download interrupted in dependent thread. #213812
            if (!(ise.getCause() instanceof ThreadDeath)) {
                throw ise;
            }
        } finally {
            ProgressTransferListener.clearAggregateHandle();
            hndl.finish();
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:Archetype.java


注:本文中的org.apache.maven.repository.RepositorySystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。