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
Fixes #9000: Maven does not honor PROXY settings #1044
Conversation
@@ -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]+))?|) { \ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
4e7dce0
to
49adf76
Compare
Thanks |
1 similar comment
Thanks |
OK, merging this PR |
Generate Maven's proxy setting from template according to PROXY
environment variable being set