You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Thomas Meyer <th...@m3y3r.de> on 2015/03/28 09:51:33 UTC

Warn about Proxies with duplicate id, but different protocols

Hi,

would you please add a patch like this?

I did copy the HTTPS proxy entry and modified it into a HTTP entry in
the settings.xml.
But I forgot to change the id of the second proxy entry.
It took me a while to figure out why it isn't working...

Untested patch, but I hope you get the idea!

with kind regards
thomas

diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
@@ -162,7 +162,10 @@
     private boolean useLegacyLocalRepositoryManager = false;
 
     private Map<String, Object> data;
-    
+
+    @Inject
+    private Logger logger;
+
     public DefaultMavenExecutionRequest()
     {
     }
@@ -788,7 +791,14 @@ public MavenExecutionRequest addProxy( Proxy proxy )
         {
             if ( p.getId() != null && p.getId().equals( proxy.getId() ) )
             {
-                return this;
+                if( !( p.getProtocol().equals( proxy.getProtocol() ) ) )
+                {
+                    logger.warn( "Duplicate proxy id found! But protocol differs!\n" +
+                                 "Please check your settings.xml file!" );
+                } else
+                {
+                    return this;
+                }
             }
         }




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Warn about Proxies with duplicate id, but different protocols

Posted by Robert Scholte <rf...@apache.org>.
Hi Thomas,

this should bee done by the  
org.apache.maven.settings.validation.DefaultSettingsValidator[1]
And it seems like most id-aware elements are checked, except the proxy.
Please create a Jira issue[2] along with your patch and a unittest if  
possible.

thanks,
Robert

[1]  
http://maven.apache.org/ref/3.3.1/maven-settings-builder/xref/org/apache/maven/settings/validation/DefaultSettingsValidator.html
[2] http://jira.codehaus.org/browse/MNG


Op Sat, 28 Mar 2015 09:51:33 +0100 schreef Thomas Meyer <th...@m3y3r.de>:

> Hi,
>
> would you please add a patch like this?
>
> I did copy the HTTPS proxy entry and modified it into a HTTP entry in
> the settings.xml.
> But I forgot to change the id of the second proxy entry.
> It took me a while to figure out why it isn't working...
>
> Untested patch, but I hope you get the idea!
>
> with kind regards
> thomas
>
> diff --git  
> a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java  
> b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
> ---  
> a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
> +++  
> b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
> @@ -162,7 +162,10 @@
>      private boolean useLegacyLocalRepositoryManager = false;
>     private Map<String, Object> data;
> -
> +
> +    @Inject
> +    private Logger logger;
> +
>      public DefaultMavenExecutionRequest()
>      {
>      }
> @@ -788,7 +791,14 @@ public MavenExecutionRequest addProxy( Proxy proxy )
>          {
>              if ( p.getId() != null && p.getId().equals( proxy.getId() )  
> )
>              {
> -                return this;
> +                if( !( p.getProtocol().equals( proxy.getProtocol() ) ) )
> +                {
> +                    logger.warn( "Duplicate proxy id found! But  
> protocol differs!\n" +
> +                                 "Please check your settings.xml file!"  
> );
> +                } else
> +                {
> +                    return this;
> +                }
>              }
>          }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org