diff --git a/api/maven-api-settings/src/main/mdo/settings.mdo b/api/maven-api-settings/src/main/mdo/settings.mdo
index 4c5a575990..d3ad60eba2 100644
--- a/api/maven-api-settings/src/main/mdo/settings.mdo
+++ b/api/maven-api-settings/src/main/mdo/settings.mdo
@@ -459,17 +459,17 @@
The <proxy>
element contains informations required to a proxy settings.
]]>
-
- active
+
+ activeString
1.0.0+
false
true
-
+ Whether this proxy configuration is the active one. Note: While the type of this field
+ is {@code String} for technical reasons, the semantic type is actually {@code boolean}.
+ @see #isActive()
- boolean
+ String
protocol
@@ -502,15 +502,15 @@
String
-
- port
+
+ portString
1.0.0+
-
+ The proxy port. Note: While the type of this field is {@code String} for technical
+ reasons, the semantic type is actually {@code int}.
+ @see #getPort()
- int
+ String
8080
@@ -535,6 +535,57 @@
String
+
+
+ 1.0.0/1.3.0
+
+ public boolean isActive() {
+ return (getActiveString() != null) ? Boolean.parseBoolean(getActiveString()) : true;
+ }
+
+ public void setActive(boolean active) {
+ setActiveString(String.valueOf(active));
+ }
+
+ public int getPort() {
+ return (getPortString() != null) ? Integer.parseInt(getPortString()) : 8080;
+ }
+
+ public void setPort(int port) {
+ setPortString(String.valueOf(port));
+ }
+
+
+
+ 2.0.0+
+
+ /**
+ * Indicates if this proxy is active.
+ * To allow interpolation of this field, this method lazily parses
+ * the {@link #getActiveString()} value as a boolean and defaults to {@code true}
+ * if not set.
+ *
+ * @return a boolean indicating if this proxy is active
+ */
+ public boolean isActive() {
+ return (getActiveString() != null) ? Boolean.parseBoolean(getActiveString()) : true;
+ }
+
+ /**
+ * Returns the port to use for this proxy.
+ * To allow interpolation of this field, this method lazily parses
+ * the {@link #getPortString()} value as an integer and defaults to {@code 8080}
+ * if not set.
+ *
+ * @return an integer indicating the port to use for this proxy
+ */
+ public int getPort() {
+ return (getPortString() != null) ? Integer.parseInt(getPortString()) : 8080;
+ }
+
+
+
+
Server
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java
index d229062dca..2e8c053068 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java
+++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java
@@ -128,8 +128,6 @@ public class DefaultSettingsBuilder implements SettingsBuilder {
problems.setSource("");
- userSettings = interpolate(userSettings, request, problems);
-
// for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
String localRepository = userSettings.getLocalRepository();
if (localRepository != null && localRepository.length() > 0) {
@@ -212,6 +210,8 @@ public class DefaultSettingsBuilder implements SettingsBuilder {
return new Settings();
}
+ settings = interpolate(settings, request, problems);
+
settingsValidator.validate(settings, isProjectSettings, problems);
if (isProjectSettings) {
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java
index f3a5cce480..017e696704 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java
+++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/DefaultSettingsValidator.java
@@ -195,6 +195,17 @@ public class DefaultSettingsValidator implements SettingsValidator {
"must be unique but found duplicate proxy with id " + proxy.getId());
}
validateStringNotEmpty(problems, "proxies.proxy.host", proxy.getHost(), proxy.getId());
+
+ try {
+ Integer.parseInt(proxy.getPortString());
+ } catch (NumberFormatException e) {
+ addViolation(
+ problems,
+ Severity.ERROR,
+ "proxies.proxy[" + proxy.getId() + "].port",
+ null,
+ "must be a valid integer but found '" + proxy.getPortString() + "'");
+ }
}
}
}