laeubi commented on a change in pull request #667: URL: https://github.com/apache/maven/pull/667#discussion_r805196635
########## File path: maven-core/src/main/java/org/apache/maven/DefaultMaven.java ########## @@ -367,11 +354,39 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess return result; } + private void setupWorkspaceReader( MavenSession session, DefaultRepositorySystemSession repoSession ) + throws ComponentLookupException + { + // Desired order of precedence for workspace reader before query the local artifact repositories Review comment: Done ########## File path: maven-core/src/main/java/org/apache/maven/DefaultMaven.java ########## @@ -463,51 +484,68 @@ private void validateLocalRepository( MavenExecutionRequest request ) } } - private Collection<AbstractMavenLifecycleParticipant> getLifecycleParticipants( Collection<MavenProject> projects ) + private <T> Collection<T> getExtensionComponents( Collection<MavenProject> projects, Class<T> role ) { - Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = new LinkedHashSet<>(); + Collection<T> foundComponents = new LinkedHashSet<>(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { try { - lifecycleListeners.addAll( container.lookupList( AbstractMavenLifecycleParticipant.class ) ); + foundComponents.addAll( container.lookupList( role ) ); } catch ( ComponentLookupException e ) { // this is just silly, lookupList should return an empty list! - logger.warn( "Failed to lookup lifecycle participants: " + e.getMessage() ); + logger.warn( "Failed to lookup " + role + ": " + e.getMessage() ); } - Collection<ClassLoader> scannedRealms = new HashSet<>(); + foundComponents.addAll( getProjectScopedExtensionComponents( projects, role ) ); + } + finally + { + Thread.currentThread().setContextClassLoader( originalClassLoader ); Review comment: Done ########## File path: maven-core/src/main/java/org/apache/maven/DefaultMaven.java ########## @@ -367,11 +354,39 @@ private MavenExecutionResult doExecute( MavenExecutionRequest request, MavenSess return result; } + private void setupWorkspaceReader( MavenSession session, DefaultRepositorySystemSession repoSession ) + throws ComponentLookupException + { + // Desired order of precedence for workspace reader before query the local artifact repositories + List<WorkspaceReader> workspaceReaders = new ArrayList<WorkspaceReader>(); + // 1) Reactor workspace reader + workspaceReaders.add( container.lookup( WorkspaceReader.class, ReactorReader.HINT ) ); + // 2) Repository system session scoped workspace reader + WorkspaceReader repoWorkspaceReader = repoSession.getWorkspaceReader(); + if ( repoWorkspaceReader != null ) + { + workspaceReaders.add( repoWorkspaceReader ); + } + // 3) .. n) project scoped workspace reader + for ( WorkspaceReader workspaceReader : getProjectScopedExtensionComponents( session.getProjects(), + WorkspaceReader.class ) ) + { + if (workspaceReaders.contains( workspaceReader )) { Review comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org