This commit is contained in:
Michael Osipov 2014-02-08 16:56:43 +01:00
commit b4a7780350
15 changed files with 189 additions and 103 deletions

View File

@ -176,7 +176,7 @@ public class DefaultArtifactVersion
if ( tok.hasMoreTokens() )
{
qualifier = tok.nextToken();
fallback = Pattern.compile("\\d+").matcher( qualifier ).matches();
fallback = Pattern.compile( "\\d+" ).matcher( qualifier ).matches();
}
// string tokenzier won't detect these and ignores them

View File

@ -91,7 +91,7 @@ public enum ArtifactScopeEnum
}
}
private static final ArtifactScopeEnum [][][] _compliancySets = {
private static final ArtifactScopeEnum [][][] COMPLIANCY_SETS = {
{ { compile }, { compile, provided, system } }
, { { test }, { compile, test, provided, system } }
, { { runtime }, { compile, runtime, system } }
@ -114,7 +114,7 @@ public enum ArtifactScopeEnum
return scope.id == system.id;
}
for ( ArtifactScopeEnum[][] set : _compliancySets )
for ( ArtifactScopeEnum[][] set : COMPLIANCY_SETS )
{
if ( id == set[0][0].id )
{

View File

@ -320,7 +320,7 @@ public class DefaultMaven
{
afterSessionEnd( projects, session );
}
catch (MavenExecutionException e)
catch ( MavenExecutionException e )
{
return addExceptionToResult( result, e );
}
@ -349,7 +349,7 @@ public class DefaultMaven
{
afterSessionEnd( projects, session );
}
catch (MavenExecutionException e)
catch ( MavenExecutionException e )
{
return addExceptionToResult( result, e );
}

View File

@ -31,11 +31,11 @@ import org.apache.maven.plugin.MojoExecutionException;
*/
public interface MojoExecutionListener
{
public void beforeMojoExecution( MojoExecutionEvent event )
void beforeMojoExecution( MojoExecutionEvent event )
throws MojoExecutionException;
public void afterMojoExecutionSuccess( MojoExecutionEvent event )
void afterMojoExecutionSuccess( MojoExecutionEvent event )
throws MojoExecutionException;
public void afterExecutionFailure( MojoExecutionEvent event );
void afterExecutionFailure( MojoExecutionEvent event );
}

View File

@ -31,14 +31,14 @@ import org.apache.maven.lifecycle.LifecycleExecutionException;
*/
public interface ProjectExecutionListener
{
public void beforeProjectExecution( ProjectExecutionEvent event )
void beforeProjectExecution( ProjectExecutionEvent event )
throws LifecycleExecutionException;
public void beforeProjectLifecycleExecution( ProjectExecutionEvent event )
void beforeProjectLifecycleExecution( ProjectExecutionEvent event )
throws LifecycleExecutionException;
public void afterProjectExecutionSuccess( ProjectExecutionEvent event )
void afterProjectExecutionSuccess( ProjectExecutionEvent event )
throws LifecycleExecutionException;
public void afterProjectExecutionFailure( ProjectExecutionEvent event );
void afterProjectExecutionFailure( ProjectExecutionEvent event );
}

View File

@ -19,7 +19,6 @@ package org.apache.maven.execution;
* under the License.
*/
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.DuplicateProjectException;
@ -29,7 +28,6 @@ import org.codehaus.plexus.util.dag.CycleDetectedException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -49,9 +47,9 @@ public class ReactorManager
// make projects that depend on me, and projects that I depend on
public static final String MAKE_BOTH_MODE = "make-both";
private List blackList = new ArrayList();
private List<String> blackList = new ArrayList<String>();
private Map buildFailuresByProject = new HashMap();
private Map<String, BuildFailure> buildFailuresByProject = new HashMap<String, BuildFailure>();
private Map pluginContextsByProjectAndPluginKey = new HashMap();
@ -59,9 +57,9 @@ public class ReactorManager
private final ProjectSorter sorter;
private Map buildSuccessesByProject = new HashMap();
private Map<String, BuildSuccess> buildSuccessesByProject = new HashMap<String, BuildSuccess>();
public ReactorManager( List projects )
public ReactorManager( List<MavenProject> projects )
throws CycleDetectedException, DuplicateProjectException
{
this.sorter = new ProjectSorter( projects );
@ -123,16 +121,14 @@ public class ReactorManager
{
blackList.add( id );
List dependents = sorter.getDependents( id );
List<String> dependents = sorter.getDependents( id );
if ( dependents != null && !dependents.isEmpty() )
{
for ( Object dependent : dependents )
for ( String dependentId : dependents )
{
String dependentId = (String) dependent;
if ( !buildSuccessesByProject.containsKey( dependentId ) && !buildFailuresByProject.containsKey(
dependentId ) )
if ( !buildSuccessesByProject.containsKey( dependentId )
&& !buildFailuresByProject.containsKey( dependentId ) )
{
blackList( dependentId );
}

View File

@ -35,11 +35,11 @@ import org.apache.maven.plugin.MojoExecutionException;
*/
public interface WeakMojoExecutionListener
{
public void beforeMojoExecution( MojoExecutionEvent event )
void beforeMojoExecution( MojoExecutionEvent event )
throws MojoExecutionException;
public void afterMojoExecutionSuccess( MojoExecutionEvent event )
void afterMojoExecutionSuccess( MojoExecutionEvent event )
throws MojoExecutionException;
public void afterExecutionFailure( MojoExecutionEvent event );
void afterExecutionFailure( MojoExecutionEvent event );
}

View File

@ -1,5 +1,24 @@
package org.apache.maven.lifecycle.internal;
/*
* 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.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
@ -11,7 +30,7 @@ public class BuildThreadFactory
{
private final AtomicInteger ID = new AtomicInteger();
private String PREFIX = "BuilderThread";
private static final String PREFIX = "BuilderThread";
public Thread newThread( Runnable r )
{

View File

@ -145,12 +145,14 @@ public class ProjectBuildList
/**
* @return a set of all the projects managed by the build
*/
public Set<MavenProject> getProjects() {
Set<MavenProject> projects = new HashSet<MavenProject>();
for (ProjectSegment s : items) {
projects.add(s.getProject());
}
return projects;
}
public Set<MavenProject> getProjects()
{
Set<MavenProject> projects = new HashSet<MavenProject>();
for ( ProjectSegment s : items )
{
projects.add( s.getProject() );
}
return projects;
}
}

View File

@ -1,5 +1,24 @@
package org.apache.maven.lifecycle.internal.builder;
/*
* 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.List;
import java.util.concurrent.ExecutionException;
@ -22,7 +41,7 @@ public interface Builder
// Be nice to whittle this down to Session, maybe add task segments to the session. The session really is the
// the place to store reactor related information.
//
public void build( MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds,
List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus )
void build( MavenSession session, ReactorContext reactorContext, ProjectBuildList projectBuilds,
List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus )
throws ExecutionException, InterruptedException;
}

View File

@ -1,9 +1,29 @@
package org.apache.maven.lifecycle.internal.builder;
public class BuilderNotFoundException extends Exception
/*
* 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.
*/
public class BuilderNotFoundException
extends Exception
{
public BuilderNotFoundException(String message)
public BuilderNotFoundException( String message )
{
super(message);
}
super( message );
}
}

View File

@ -53,7 +53,8 @@ import org.codehaus.plexus.logging.Logger;
* 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
public class MultiThreadedBuilder
implements Builder
{
@Requirement
@ -72,9 +73,12 @@ public class MultiThreadedBuilder implements Builder
List<TaskSegment> taskSegments, ReactorBuildStatus reactorBuildStatus )
throws ExecutionException, InterruptedException
{
ExecutorService executor = Executors.newFixedThreadPool(Math.min(session.getRequest().getDegreeOfConcurrency(), session.getProjects().size()), new BuildThreadFactory());
CompletionService<ProjectSegment> service = new ExecutorCompletionService<ProjectSegment>(executor);
ConcurrencyDependencyGraph analyzer = new ConcurrencyDependencyGraph(projectBuilds, session.getProjectDependencyGraph());
ExecutorService executor =
Executors.newFixedThreadPool( Math.min( session.getRequest().getDegreeOfConcurrency(),
session.getProjects().size() ), new BuildThreadFactory() );
CompletionService<ProjectSegment> service = new ExecutorCompletionService<ProjectSegment>( executor );
ConcurrencyDependencyGraph analyzer =
new ConcurrencyDependencyGraph( projectBuilds, session.getProjectDependencyGraph() );
// Currently disabled
ThreadOutputMuxer muxer = null; // new ThreadOutputMuxer( analyzer.getProjectBuilds(), System.out );
@ -189,4 +193,4 @@ public class MultiThreadedBuilder implements Builder
}
};
}
}
}

View File

@ -1,5 +1,24 @@
package org.apache.maven.lifecycle.internal.builder.singlethreaded;
/*
* 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.List;
import org.apache.maven.execution.MavenSession;

View File

@ -1093,7 +1093,7 @@ public class MavenCli
threadConfiguration.contains( "C" ) ? Integer.valueOf( threadConfiguration.replace( "C", "" ) )
* Runtime.getRuntime().availableProcessors() : Integer.valueOf( threadConfiguration );
request.setDegreeOfConcurrency(threads);
request.setDegreeOfConcurrency( threads );
}
if ( commandLine.hasOption( CLIManager.BUILDER ) )

View File

@ -77,11 +77,14 @@ public class DefaultModelValidator
Parent parent = model.getParent();
if ( parent != null )
{
validateStringNotEmpty( "parent.groupId", problems, Severity.FATAL, Version.BASE, parent.getGroupId(), parent );
validateStringNotEmpty( "parent.groupId", problems, Severity.FATAL, Version.BASE, parent.getGroupId(),
parent );
validateStringNotEmpty( "parent.artifactId", problems, Severity.FATAL, Version.BASE, parent.getArtifactId(), parent );
validateStringNotEmpty( "parent.artifactId", problems, Severity.FATAL, Version.BASE,
parent.getArtifactId(), parent );
validateStringNotEmpty( "parent.version", problems, Severity.FATAL, Version.BASE, parent.getVersion(), parent );
validateStringNotEmpty( "parent.version", problems, Severity.FATAL, Version.BASE, parent.getVersion(),
parent );
if ( equals( parent.getGroupId(), model.getGroupId() )
&& equals( parent.getArtifactId(), model.getArtifactId() ) )
@ -95,7 +98,8 @@ public class DefaultModelValidator
{
Severity errOn30 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
validateEnum( "modelVersion", problems, Severity.ERROR, Version.V20, model.getModelVersion(), null, model, "4.0.0" );
validateEnum( "modelVersion", problems, Severity.ERROR, Version.V20, model.getModelVersion(), null, model,
"4.0.0" );
validateStringNoExpression( "groupId", problems, Severity.WARNING, Version.V20, model.getGroupId(), model );
if ( parent == null )
@ -103,7 +107,8 @@ public class DefaultModelValidator
validateStringNotEmpty( "groupId", problems, Severity.FATAL, Version.V20, model.getGroupId(), model );
}
validateStringNoExpression( "artifactId", problems, Severity.WARNING, Version.V20, model.getArtifactId(), model );
validateStringNoExpression( "artifactId", problems, Severity.WARNING, Version.V20, model.getArtifactId(),
model );
validateStringNotEmpty( "artifactId", problems, Severity.FATAL, Version.V20, model.getArtifactId(), model );
validateVersionNoExpression( "version", problems, Severity.WARNING, Version.V20, model.getVersion(), model );
@ -117,13 +122,13 @@ public class DefaultModelValidator
if ( model.getDependencyManagement() != null )
{
validate20RawDependencies( problems, model.getDependencyManagement().getDependencies(),
"dependencyManagement.dependencies.dependency", request );
"dependencyManagement.dependencies.dependency", request );
}
validateRawRepositories( problems, model.getRepositories(), "repositories.repository", request );
validateRawRepositories( problems, model.getPluginRepositories(), "pluginRepositories.pluginRepository",
request );
request );
Build build = model.getBuild();
if ( build != null )
@ -133,8 +138,7 @@ public class DefaultModelValidator
PluginManagement mngt = build.getPluginManagement();
if ( mngt != null )
{
validate20RawPlugins( problems, mngt.getPlugins(), "build.pluginManagement.plugins.plugin",
request );
validate20RawPlugins( problems, mngt.getPlugins(), "build.pluginManagement.plugins.plugin", request );
}
}
@ -681,32 +685,34 @@ public class DefaultModelValidator
return false;
}
private boolean validateVersionNoExpression(String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, InputLocationTracker tracker)
private boolean validateVersionNoExpression( String fieldName, ModelProblemCollector problems, Severity severity,
Version version, String string, InputLocationTracker tracker )
{
if ( !hasExpression( string ) )
{
return true;
}
//
// Acceptable versions for continuous delivery
//
// changelist
// revision
// sha1
//
if( string.trim().contains("${changelist}") || string.trim().contains("${revision}") || string.trim().contains("${sha1}") )
{
return true;
}
addViolation(problems, severity, version, fieldName, null, "contains an expression but should be a constant.", tracker);
return false;
}
if ( !hasExpression( string ) )
{
return true;
}
//
// Acceptable versions for continuous delivery
//
// changelist
// revision
// sha1
//
if ( string.trim().contains( "${changelist}" ) || string.trim().contains( "${revision}" )
|| string.trim().contains( "${sha1}" ) )
{
return true;
}
addViolation( problems, severity, version, fieldName, null, "contains an expression but should be a constant.",
tracker );
return false;
}
private boolean hasExpression( String value )
{
return value != null && value.contains( "${" );
@ -764,8 +770,8 @@ public class DefaultModelValidator
return false;
}
private boolean validateBoolean( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, String sourceHint, InputLocationTracker tracker )
private boolean validateBoolean( String fieldName, ModelProblemCollector problems, Severity severity,
Version version, String string, String sourceHint, InputLocationTracker tracker )
{
if ( string == null || string.length() <= 0 )
{
@ -777,14 +783,14 @@ public class DefaultModelValidator
return true;
}
addViolation( problems, severity, version, fieldName, sourceHint, "must be 'true' or 'false' but is '" + string + "'.",
tracker );
addViolation( problems, severity, version, fieldName, sourceHint, "must be 'true' or 'false' but is '" + string
+ "'.", tracker );
return false;
}
private boolean validateEnum( String fieldName, ModelProblemCollector problems, Severity severity, Version version, String string,
String sourceHint, InputLocationTracker tracker, String... validValues )
private boolean validateEnum( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, String sourceHint, InputLocationTracker tracker, String... validValues )
{
if ( string == null || string.length() <= 0 )
{
@ -804,9 +810,9 @@ public class DefaultModelValidator
return false;
}
private boolean validateBannedCharacters( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, String sourceHint, InputLocationTracker tracker,
String banned )
private boolean validateBannedCharacters( String fieldName, ModelProblemCollector problems, Severity severity,
Version version, String string, String sourceHint,
InputLocationTracker tracker, String banned )
{
if ( string != null )
{
@ -825,8 +831,8 @@ public class DefaultModelValidator
return true;
}
private boolean validateVersion( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, String sourceHint, InputLocationTracker tracker )
private boolean validateVersion( String fieldName, ModelProblemCollector problems, Severity severity,
Version version, String string, String sourceHint, InputLocationTracker tracker )
{
if ( string == null || string.length() <= 0 )
{
@ -845,8 +851,9 @@ public class DefaultModelValidator
}
private boolean validate20ProperSnapshotVersion( String fieldName, ModelProblemCollector problems, Severity severity, Version version,
String string, String sourceHint, InputLocationTracker tracker )
private boolean validate20ProperSnapshotVersion( String fieldName, ModelProblemCollector problems,
Severity severity, Version version, String string,
String sourceHint, InputLocationTracker tracker )
{
if ( string == null || string.length() <= 0 )
{
@ -855,8 +862,8 @@ public class DefaultModelValidator
if ( string.endsWith( "SNAPSHOT" ) && !string.endsWith( "-SNAPSHOT" ) )
{
addViolation( problems, severity, version, fieldName, sourceHint, "uses an unsupported snapshot version format"
+ ", should be '*-SNAPSHOT' instead.", tracker );
addViolation( problems, severity, version, fieldName, sourceHint,
"uses an unsupported snapshot version format" + ", should be '*-SNAPSHOT' instead.", tracker );
return false;
}
@ -864,8 +871,8 @@ public class DefaultModelValidator
}
private boolean validate20PluginVersion( String fieldName, ModelProblemCollector problems, String string,
String sourceHint, InputLocationTracker tracker,
ModelBuildingRequest request )
String sourceHint, InputLocationTracker tracker,
ModelBuildingRequest request )
{
if ( string == null )
{
@ -882,16 +889,16 @@ public class DefaultModelValidator
if ( string.length() <= 0 || "RELEASE".equals( string ) || "LATEST".equals( string ) )
{
addViolation( problems, errOn30, Version.V20, fieldName, sourceHint, "must be a valid version but is '" + string + "'.",
tracker );
addViolation( problems, errOn30, Version.V20, fieldName, sourceHint, "must be a valid version but is '"
+ string + "'.", tracker );
return false;
}
return true;
}
private static void addViolation( ModelProblemCollector problems, Severity severity, Version version, String fieldName,
String sourceHint, String message, InputLocationTracker tracker )
private static void addViolation( ModelProblemCollector problems, Severity severity, Version version,
String fieldName, String sourceHint, String message, InputLocationTracker tracker )
{
StringBuilder buffer = new StringBuilder( 256 );
buffer.append( '\'' ).append( fieldName ).append( '\'' );