本文整理汇总了Java中org.sonatype.aether.repository.RemoteRepository类的典型用法代码示例。如果您正苦于以下问题:Java RemoteRepository类的具体用法?Java RemoteRepository怎么用?Java RemoteRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemoteRepository类属于org.sonatype.aether.repository包,在下文中一共展示了RemoteRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRepoFromProperty
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
private void addRepoFromProperty(String listOfRepo) {
if (listOfRepo != null) {
String[] repos = listOfRepo.split(";");
for (String repo : repos) {
String[] parts = repo.split(",");
if (parts.length == 3) {
String id = parts[0].trim();
String url = parts[1].trim();
boolean isSnapshot = Boolean.parseBoolean(parts[2].trim());
if (id.length() > 1 && url.length() > 1) {
RemoteRepository rr = new RemoteRepository(id, "default", url);
rr.setPolicy(isSnapshot, null);
additionalRepos.add(rr);
}
}
}
}
}
示例2: getArtifactsWithDep
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
/**
*
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
public List<ArtifactResult> getArtifactsWithDep(String dependency,
Collection<String> excludes) throws Exception {
Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
PatternExclusionsDependencyFilter exclusionFilter =
new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
示例3: fetchArtifactWithDep
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep)
throws DependencyResolutionException, ArtifactResolutionException {
Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());
DependencyFilter classpathFilter = DependencyFilterUtils
.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(
dep.getExclusions());
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact,
JavaScopes.COMPILE));
collectRequest.addRepository(mavenCentral);
collectRequest.addRepository(mavenLocal);
for (Repository repo : repositories) {
RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
rr.setPolicy(repo.isSnapshot(), null);
collectRequest.addRepository(rr);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
示例4: getArtifactsWithDep
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
Collection<String> excludes) throws RepositoryException {
Artifact artifact = new DefaultArtifact(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter =
new PatternExclusionsDependencyFilter(excludes);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
try {
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (NullPointerException | DependencyResolutionException ex) {
throw new RepositoryException(
String.format("Cannot fetch dependencies for %s", dependency), ex);
}
}
示例5: getArtifactsWithDep
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
Collection<String> excludes) throws Exception {
Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter =
new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
示例6: parseDependencyGroupId
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
private String parseDependencyGroupId(Dependency dependency, MavenRepositorySystemSession mvnRepository, RepositorySystem system,
RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
String parsedGroupId;
String groupId = dependency.getArtifact().getGroupId();
Set<String> properties = getPropertiesFromString(groupId);
for (String propertyName : properties) {
String parsedProperty = getPropertyFromPom(parsePropertyName(propertyName), mvnRepository, system,
remoteRepository, pomInformation);
if (parsedProperty == null) {
throw new MotechException(String.format("The property: %s used for groupId in dependency: %s cannot be found in pom and its parents.",
propertyName, dependency.getArtifact().getArtifactId()));
}
groupId = StringUtils.replace(groupId, propertyName, parsedProperty);
}
parsedGroupId = groupId;
return parsedGroupId;
}
示例7: makeImageJRepositoryKnown
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
private void makeImageJRepositoryKnown() throws MojoExecutionException {
for (final RemoteRepository repository : remoteRepositories) {
final String url = repository.getUrl();
if (IMAGEJ_REPOSITORY_URL.equals(url)) return;
}
final ArtifactRepositoryLayout layout = repositoryLayouts.get("default");
if (layout == null) {
throw new MojoExecutionException("default", "Invalid repository layout",
"Invalid repository layout: default");
}
final RemoteRepository imagej =
new RemoteRepository("imagej.public", "default", IMAGEJ_REPOSITORY_URL);
remoteRepositories.add(imagej);
}
示例8: ArtifactResolver
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
public ArtifactResolver(String localRepositoryDir, List<String> remoteRepositoryUris)
{
MavenServiceLocator locator = new MavenServiceLocator();
locator.addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class);
locator.addService(RepositoryConnectorFactory.class, AsyncRepositoryConnectorFactory.class);
repositorySystem = locator.getService(RepositorySystem.class);
repositorySystemSession = new MavenRepositorySystemSession();
LocalRepositoryManager localRepositoryManager = new SimpleLocalRepositoryManager(localRepositoryDir);
repositorySystemSession.setLocalRepositoryManager(localRepositoryManager);
repositorySystemSession.setTransferListener(new ConsoleTransferListener());
repositorySystemSession.setRepositoryListener(new ConsoleRepositoryListener());
List<RemoteRepository> repositories = new ArrayList<>(remoteRepositoryUris.size());
int index = 0;
for (String repositoryUri : remoteRepositoryUris) {
repositories.add(new RemoteRepository("repo-" + index++, "default", repositoryUri));
}
this.repositories = Collections.unmodifiableList(repositories);
}
示例9: getMirror
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository )
{
if ( session != null )
{
org.sonatype.aether.repository.MirrorSelector selector = session.getMirrorSelector();
if ( selector != null )
{
RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) );
if ( repo != null )
{
Mirror mirror = new Mirror();
mirror.setId( repo.getId() );
mirror.setUrl( repo.getUrl() );
mirror.setLayout( repo.getContentType() );
return mirror;
}
}
}
return null;
}
示例10: addRepository
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
public void addRepository( Repository repository )
throws InvalidRepositoryException
{
if ( !repositoryIds.add( repository.getId() ) )
{
return;
}
List<RemoteRepository> newRepositories =
Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) );
if ( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT.equals( repositoryMerging ) )
{
repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true );
}
else
{
pomRepositories =
remoteRepositoryManager.aggregateRepositories( session, pomRepositories, newRepositories, true );
repositories =
remoteRepositoryManager.aggregateRepositories( session, pomRepositories, externalRepositories, false );
}
}
示例11: format
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
private static String format( LocalRepository localRepository, List<RemoteRepository> remoteRepositories )
{
String repos = "[";
if ( localRepository != null )
{
repos += localRepository.getId() + " (" + localRepository.getBasedir() + ")";
}
if ( remoteRepositories != null && !remoteRepositories.isEmpty() )
{
for ( RemoteRepository repository : remoteRepositories )
{
repos += ", ";
if ( repository != null )
{
repos += repository.getId() + " (" + repository.getUrl() + ")";
}
}
}
repos += "]";
return repos;
}
示例12: getMojoDescriptor
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
RepositorySystemSession session )
throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
InvalidPluginDescriptorException
{
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin, repositories, session );
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
if ( mojoDescriptor == null )
{
throw new MojoNotFoundException( goal, pluginDescriptor );
}
return mojoDescriptor;
}
示例13: repositoriesEquals
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
public static boolean repositoriesEquals( List<RemoteRepository> r1, List<RemoteRepository> r2 )
{
if ( r1.size() != r2.size() )
{
return false;
}
for ( Iterator<RemoteRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); )
{
if ( !repositoryEquals( it1.next(), it2.next() ) )
{
return false;
}
}
return true;
}
示例14: resolveById
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
@Override
public File resolveById(String id, Log log) throws MojoFailureException {
id = MavenUtil.mvnToAether(id);
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(id));
request.setRepositories((List<RemoteRepository>) projectRepositories);
log.debug("Resolving artifact " + id + " from " + projectRepositories);
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repositorySystemSession, request);
} catch (ArtifactResolutionException e) {
log.warn("Could not resolve " + id, e);
throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e);
}
log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
return result.getArtifact().getFile();
}
示例15: decorate
import org.sonatype.aether.repository.RemoteRepository; //导入依赖的package包/类
@Override
public RemoteRepository decorate(RemoteRepository repo) {
loadBeesConfig();
if (proxyHost != null && proxyPort!=null) {
String proxyType = Proxy.TYPE_HTTP;
if (repo.getUrl().startsWith("https"))
proxyType = Proxy.TYPE_HTTPS;
Proxy proxy = new Proxy(proxyType, proxyHost, Integer.parseInt(proxyPort), null);
if (proxyUser != null) {
Authentication authentication = new Authentication(proxyUser, proxyPass);
proxy.setAuthentication(authentication);
}
repo.setProxy(proxy);
}
return repo;
}