本文整理匯總了Java中org.eclipse.aether.RepositorySystemSession類的典型用法代碼示例。如果您正苦於以下問題:Java RepositorySystemSession類的具體用法?Java RepositorySystemSession怎麽用?Java RepositorySystemSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RepositorySystemSession類屬於org.eclipse.aether包,在下文中一共展示了RepositorySystemSession類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectDependencies
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
@Override
public CollectResult collectDependencies(RepositorySystemSession session, CollectRequest request) throws DependencyCollectionException {
DefaultRepositorySystemSession cloned = new DefaultRepositorySystemSession(session);
DependencyGraphTransformer transformer = session.getDependencyGraphTransformer();
//need to reset the transformer to prevent the transformation to happen and to it below separately.
cloned.setDependencyGraphTransformer(null);
CollectResult res = super.collectDependencies(cloned, request);
CloningDependencyVisitor vis = new CloningDependencyVisitor();
res.getRoot().accept(vis);
//this part copied from DefaultDependencyCollector
try {
DefaultDependencyGraphTransformationContext context =
new DefaultDependencyGraphTransformationContext(session);
res.setRoot(transformer.transformGraph(res.getRoot(), context));
} catch (RepositoryException e) {
res.addException(e);
}
if (!res.getExceptions().isEmpty()) {
throw new DependencyCollectionException(res);
}
res.getRoot().setData("NB_TEST", vis.getRootNode());
return res;
}
示例2: put
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
@Override
public void put(RepositorySystemSession session, Object key, Object data) {
//we just let the pools to get overriden to new value, the worst that can happen is that
//2 pools will coexist
if (ARTIFACT_POOL.equals(key)) {
synchronized (LOCK) {
artifacts = data;
}
return;
}
if (DEPENDENCY_POOL.equals(key)) {
synchronized (LOCK) {
dependencies = data;
}
return;
}
superDelegate.put(session, key, data);
}
示例3: resolve
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
@Override
public Artifact resolve(Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
WorkspaceReader wr = session.getWorkspaceReader();
NbWorkspaceReader nbwr = null;
if (wr instanceof NbWorkspaceReader) {
nbwr = (NbWorkspaceReader)wr;
//this only works reliably because the NbWorkspaceReader is part of the session, not a component
nbwr.silence();
}
try {
return super.resolve(plugin, repositories, session);
} finally {
if (nbwr != null) {
nbwr.normal();
}
}
}
示例4: getLatestVersion
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
private String getLatestVersion(String groupId, String artifactId, String range,
RepositorySystemSession session, List<RemoteRepository> remotes)
throws VersionRangeResolutionException {
VersionRangeRequest rangeRequest = new VersionRangeRequest();
rangeRequest.setArtifact(
new DefaultArtifact(String.format("%s:%s:%s", groupId, artifactId, range)));
rangeRequest.setRepositories(remotes);
VersionRangeResult rangeResult = repoSystem.resolveVersionRange(session, rangeRequest);
if (rangeResult.getHighestVersion() != null) {
return rangeResult.getHighestVersion().toString();
}
else {
throw new com.atomist.rug.resolver.maven.DependencyCollectionException(String
.format("Unable to find a version of archive %s:%s.", groupId, artifactId),
properties.repositories());
}
}
示例5: resolvePluginDependency
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
/**
* Uses the aether to resolve a plugin dependency and returns the file for further processing.
*
* @param d the dependency to resolve.
* @param pluginRepos the plugin repositories to use for dependency resolution.
* @param resolver the resolver for aether access.
* @param repoSystemSession the session for the resolver.
* @return optionally a file which is the resolved dependency.
*/
public static Optional<File> resolvePluginDependency(Dependency d, List<RemoteRepository> pluginRepos,
ArtifactResolver resolver, RepositorySystemSession repoSystemSession) {
Artifact a = new DefaultArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(a);
artifactRequest.setRepositories(pluginRepos);
try {
ArtifactResult artifactResult = resolver.resolveArtifact(repoSystemSession, artifactRequest);
if (artifactResult.getArtifact() != null) {
return Optional.fromNullable(artifactResult.getArtifact().getFile());
}
return Optional.absent();
} catch (ArtifactResolutionException e) {
return Optional.absent();
}
}
示例6: main
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
/**
* Entry point for the JVM forked by {@link #testSeparateJVMs()}.
*/
public static void main(String[] arguments) throws IOException, AlreadyBoundException, NotBoundException {
LocalController localController = new LocalController();
Registry registry = LocateRegistry.createRegistry(REGISTRY_PORT);
Controller controller = (Controller) UnicastRemoteObject.exportObject(localController, 0);
registry.bind(CONTROLLER, controller);
Path lockFile = Paths.get(arguments[0]);
RepositorySystemSession repositorySystemSession = Mockito.mock(RepositorySystemSession.class);
try (FileLockSyncContextFactory syncContextFactory = new FileLockSyncContextFactory(lockFile)) {
new SyncTask(syncContextFactory, localController, repositorySystemSession).run();
}
UnicastRemoteObject.unexportObject(localController, true);
UnicastRemoteObject.unexportObject(registry, true);
}
示例7: setupArtifact
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
@SuppressWarnings( "unchecked" )
void setupArtifact( String groupId, String artifactId, String goal, String type )
throws DuplicateMojoDescriptorException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException {
DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, "DUMMY", "compile", type, "", null );
MojoDescriptor mojoDescriptor = new MojoDescriptor();
mojoDescriptor.setGoal( goal );
PluginDescriptor pluginDescriptor = new PluginDescriptor();
pluginDescriptor.addMojo( mojoDescriptor );
Plugin plugin = new Plugin();
plugin.setGroupId( groupId );
plugin.setArtifactId( artifactId );
when( this.mojo.pluginManager.loadPlugin( eq( plugin ), anyList(), any( RepositorySystemSession.class ) ) ).thenReturn( pluginDescriptor );
this.mojo.pluginDescriptor.getArtifactMap().put( String.format( "%s:%s", groupId, artifactId ), artifact );
}
示例8: create
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
/**
* Uses the passed Settings in order to configure and create the session
* */
public RepositorySystemSession create(){
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setOffline(settings.getOffline()!=null ? settings.getOffline().booleanValue() : false);
session.setIgnoreArtifactDescriptorRepositories(true);
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_WARN);
session.setUpdatePolicy(settings.getUpdatePolicy());
LocalRepository localRepo = new LocalRepository(settings.getLocalRepository());
session.setLocalRepositoryManager( repositorySystem.newLocalRepositoryManager( session, localRepo ) );
session.setRepositoryListener( new microsofia.boot.aether.RepositoryListener() );
session.setTransferListener( new microsofia.boot.aether.TransferListener() );
/*TODO should allow the followig to be configured via settings file? (if needed)
* session.setResolutionErrorPolicy();
session.setArtifactDescriptorPolicy(artifactDescriptorPolicy)
session.setSystemProperties(systemProperties)
session.setUserProperties(userProperties)
session.setConfigProperties(configProperties)*/
return session;
}
示例9: dependencyArtifact
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
public static Artifact dependencyArtifact( RepositorySystemSession repoSession, Dependency dependency )
{
ArtifactTypeRegistry registry = ArtifactTypeRegistry.getDefaultRegistry();
if ( repoSession != null && dependency.getType() != null )
{
ArtifactType type = repoSession.getArtifactTypeRegistry().get( dependency.getType() );
if ( type != null )
{
registry =
registry.registerStereotype( dependency.getType(), type.getExtension(), type.getClassifier() );
}
}
return registry.createTypedArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(),
dependency.getClassifier(), dependency.getVersion() );
}
示例10: resolve
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
@Override
public PluginVersionResult resolve( PluginVersionRequest request )
{
RepositorySystemSession session = request.getRepositorySession();
WorkspaceReader reader = session.getWorkspaceReader();
List<String> versions =
reader.findVersions( new DefaultArtifact( request.getGroupId(), request.getArtifactId(),
Artifact.DEFAULT_EXTENSION, Artifact.DEFAULT_VERSION ) );
final String version = versions.isEmpty() ? Artifact.DEFAULT_VERSION : versions.iterator().next();
final ArtifactRepository repository = reader.getRepository();
return new PluginVersionResult()
{
@Override
public ArtifactRepository getRepository()
{
return repository;
}
@Override
public String getVersion()
{
return version;
}
};
}
示例11: assertDependencyUpdated
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
private void assertDependencyUpdated(final Artifact artifact, final String targetProject,
final String expectedVersion, final String expectedBuildNumber) throws Exception {
final RepositorySystemSession session = newRepositorySystemSession();
final ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
final ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
Dependency targetDependency = null;
for (final Dependency dep : descriptorResult.getDependencies()) {
if (targetProject.equals(dep.getArtifact().getArtifactId())) {
targetDependency = dep;
break;
}
}
assertNotNull(format("No dependency found with artifact-id %s", targetProject), targetDependency);
assertEquals(format("%s%s", expectedVersion, expectedBuildNumber), targetDependency.getArtifact().getVersion());
}
示例12: runMavenRequest
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
public void runMavenRequest(MavenExecutionRequest request, Runnable runnable) {
DefaultMaven maven = (DefaultMaven) getMavenComponent(Maven.class);
RepositorySystemSession repositorySystemSession = maven.newRepositorySession(request);
request.getProjectBuildingRequest().setRepositorySession(repositorySystemSession);
MavenSession mavenSession =
new MavenSession(
container, repositorySystemSession, request, new DefaultMavenExecutionResult());
LegacySupport legacySupport = getMavenComponent(LegacySupport.class);
MavenSession previousSession = legacySupport.getSession();
legacySupport.setSession(mavenSession);
try {
for (AbstractMavenLifecycleParticipant participant :
getLifecycleParticipants(Collections.emptyList())) {
participant.afterSessionStart(mavenSession);
}
runnable.run();
} catch (MavenExecutionException e) {
throw new RuntimeException(e);
} finally {
legacySupport.setSession(previousSession);
}
}
示例13: resolve
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
private void resolve(
Artifact artifact,
List<ArtifactRepository> remoteRepositories,
RepositorySystemSession session)
throws ArtifactResolutionException, ArtifactNotFoundException {
if (isModule(artifact)) {
return;
}
try {
resolveOrig(artifact, remoteRepositories, session);
} catch (AbstractArtifactResolutionException e) {
if (!failOnUnresolvedDependency) {
artifact.setResolved(true);
}
}
}
示例14: populateResult
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
@Override
public void populateResult(RepositorySystemSession session,
ArtifactDescriptorResult result,
Model model) {
super.populateResult(session, result, model);
Parent parent = model.getParent();
if (parent != null) {
DefaultArtifact art =
new DefaultArtifact(parent.getGroupId(),
parent.getArtifactId(),
"pom",
parent.getVersion());
Dependency dep = new Dependency(art, "compile");
result.addDependency(dep);
}
}
開發者ID:NixOS,項目名稱:mvn2nix-maven-plugin,代碼行數:17,代碼來源:ParentPOMPropagatingArtifactDescriptorReaderDelegate.java
示例15: getSdk
import org.eclipse.aether.RepositorySystemSession; //導入依賴的package包/類
public static File getSdk(MavenProject project, RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository>... repos)
throws MojoExecutionException {
Artifact artifact = (Artifact) find(project.getPluginArtifacts(), new Predicate<Artifact>() {
@Override
public boolean apply(Artifact artifact1) {
return (artifact1.getArtifactId().equals("appengine-maven-plugin")
&& artifact1.getGroupId().equals("com.google.appengine"));
}
});
String version = artifact.getVersion();
if(version.endsWith("-SNAPSHOT")) {
String newestVersion = determineNewestVersion(repoSystem, repoSession, repos);
return getSdk(newestVersion, repoSystem, repoSession, repos);
}
return getSdk(version, repoSystem, repoSession, repos);
}