本文整理汇总了Java中org.sonatype.aether.RepositorySystem类的典型用法代码示例。如果您正苦于以下问题:Java RepositorySystem类的具体用法?Java RepositorySystem怎么用?Java RepositorySystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RepositorySystem类属于org.sonatype.aether包,在下文中一共展示了RepositorySystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishArtifacts
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws DeploymentException {
RemoteRepository gradleRepo = remoteRepository;
if (artifacts.iterator().next().isSnapshot() && remoteSnapshotRepository != null) {
gradleRepo = remoteSnapshotRepository;
}
if (gradleRepo == null) {
throw new GradleException("Must specify a repository for deployment");
}
org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo);
DeployRequest request = new DeployRequest();
request.setRepository(aetherRepo);
for (Artifact artifact : artifacts) {
request.addArtifact(artifact);
}
LOGGER.info("Deploying to {}", gradleRepo.getUrl());
repositorySystem.deploy(session, request);
}
示例2: newRepositorySystemSession
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
public static RepositorySystemSession newRepositorySystemSession(
RepositorySystem system, String localRepoPath) {
Validate.notNull(localRepoPath, "localRepoPath should have a value");
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
LocalRepository localRepo = new LocalRepository(resolveLocalRepoPath(localRepoPath));
session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
if (logger.isDebugEnabled()) {
session.setTransferListener(new TransferListener());
session.setRepositoryListener(new RepositoryListener());
}
// uncomment to generate dirty trees
// session.setDependencyGraphTransformer( null );
return session;
}
示例3: parseDependencyGroupId
import org.sonatype.aether.RepositorySystem; //导入依赖的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;
}
示例4: ArtifactResolver
import org.sonatype.aether.RepositorySystem; //导入依赖的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);
}
示例5: resolve
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
/**
* List of transitive dependencies of the artifact.
* @param root The artifact to work with
* @param scope The scope to work with ("runtime", "test", etc.)
* @param filter The dependency filter to work with
* @return The list of dependencies
* @throws DependencyResolutionException If can't fetch it
*/
public List<Artifact> resolve(final Artifact root,
final String scope, final DependencyFilter filter)
throws DependencyResolutionException {
final List<Artifact> deps = new LinkedList<Artifact>();
final RepositorySystem system = new RepositorySystemBuilder().build();
deps.addAll(
this.fetch(
system,
this.session(system),
new DependencyRequest(
this.request(new Dependency(root, scope)),
filter
)
)
);
return deps;
}
示例6: publishArtifacts
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws InstallationException {
InstallRequest request = new InstallRequest();
for (Artifact artifact : artifacts) {
request.addArtifact(artifact);
}
repositorySystem.install(session, request);
}
示例7: newRepositorySystem
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
private RepositorySystem newRepositorySystem() {
try {
DefaultDeployer deployer = (DefaultDeployer) getContainer().lookup(Deployer.class);
// This is a workaround for https://issues.gradle.org/browse/GRADLE-3324.
// Somehow the ArrayList 'result' in `org.sonatype.aether.impl.internal.Utils#sortMetadataGeneratorFactories` ends up
// being a list of nulls on windows and IBM's 1.6 JDK.
deployer.setMetadataFactories(null);
deployer.addMetadataGeneratorFactory(new VersionsMetadataGeneratorFactory());
deployer.addMetadataGeneratorFactory(new SnapshotMetadataGeneratorFactory());
deployer.addMetadataGeneratorFactory(snapshotVersionManager);
return container.lookup(RepositorySystem.class);
} catch (ComponentLookupException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
示例8: resolve
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
private void resolve( ResolveRequest resolveRequest )
{
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession( system, resolveRequest.localRepoDir );
org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(
resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version );
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot( new Dependency( artifact, "" ) );
// add remote repositories
for ( RemoteRepository remoteRepository : resolveRequest.remoteRepositories )
{
collectRequest.addRepository(
new org.sonatype.aether.repository.RemoteRepository( remoteRepository.getId(), "default",
remoteRepository.getUrl() ) );
}
collectRequest.setRequestContext( "project" );
//collectRequest.addRepository( repo );
try
{
CollectResult collectResult = system.collectDependencies( session, collectRequest );
collectResult.getRoot().accept( resolveRequest.dependencyVisitor );
log.debug( "test" );
}
catch ( DependencyCollectionException e )
{
log.error( e.getMessage(), e );
}
}
示例9: newRepositorySystem
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
private RepositorySystem newRepositorySystem()
{
DefaultServiceLocator locator = new DefaultServiceLocator();
locator.addService( RepositoryConnectorFactory.class,
ArchivaRepositoryConnectorFactory.class );// FileRepositoryConnectorFactory.class );
locator.addService( VersionResolver.class, DefaultVersionResolver.class );
locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class );
locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class );
//locator.addService( RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class );
//locator.setServices( WagonProvider.class, );
return locator.getService( RepositorySystem.class );
}
示例10: newRepositorySystemSession
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
private RepositorySystemSession newRepositorySystemSession( RepositorySystem system, String localRepoDir )
{
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
DependencySelector depFilter = new AndDependencySelector( new ExclusionDependencySelector() );
session.setDependencySelector( depFilter );
session.setLocalRepositoryManager(
new SimpleLocalRepositoryManager( localRepoDir ) );
return session;
}
示例11: newRepositorySystem
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
public static RepositorySystem newRepositorySystem() {
DefaultServiceLocator locator = new DefaultServiceLocator();
locator.addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class);
locator.addService(RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class);
locator.setServices(WagonProvider.class, new ManualWagonProvider());
return locator.getService(RepositorySystem.class);
}
示例12: newRepositorySystemSession
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
public static RepositorySystemSession newRepositorySystemSession(
RepositorySystem system, String localRepoPath) {
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
// find homedir
String home = System.getenv("ZEPPELIN_HOME");
if (home == null) {
home = System.getProperty("zeppelin.home");
}
if (home == null) {
home = "..";
}
String path = home + "/" + localRepoPath;
LocalRepository localRepo =
new LocalRepository(new File(path).getAbsolutePath());
session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
// session.setTransferListener(new ConsoleTransferListener());
// session.setRepositoryListener(new ConsoleRepositoryListener());
// uncomment to generate dirty trees
// session.setDependencyGraphTransformer( null );
return session;
}
示例13: parseDependencyVersion
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
private String parseDependencyVersion(Dependency dependency, MavenRepositorySystemSession mvnRepository, RepositorySystem system,
RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
String parsedVersion;
String version = dependency.getArtifact().getVersion();
if (StringUtils.isEmpty(version)) {
parsedVersion = "[0,)";
} else {
Set<String> properties = getPropertiesFromString(version);
for (String propertyName : properties) {
String parsedProperty = getPropertyFromPom(parsePropertyName(propertyName), mvnRepository, system,
remoteRepository, pomInformation);
if (parsedProperty == null) {
LOGGER.error("The property: {} used in dependency: {} cannot be found in pom " +
"and its parents. For this dependency the latest version will be used",
propertyName, dependency.getArtifact().getArtifactId());
version = "[0,)";
break;
}
version = StringUtils.replace(version, propertyName, parsedProperty);
}
parsedVersion = version;
}
return parsedVersion;
}
示例14: getPropertyFromPom
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
private String getPropertyFromPom(String propertyName, MavenRepositorySystemSession mvnRepository, RepositorySystem system,
RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
Properties properties = pomInformation.getProperties();
String property = properties.getProperty(propertyName);
if (property == null) {
if (pomInformation.getParentPomInformation() == null) {
if (pomInformation.getParent() != null) {
Artifact artifact = new DefaultArtifact(pomInformation.getParent().getGroupId(),
pomInformation.getParent().getArtifactId(), "pom", pomInformation.getParent().getVersion());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
if (pomInformation.getRepositories() != null) {
for (RemoteRepository repository : pomInformation.getRepositories()) {
artifactRequest.addRepository(repository);
}
}
artifactRequest.addRepository(remoteRepository);
ArtifactResult artifactResult = system.resolveArtifact(mvnRepository, artifactRequest);
File parentPOM = artifactResult.getArtifact().getFile();
pomInformation.parseParentPom(parentPOM);
return getPropertyFromPom(propertyName, mvnRepository, system, remoteRepository, pomInformation.getParentPomInformation());
} else {
return null;
}
} else {
return getPropertyFromPom(propertyName, mvnRepository, system, remoteRepository, pomInformation.getParentPomInformation());
}
} else {
return property;
}
}
示例15: repositorySystem
import org.sonatype.aether.RepositorySystem; //导入依赖的package包/类
public static RepositorySystem repositorySystem()
{
MavenServiceLocator locator = new MavenServiceLocator();
locator.addService( RepositoryConnectorFactory.class, AsyncRepositoryConnectorFactory.class);
locator.addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class);
return locator.getService( RepositorySystem.class );
}