Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
maven-core-3.8.6.jar - Maven Core Module
maven-core-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Core module.
Apache Maven is a software project management and comprehension tool.
JAR File Size and Download Location:
File: 646022 06-06-2022 16:16 lib/maven-core-3.8.6.jar Download: Apache Maven Website
✍: FYIcenter.com
⏎ org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
package org.apache.maven.lifecycle.internal.builder.multithreaded; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.BuildThreadFactory; import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder; import org.apache.maven.lifecycle.internal.ProjectBuildList; import org.apache.maven.lifecycle.internal.ProjectSegment; import org.apache.maven.lifecycle.internal.ReactorBuildStatus; import org.apache.maven.lifecycle.internal.ReactorContext; import org.apache.maven.lifecycle.internal.TaskSegment; import org.apache.maven.lifecycle.internal.builder.Builder; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; /** * Builds the full lifecycle in weave-mode (phase by phase as opposed to project-by-project). * <p> * This builder uses a number of threads equal to the minimum of the degree of concurrency (which is the thread count * set with <code>-T</code> on the command-line) and the number of projects to build. As such, building a single project * will always result in a sequential build, regardless of the thread count. * </p> * <strong>NOTE:</strong> This class is not part of any public api and can be changed or deleted without prior notice. * * @since 3.0 * @author Kristian Rosenvold * Builds one or more lifecycles for a full module * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. */ @Component( role = Builder.class, hint = "multithreaded" ) public class MultiThreadedBuilder implements Builder { @Requirement private Logger logger; @Requirement private LifecycleModuleBuilder lifecycleModuleBuilder; public MultiThreadedBuilder() { } @Override public void build( MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds, List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus ) throws ExecutionException, InterruptedException { int nThreads = Math.min( session.getRequest().getDegreeOfConcurrency(), session.getProjects().size() ); boolean parallel = nThreads >= 2; // Propagate the parallel flag to the root session and all of the cloned sessions in each project segment session.setParallel( parallel ); for ( ProjectSegment segment : projectBuilds ) { segment.getSession().setParallel( parallel ); } ExecutorService executor = Executors.newFixedThreadPool( nThreads, new BuildThreadFactory() ); CompletionService<ProjectSegment> service = new ExecutorCompletionService<>( executor ); // Currently disabled ThreadOutputMuxer muxer = null; // new ThreadOutputMuxer( analyzer.getProjectBuilds(), System.out ); for ( TaskSegment taskSegment : taskSegments ) { ProjectBuildList segmentProjectBuilds = projectBuilds.getByTaskSegment( taskSegment ); Map<MavenProject, ProjectSegment> projectBuildMap = projectBuilds.selectSegment( taskSegment ); try { ConcurrencyDependencyGraph analyzer = new ConcurrencyDependencyGraph( segmentProjectBuilds, session.getProjectDependencyGraph() ); multiThreadedProjectTaskSegmentBuild( analyzer, reactorContext, session, service, taskSegment, projectBuildMap, muxer ); if ( reactorContext.getReactorBuildStatus().isHalted() ) { break; } } catch ( Exception e ) { session.getResult().addException( e ); break; } } executor.shutdown(); executor.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS ); } private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph analyzer, ReactorContext reactorContext, MavenSession rootSession, CompletionService<ProjectSegment> service, TaskSegment taskSegment, Map<MavenProject, ProjectSegment> projectBuildList, ThreadOutputMuxer muxer ) { // gather artifactIds which are not unique so that the respective thread names can be extended with the groupId Set<String> duplicateArtifactIds = gatherDuplicateArtifactIds( projectBuildList.keySet() ); // schedule independent projects for ( MavenProject mavenProject : analyzer.getRootSchedulableBuilds() ) { ProjectSegment projectSegment = projectBuildList.get( mavenProject ); logger.debug( "Scheduling: " + projectSegment.getProject() ); Callable<ProjectSegment> cb = createBuildCallable( rootSession, projectSegment, reactorContext, taskSegment, muxer, duplicateArtifactIds ); service.submit( cb ); } // for each finished project for ( int i = 0; i < analyzer.getNumberOfBuilds(); i++ ) { try { ProjectSegment projectBuild = service.take().get(); if ( reactorContext.getReactorBuildStatus().isHalted() ) { break; } // MNG-6170: Only schedule other modules from reactor if we have more modules to build than one. if ( analyzer.getNumberOfBuilds() > 1 ) { final List<MavenProject> newItemsThatCanBeBuilt = analyzer.markAsFinished( projectBuild.getProject() ); for ( MavenProject mavenProject : newItemsThatCanBeBuilt ) { ProjectSegment scheduledDependent = projectBuildList.get( mavenProject ); logger.debug( "Scheduling: " + scheduledDependent ); Callable<ProjectSegment> cb = createBuildCallable( rootSession, scheduledDependent, reactorContext, taskSegment, muxer, duplicateArtifactIds ); service.submit( cb ); } } } catch ( InterruptedException e ) { rootSession.getResult().addException( e ); break; } catch ( ExecutionException e ) { // TODO MNG-5766 changes likely made this redundant rootSession.getResult().addException( e ); break; } } } private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession, final ProjectSegment projectBuild, final ReactorContext reactorContext, final TaskSegment taskSegment, final ThreadOutputMuxer muxer, final Set<String> duplicateArtifactIds ) { return new Callable<ProjectSegment>() { public ProjectSegment call() { final Thread currentThread = Thread.currentThread(); final String originalThreadName = currentThread.getName(); final MavenProject project = projectBuild.getProject(); final String threadNameSuffix = duplicateArtifactIds.contains( project.getArtifactId() ) ? project.getGroupId() + ":" + project.getArtifactId() : project.getArtifactId(); currentThread.setName( "mvn-builder-" + threadNameSuffix ); try { // muxer.associateThreadWithProjectSegment( projectBuild ); lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, project, taskSegment ); // muxer.setThisModuleComplete( projectBuild ); return projectBuild; } finally { currentThread.setName( originalThreadName ); } } }; } private Set<String> gatherDuplicateArtifactIds( Set<MavenProject> projects ) { Set<String> artifactIds = new HashSet<>( projects.size() ); Set<String> duplicateArtifactIds = new HashSet<>(); for ( MavenProject project : projects ) { if ( !artifactIds.add( project.getArtifactId() ) ) { duplicateArtifactIds.add( project.getArtifactId() ); } } return duplicateArtifactIds; } }
⏎ org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
Or download all of them as a single archive file:
File name: maven-core-3.8.6-src.zip File size: 550169 bytes Release date: 2022-06-06 Download
⇒ maven-artifact-3.8.6.jar - Maven Artifact Module
⇐ apache-maven-3.8.6-bin.zip - Apache Maven Binary Package
2020-10-26, 128393👍, 0💬
Popular Posts:
JDK 6 tools.jar is the JAR file for JDK 6 tools. It contains Java classes to support different JDK t...
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
What Is ojdbc8.jar for Oracle 12c R2? ojdbc8.jar for Oracle 12c R2 is the JAR files of ojdbc.jar, JD...
How to download and install JDK (Java Development Kit) 6? If you want to write Java applications, yo...
Apache Ant Source Code Files are inside the Apache Ant source package file like apache-ant-1.10.10-s...