mirror of https://github.com/apache/maven.git
PR: MNG-1011
add default goal handling git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292411 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20116dbc4e
commit
52e8a216ef
|
@ -42,8 +42,8 @@ import org.apache.maven.profiles.DefaultProfileManager;
|
|||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.reactor.ReactorException;
|
||||
import org.apache.maven.settings.MavenSettingsBuilder;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.RuntimeInfo;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.classworlds.ClassWorld;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
|
@ -231,15 +231,6 @@ public class MavenCli
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: this should be in default maven, and should accommodate default goals
|
||||
if ( request.getGoals().isEmpty() )
|
||||
{
|
||||
System.err.println( "You must specify at least one goal. Try 'install'" );
|
||||
|
||||
cliManager.displayHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
MavenExecutionResponse response;
|
||||
try
|
||||
{
|
||||
|
@ -285,8 +276,8 @@ public class MavenCli
|
|||
}
|
||||
else
|
||||
{
|
||||
System.out.println( "WARNING: Alternate user settings file: " + userSettingsPath +
|
||||
" is invalid. Using default path." );
|
||||
System.out.println(
|
||||
"WARNING: Alternate user settings file: " + userSettingsPath + " is invalid. Using default path." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,10 +347,8 @@ public class MavenCli
|
|||
}
|
||||
}
|
||||
|
||||
private static MavenExecutionRequest createRequest( CommandLine commandLine,
|
||||
Settings settings,
|
||||
EventDispatcher eventDispatcher,
|
||||
LoggerManager loggerManager,
|
||||
private static MavenExecutionRequest createRequest( CommandLine commandLine, Settings settings,
|
||||
EventDispatcher eventDispatcher, LoggerManager loggerManager,
|
||||
ProfileManager profileManager )
|
||||
throws ComponentLookupException
|
||||
{
|
||||
|
|
|
@ -51,7 +51,8 @@ public class MavenSession
|
|||
private boolean usingPOMsFromFilesystem;
|
||||
|
||||
public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository,
|
||||
EventDispatcher eventDispatcher, ReactorManager reactorManager, List goals, String executionRootDir )
|
||||
EventDispatcher eventDispatcher, ReactorManager reactorManager, List goals,
|
||||
String executionRootDir )
|
||||
{
|
||||
this.container = container;
|
||||
|
||||
|
@ -67,7 +68,7 @@ public class MavenSession
|
|||
|
||||
this.executionRootDir = executionRootDir;
|
||||
}
|
||||
|
||||
|
||||
public Map getPluginContext( PluginDescriptor pluginDescriptor, MavenProject project )
|
||||
{
|
||||
return reactorManager.getPluginContext( pluginDescriptor, project );
|
||||
|
@ -140,7 +141,7 @@ public class MavenSession
|
|||
{
|
||||
this.usingPOMsFromFilesystem = usingPOMsFromFilesystem;
|
||||
}
|
||||
|
||||
|
||||
public boolean isUsingPOMsFromFilesystem()
|
||||
{
|
||||
return usingPOMsFromFilesystem;
|
||||
|
|
|
@ -110,7 +110,16 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
MavenProject rootProject = rm.getTopLevelProject();
|
||||
|
||||
List taskSegments = segmentTaskListByAggregationNeeds( session.getGoals(), session, rootProject );
|
||||
List goals = session.getGoals();
|
||||
|
||||
if ( goals.isEmpty() && rootProject != null )
|
||||
{
|
||||
String goal = rootProject.getDefaultGoal();
|
||||
if ( goal != null )
|
||||
{
|
||||
goals = Collections.singletonList( goal );
|
||||
}
|
||||
}
|
||||
|
||||
MavenExecutionResponse response = new MavenExecutionResponse();
|
||||
|
||||
|
@ -118,6 +127,13 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
try
|
||||
{
|
||||
if ( goals.isEmpty() )
|
||||
{
|
||||
throw new NoGoalsSpecifiedException( "You must specify at least one goal. Try 'install'" );
|
||||
}
|
||||
|
||||
List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
|
||||
|
||||
// TODO: probably don't want to do all this up front
|
||||
for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -164,6 +180,10 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
throw new LifecycleExecutionException( "Unable to initialise extensions", e );
|
||||
}
|
||||
catch ( NoGoalsSpecifiedException e )
|
||||
{
|
||||
response.setException( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
response.setFinish( new Date() );
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package org.apache.maven.lifecycle;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception indicating there were no goals given.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class NoGoalsSpecifiedException
|
||||
extends Exception
|
||||
{
|
||||
public NoGoalsSpecifiedException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
}
|
|
@ -1463,4 +1463,9 @@ public class MavenProject
|
|||
{
|
||||
this.executionRoot = executionRoot;
|
||||
}
|
||||
|
||||
public String getDefaultGoal()
|
||||
{
|
||||
return getBuild() != null ? getBuild().getDefaultGoal() : null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue