本文整理汇总了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;
}
示例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
}
}
示例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");
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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 );
}
示例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 ) );
}
示例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 );
}
}
}
示例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 );
}
}
}
示例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 );
}
}
示例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 ) );
}
示例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;
}
示例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();
}
}