diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 35214bd296..12bb16b28f 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -102,7 +102,7 @@ public class DefaultMaven
// ----------------------------------------------------------------------
public MavenExecutionResponse execute( MavenExecutionRequest request )
- throws ReactorException
+ throws ReactorException, SettingsConfigurationException
{
if ( request.getSettings().isOffline() )
{
@@ -515,7 +515,7 @@ public class DefaultMaven
* the wagons, shouldn't we?
*/
private void resolveParameters( Settings settings )
- throws ComponentLookupException, ComponentLifecycleException
+ throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
{
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
@@ -525,6 +525,11 @@ public class DefaultMaven
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(),
proxy.getPassword(), proxy.getNonProxyHosts() );
}
diff --git a/maven-core/src/main/java/org/apache/maven/Maven.java b/maven-core/src/main/java/org/apache/maven/Maven.java
index 6099020edb..f35126841d 100644
--- a/maven-core/src/main/java/org/apache/maven/Maven.java
+++ b/maven-core/src/main/java/org/apache/maven/Maven.java
@@ -29,9 +29,9 @@ public interface Maven
static String ROLE = Maven.class.getName();
String POMv4 = "pom.xml";
-
+
String RELEASE_POMv4 = "release-pom.xml";
MavenExecutionResponse execute( MavenExecutionRequest request )
- throws ReactorException;
+ throws ReactorException, SettingsConfigurationException;
}
\ No newline at end of file
diff --git a/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java b/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java
new file mode 100644
index 0000000000..d0c67ae0d1
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java
@@ -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 Brett Porter
+ * @version $Id$
+ */
+public class SettingsConfigurationException
+ extends Exception
+{
+ public SettingsConfigurationException( String message )
+ {
+ super( message );
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
index f4a6bd5753..4ac3c07884 100644
--- a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -24,6 +24,7 @@ import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.maven.Maven;
+import org.apache.maven.SettingsConfigurationException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
@@ -152,7 +153,7 @@ public class MavenCli
Properties executionProperties = getExecutionProperties( commandLine );
- Settings settings = null;
+ Settings settings;
try
{
@@ -209,11 +210,7 @@ public class MavenCli
}
}
- request = createRequest( commandLine,
- settings,
- eventDispatcher,
- loggerManager,
- profileManager,
+ request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager,
executionProperties );
setProjectFileOptions( commandLine, request );
@@ -251,6 +248,11 @@ public class MavenCli
showFatalError( "Error executing Maven for a project", e, showErrors );
return 1;
}
+ catch ( SettingsConfigurationException e )
+ {
+ showError( e.getMessage(), e, showErrors );
+ return 1;
+ }
if ( response != null && response.isExecutionFailure() )
{
@@ -357,12 +359,20 @@ public class MavenCli
}
}
- private static MavenExecutionRequest createRequest( CommandLine commandLine,
- Settings settings,
- EventDispatcher eventDispatcher,
- LoggerManager loggerManager,
- ProfileManager profileManager,
- Properties executionProperties )
+ private static void showError( String message, Exception e, boolean show )
+ {
+ System.err.println( message );
+ if ( show )
+ {
+ 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
{
MavenExecutionRequest request;
@@ -371,12 +381,8 @@ public class MavenCli
File userDir = new File( System.getProperty( "user.dir" ) );
- request = new DefaultMavenExecutionRequest( localRepository,
- settings,
- eventDispatcher,
- commandLine.getArgList(),
- userDir.getPath(),
- profileManager,
+ request = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher,
+ commandLine.getArgList(), userDir.getPath(), profileManager,
executionProperties );
// TODO [BP]: do we set one per mojo? where to do it?
diff --git a/maven-settings/settings.mdo b/maven-settings/settings.mdo
index 1b9c0b5aa1..af5a3bc70d 100644
--- a/maven-settings/settings.mdo
+++ b/maven-settings/settings.mdo
@@ -402,12 +402,14 @@
1.0.0
int
+ 8080
host
1.0.0
String
+ true
nonProxyHosts