本文整理汇总了Java中org.apache.maven.artifact.resolver.ResolutionListener类的典型用法代码示例。如果您正苦于以下问题:Java ResolutionListener类的具体用法?Java ResolutionListener怎么用?Java ResolutionListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolutionListener类属于org.apache.maven.artifact.resolver包,在下文中一共展示了ResolutionListener类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveProject
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
@NotNull
public MavenServerExecutionResult resolveProject(@NotNull final File file,
@NotNull final Collection<String> activeProfiles,
@NotNull final Collection<String> inactiveProfiles)
throws MavenServerProcessCanceledException, RemoteException {
return doExecute(new Executor<MavenServerExecutionResult>() {
public MavenServerExecutionResult execute() throws Exception {
DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener(myConsoleWrapper);
MavenExecutionResult result = myImpl.resolveProject(file,
new ArrayList<String>(activeProfiles),
new ArrayList<String>(inactiveProfiles),
Arrays.<ResolutionListener>asList(listener));
return createExecutionResult(file, result, listener.getRootNode());
}
});
}
示例2: resolveTransitively
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
public ArtifactResolutionResult resolveTransitively(
Set<Artifact> artifacts,
Artifact originatingArtifact,
List<ArtifactRepository> remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source,
List<ResolutionListener> listeners)
throws ArtifactResolutionException, ArtifactNotFoundException {
return resolveTransitively(
artifacts,
originatingArtifact,
Collections.EMPTY_MAP,
localRepository,
remoteRepositories,
source,
null,
listeners);
}
示例3: collect
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
public ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter,
List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers )
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
injectSession( request );
return collect( artifacts, originatingArtifact, managedVersions, request, source, filter, listeners,
conflictResolvers );
}
示例4: checkScopeUpdate
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
private void checkScopeUpdate(ResolutionNode farthest,
ResolutionNode nearest, List listeners) {
boolean updateScope = false;
Artifact farthestArtifact = farthest.getArtifact();
Artifact nearestArtifact = nearest.getArtifact();
if (Artifact.SCOPE_RUNTIME.equals(farthestArtifact.getScope())
&& (Artifact.SCOPE_TEST.equals(nearestArtifact.getScope()) || Artifact.SCOPE_PROVIDED
.equals(nearestArtifact.getScope()))) {
updateScope = true;
}
if (Artifact.SCOPE_COMPILE.equals(farthestArtifact.getScope())
&& !Artifact.SCOPE_COMPILE.equals(nearestArtifact.getScope())) {
updateScope = true;
}
// current POM rules all
if (nearest.getDepth() < 2 && updateScope) {
updateScope = false;
fireEvent(ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners,
nearest, farthestArtifact);
}
if (updateScope) {
fireEvent(ResolutionListener.UPDATE_SCOPE, listeners, nearest,
farthestArtifact);
// previously we cloned the artifact, but it is more effecient to
// just update the scope
// if problems are later discovered that the original object needs
// its original scope value, cloning may
// again be appropriate
nearestArtifact.setScope(farthestArtifact.getScope());
}
}
示例5: resolveProject
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
@NotNull
public MavenServerExecutionResult resolveProject(@NotNull final File file,
@NotNull final Collection<String> activeProfiles)
throws MavenServerProcessCanceledException, RemoteException {
return doExecute(new Executor<MavenServerExecutionResult>() {
public MavenServerExecutionResult execute() throws Exception {
DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener(myConsoleWrapper);
MavenExecutionResult result = myImpl.resolveProject(file,
new ArrayList<String>(activeProfiles),
Arrays.<ResolutionListener>asList(listener));
return createExecutionResult(file, result, listener.getRootNode());
}
});
}
示例6: manageArtifact
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions,
List<ResolutionListener> listeners )
{
Artifact artifact = (Artifact) managedVersions.get( node.getKey() );
// Before we update the version of the artifact, we need to know
// whether we are working on a transitive dependency or not. This
// allows depMgmt to always override transitive dependencies, while
// explicit child override depMgmt (viz. depMgmt should only
// provide defaults to children, but should override transitives).
// We can do this by calling isChildOfRootNode on the current node.
if ( ( artifact.getVersion() != null )
&& ( !node.isChildOfRootNode() || node.getArtifact().getVersion() == null ) )
{
fireEvent( ResolutionListener.MANAGE_ARTIFACT_VERSION, listeners, node, artifact );
node.getArtifact().setVersion( artifact.getVersion() );
}
if ( ( artifact.getScope() != null ) && ( !node.isChildOfRootNode() || node.getArtifact().getScope() == null ) )
{
fireEvent( ResolutionListener.MANAGE_ARTIFACT_SCOPE, listeners, node, artifact );
node.getArtifact().setScope( artifact.getScope() );
}
if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) && ( node.getArtifact().getFile() == null )
&& ( artifact.getFile() != null ) )
{
fireEvent( ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH, listeners, node, artifact );
node.getArtifact().setFile( artifact.getFile() );
}
}
示例7: internalResolveProject
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
private MavenResult internalResolveProject(
File pom,
List<String> activeProfiles,
List<String> inactiveProfiles,
List<ResolutionListener> dependencyTreeResolutionListeners) {
MavenExecutionRequest request =
newMavenRequest(pom, activeProfiles, inactiveProfiles, Collections.emptyList());
request.setUpdateSnapshots(updateSnapshots);
AtomicReference<MavenResult> reference = new AtomicReference<>();
runMavenRequest(
request,
() -> {
try {
ProjectBuilder builder = getMavenComponent(ProjectBuilder.class);
List<ProjectBuildingResult> resultList =
builder.build(
Collections.singletonList(pom), false, request.getProjectBuildingRequest());
ProjectBuildingResult result = resultList.get(0);
MavenProject mavenProject = result.getProject();
RepositorySystemSession repositorySession =
getMavenComponent(LegacySupport.class).getRepositorySession();
if (repositorySession instanceof DefaultRepositorySystemSession) {
((DefaultRepositorySystemSession) repositorySession)
.setTransferListener(new ArtifactTransferListener(mavenProgressNotifier));
if (workspaceCache != null) {
((DefaultRepositorySystemSession) repositorySession)
.setWorkspaceReader(new MavenWorkspaceReader(workspaceCache));
}
}
List<Exception> exceptions = new ArrayList<>();
loadExtensions(mavenProject, exceptions);
mavenProject.setDependencyArtifacts(
mavenProject.createArtifacts(getMavenComponent(ArtifactFactory.class), null, null));
ArtifactResolutionRequest resolutionRequest = new ArtifactResolutionRequest();
resolutionRequest.setArtifact(mavenProject.getArtifact());
resolutionRequest.setRemoteRepositories(mavenProject.getRemoteArtifactRepositories());
resolutionRequest.setArtifactDependencies(mavenProject.getDependencyArtifacts());
resolutionRequest.setListeners(dependencyTreeResolutionListeners);
resolutionRequest.setLocalRepository(localRepo);
resolutionRequest.setManagedVersionMap(mavenProject.getManagedVersionMap());
resolutionRequest.setResolveTransitively(true);
resolutionRequest.setResolveRoot(false);
ArtifactResolver resolver = getMavenComponent(ArtifactResolver.class);
ArtifactResolutionResult resolve = resolver.resolve(resolutionRequest);
mavenProject.setArtifacts(resolve.getArtifacts());
reference.set(new MavenResult(mavenProject, exceptions));
} catch (Exception e) {
reference.set(new MavenResult(null, null, Collections.singletonList(e)));
}
});
return reference.get();
}
示例8: fireEvent
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
private void fireEvent(int event, List listeners, ResolutionNode node,
Artifact replacement, VersionRange newRange) {
for (Iterator i = listeners.iterator(); i.hasNext();) {
ResolutionListener listener = (ResolutionListener) i.next();
switch (event) {
case ResolutionListener.TEST_ARTIFACT:
listener.testArtifact(node.getArtifact());
break;
case ResolutionListener.PROCESS_CHILDREN:
listener.startProcessChildren(node.getArtifact());
break;
case ResolutionListener.FINISH_PROCESSING_CHILDREN:
listener.endProcessChildren(node.getArtifact());
break;
case ResolutionListener.INCLUDE_ARTIFACT:
listener.includeArtifact(node.getArtifact());
break;
case ResolutionListener.OMIT_FOR_NEARER:
String version = node.getArtifact().getVersion();
String replacementVersion = replacement.getVersion();
if (version != null ? !version.equals(replacementVersion)
: replacementVersion != null) {
listener.omitForNearer(node.getArtifact(), replacement);
}
break;
case ResolutionListener.OMIT_FOR_CYCLE:
listener.omitForCycle(node.getArtifact());
break;
case ResolutionListener.UPDATE_SCOPE:
listener
.updateScope(node.getArtifact(), replacement.getScope());
break;
case ResolutionListener.UPDATE_SCOPE_CURRENT_POM:
listener.updateScopeCurrentPom(node.getArtifact(), replacement
.getScope());
break;
case ResolutionListener.MANAGE_ARTIFACT:
listener.manageArtifact(node.getArtifact(), replacement);
break;
case ResolutionListener.SELECT_VERSION_FROM_RANGE:
listener.selectVersionFromRange(node.getArtifact());
break;
case ResolutionListener.RESTRICT_RANGE:
if (node.getArtifact().getVersionRange().hasRestrictions()
|| replacement.getVersionRange().hasRestrictions()) {
listener.restrictRange(node.getArtifact(), replacement,
newRange);
}
break;
default:
throw new IllegalStateException("Unknown event: " + event);
}
}
}
示例9: checkScopeUpdate
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
/**
* Check if the artifactScope needs to be updated. <a
* href="http://docs.codehaus.org/x/IGU#DependencyMediationandConflictResolution-Scoperesolution">More info</a>.
*
* @param farthest farthest resolution node
* @param nearest nearest resolution node
* @param listeners
*/
boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List<ResolutionListener> listeners )
{
boolean updateScope = false;
Artifact farthestArtifact = farthest.getArtifact();
Artifact nearestArtifact = nearest.getArtifact();
/* farthest is runtime and nearest has lower priority, change to runtime */
if ( Artifact.SCOPE_RUNTIME.equals( farthestArtifact.getScope() )
&& ( Artifact.SCOPE_TEST.equals( nearestArtifact.getScope() )
|| Artifact.SCOPE_PROVIDED.equals( nearestArtifact.getScope() ) ) )
{
updateScope = true;
}
/* farthest is compile and nearest is not (has lower priority), change to compile */
if ( Artifact.SCOPE_COMPILE.equals( farthestArtifact.getScope() )
&& !Artifact.SCOPE_COMPILE.equals( nearestArtifact.getScope() ) )
{
updateScope = true;
}
/* current POM rules all, if nearest is in current pom, do not update its artifactScope */
if ( ( nearest.getDepth() < 2 ) && updateScope )
{
updateScope = false;
fireEvent( ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners, nearest, farthestArtifact );
}
if ( updateScope )
{
fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact );
// previously we cloned the artifact, but it is more effecient to just update the artifactScope
// if problems are later discovered that the original object needs its original artifactScope value, cloning
// may
// again be appropriate
nearestArtifact.setScope( farthestArtifact.getScope() );
}
return updateScope;
}
示例10: fireEvent
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
private void fireEvent( int event, List<ResolutionListener> listeners, ResolutionNode node )
{
fireEvent( event, listeners, node, null );
}
示例11: collect
import org.apache.maven.artifact.resolver.ResolutionListener; //导入依赖的package包/类
ArtifactResolutionResult collect( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactResolutionRequest repositoryRequest, ArtifactMetadataSource source,
ArtifactFilter filter, List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers );