Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9000: Maven does not honor PROXY settings #1044

Conversation

armeniaca
Copy link
Contributor

Generate Maven's proxy setting from template according to PROXY
environment variable being set

@@ -19,6 +19,17 @@
MAVEN_RELEASE = 3.0.4
WGET := $(if $(PROXY), http_proxy=$(PROXY) ftp_proxy=$(PROXY)) /usr/bin/wget -q

MAVEN_PROXY := $(if $(PROXY), $(shell echo "$(PROXY)" | perl -ne ' \
if (m|(https?)://(?:([^:@]+)(?::([^@]+))?\@)?([^:/]+)(?::([0-9]+))?|) { \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'(?:' means do not remember this field, so the $x variables where x>=2 will be empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the $x variable you meant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean $1 $2 $3 $4 $5 below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$1 and $2 are true - inside a (?:, but they are not (?: themselves, so they are actually undefined.
so I have basically a match set of <$1:proto>://<$2:user>:<$3:pass>@<$4:host>:<$5:port>, from which $2/$3/$5 might be missing, and therefore undefined.
You can try this by this short test script:

#!/bin/bash
for PROXY in \
        'http://localhost' \
        'http://localhost:1234' \
        'https://user@localhost' \
        'https://user@sub.proxy.fqdn:12345' \
        'https://user:pass@proxy.fqdn' \
        'https://user:pass@proxy.fqdn:port'; do
 echo "====> $PROXY"
 echo "$PROXY" |  perl -ne '
     chomp;
     if (m|(https?)://(?:([^:@]+)(?::([^@]+))?\@)?([^:/]+)(?::([0-9]+))?|) {
         my $proto = "<protocol>$1</protocol>";
         my $user = defined($2) ? "<username>$2</username>" : "";
         my $pass = defined($3) ? "<password><![CDATA[$3]]></password>" : "";
         my $host = "<host>$4</host>";
         my $id   = "<id>$4</id>";
         my $port = defined($5) ? "<port>$5</port>" : "";
         print "<proxies> <proxy> <active>true</active> $id $proto $user $pass $host $port </proxy> </proxies>\n";
     }';
 echo "";
done

PS: This already includes the suggested fixes and a chomp.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I hadn't seen that you put regular parens inside (?: )

Generate Maven's proxy setting from template according to PROXY
environment variable being set
@peckpeck
Copy link
Member

Thanks

1 similar comment
@peckpeck
Copy link
Member

Thanks

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 49adf76 into Normation:master Sep 12, 2016
@armeniaca armeniaca deleted the bmw/upstream_issues/9000 branch September 12, 2016 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants