mirror of https://github.com/apache/maven.git
PR: MNG-838
improve error reporting for bad settings git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307261 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb259a7689
commit
24ebd82f31
|
@ -102,7 +102,7 @@ public class DefaultMaven
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public MavenExecutionResponse execute( MavenExecutionRequest request )
|
public MavenExecutionResponse execute( MavenExecutionRequest request )
|
||||||
throws ReactorException
|
throws ReactorException, SettingsConfigurationException
|
||||||
{
|
{
|
||||||
if ( request.getSettings().isOffline() )
|
if ( request.getSettings().isOffline() )
|
||||||
{
|
{
|
||||||
|
@ -515,7 +515,7 @@ public class DefaultMaven
|
||||||
* the wagons, shouldn't we?
|
* the wagons, shouldn't we?
|
||||||
*/
|
*/
|
||||||
private void resolveParameters( Settings settings )
|
private void resolveParameters( Settings settings )
|
||||||
throws ComponentLookupException, ComponentLifecycleException
|
throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
|
||||||
{
|
{
|
||||||
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
|
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
|
||||||
|
|
||||||
|
@ -525,6 +525,11 @@ public class DefaultMaven
|
||||||
|
|
||||||
if ( proxy != null )
|
if ( proxy != null )
|
||||||
{
|
{
|
||||||
|
if ( proxy.getHost() == null )
|
||||||
|
{
|
||||||
|
throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
|
||||||
|
}
|
||||||
|
|
||||||
wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
|
wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
|
||||||
proxy.getPassword(), proxy.getNonProxyHosts() );
|
proxy.getPassword(), proxy.getNonProxyHosts() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ public interface Maven
|
||||||
static String ROLE = Maven.class.getName();
|
static String ROLE = Maven.class.getName();
|
||||||
|
|
||||||
String POMv4 = "pom.xml";
|
String POMv4 = "pom.xml";
|
||||||
|
|
||||||
String RELEASE_POMv4 = "release-pom.xml";
|
String RELEASE_POMv4 = "release-pom.xml";
|
||||||
|
|
||||||
MavenExecutionResponse execute( MavenExecutionRequest request )
|
MavenExecutionResponse execute( MavenExecutionRequest request )
|
||||||
throws ReactorException;
|
throws ReactorException, SettingsConfigurationException;
|
||||||
}
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there was an error in the settings file.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SettingsConfigurationException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
public SettingsConfigurationException( String message )
|
||||||
|
{
|
||||||
|
super( message );
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.maven.Maven;
|
import org.apache.maven.Maven;
|
||||||
|
import org.apache.maven.SettingsConfigurationException;
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
|
@ -152,7 +153,7 @@ public class MavenCli
|
||||||
|
|
||||||
Properties executionProperties = getExecutionProperties( commandLine );
|
Properties executionProperties = getExecutionProperties( commandLine );
|
||||||
|
|
||||||
Settings settings = null;
|
Settings settings;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -209,11 +210,7 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request = createRequest( commandLine,
|
request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager,
|
||||||
settings,
|
|
||||||
eventDispatcher,
|
|
||||||
loggerManager,
|
|
||||||
profileManager,
|
|
||||||
executionProperties );
|
executionProperties );
|
||||||
|
|
||||||
setProjectFileOptions( commandLine, request );
|
setProjectFileOptions( commandLine, request );
|
||||||
|
@ -251,6 +248,11 @@ public class MavenCli
|
||||||
showFatalError( "Error executing Maven for a project", e, showErrors );
|
showFatalError( "Error executing Maven for a project", e, showErrors );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
catch ( SettingsConfigurationException e )
|
||||||
|
{
|
||||||
|
showError( e.getMessage(), e, showErrors );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( response != null && response.isExecutionFailure() )
|
if ( response != null && response.isExecutionFailure() )
|
||||||
{
|
{
|
||||||
|
@ -357,12 +359,20 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MavenExecutionRequest createRequest( CommandLine commandLine,
|
private static void showError( String message, Exception e, boolean show )
|
||||||
Settings settings,
|
{
|
||||||
EventDispatcher eventDispatcher,
|
System.err.println( message );
|
||||||
LoggerManager loggerManager,
|
if ( show )
|
||||||
ProfileManager profileManager,
|
{
|
||||||
Properties executionProperties )
|
System.err.println( "Error stacktrace:" );
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MavenExecutionRequest createRequest( CommandLine commandLine, Settings settings,
|
||||||
|
EventDispatcher eventDispatcher, LoggerManager loggerManager,
|
||||||
|
ProfileManager profileManager, Properties executionProperties )
|
||||||
throws ComponentLookupException
|
throws ComponentLookupException
|
||||||
{
|
{
|
||||||
MavenExecutionRequest request;
|
MavenExecutionRequest request;
|
||||||
|
@ -371,12 +381,8 @@ public class MavenCli
|
||||||
|
|
||||||
File userDir = new File( System.getProperty( "user.dir" ) );
|
File userDir = new File( System.getProperty( "user.dir" ) );
|
||||||
|
|
||||||
request = new DefaultMavenExecutionRequest( localRepository,
|
request = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher,
|
||||||
settings,
|
commandLine.getArgList(), userDir.getPath(), profileManager,
|
||||||
eventDispatcher,
|
|
||||||
commandLine.getArgList(),
|
|
||||||
userDir.getPath(),
|
|
||||||
profileManager,
|
|
||||||
executionProperties );
|
executionProperties );
|
||||||
|
|
||||||
// TODO [BP]: do we set one per mojo? where to do it?
|
// TODO [BP]: do we set one per mojo? where to do it?
|
||||||
|
|
|
@ -402,12 +402,14 @@
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<description><![CDATA[The proxy port.]]></description>
|
<description><![CDATA[The proxy port.]]></description>
|
||||||
<type>int</type>
|
<type>int</type>
|
||||||
|
<defaultValue>8080</defaultValue>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>host</name>
|
<name>host</name>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<description><![CDATA[The proxy host.]]></description>
|
<description><![CDATA[The proxy host.]]></description>
|
||||||
<type>String</type>
|
<type>String</type>
|
||||||
|
<required>true</required>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>nonProxyHosts</name>
|
<name>nonProxyHosts</name>
|
||||||
|
|
Loading…
Reference in New Issue