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

Honor system proxy settings #510

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

drewhamilton
Copy link

@drewhamilton drewhamilton commented Jun 1, 2021

  • All tests passed. If this feature is not already covered by the tests, I added new tests.

This partially addresses #149. If no proxyHost is specified by the Gradle plugin consumer, the Gradle plugin tries using the JVM "http(s).proxyHost" property. Similarly, if no proxyPort is specified by the Gradle plugin consumer, it tries using the JVM "http(s).proxyPort" property.

Whether the "http" or "https" property is used depends on the contextUrl: "http" if the contextUrl starts with "http://", "https" otherwise.

This does not address the part of #149 that mentions non-proxy-hosts. This may be a blocker for this PR, since now this plugin could try using a proxy when contextUrl is actually part of non-proxy-hosts. Please let me know if you think non-proxy-hosts handling must be part of this PR.

I didn't write tests yet since I'd like confirmation about whether the above behavior choices are correct. Once these are confirmed I'm happy to add tests.

Drew Hamilton added 2 commits June 1, 2021 16:58
if plugin proxy properties are not set
@github-actions
Copy link

github-actions bot commented Jun 1, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@eyalbe4
Copy link
Contributor

eyalbe4 commented Jun 2, 2021

Thanks for this contribution @drewhamilton!
Looks good to me.
Let's just add a unit test for the configureProxy method.
Also, please go ahead and sign the CLA as requested in the above comment.

@drewhamilton
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@drewhamilton
Copy link
Author

@eyalbe4 Thanks for taking a look. After thinking about it more, I think this doesn't make sense without also handling the "http.nonProxyHosts" property, so I will add that handling as well. Then I'll add some tests.

@drewhamilton
Copy link
Author

I added handling for the "http.nonProxyHosts" property. It felt a bit silly to write so much string-parsing logic for the wildcard matching; let me know if you're aware of a better way.

The configureProxy method is private; do you want me to make it visible and unit-test it directly or did you mean something else?

@eyalbe4
Copy link
Contributor

eyalbe4 commented Jun 2, 2021

I'll have a look at the code soon @drewhamilton.
Yes - let's make the method public for the test.

@drewhamilton
Copy link
Author

Anything else I can do for this?

@eyalbe4
Copy link
Contributor

eyalbe4 commented Jan 31, 2022

@drewhamilton -
It looks like this PR was mistakenly skipped.
Please accept my apologies for this...
Would you like us to review the PR again? Are you still interested in promoting this functionality?

@drewhamilton
Copy link
Author

@eyalbe4 I don't personally need this anymore, though as far as I know it's still a valid approach.

@paristote Would this be helpful for your CI/Gradle setup?

@paristote
Copy link

Thanks for coming back to this PR, @eyalbe4 , @drewhamilton. Yes this is still useful for us, without it we need extra configuration to set the proxy settings for this particular plugin.

@eyalbe4 eyalbe4 self-requested a review May 12, 2022 11:28
System.setProperty(HTTPS_PROXY_HOST_SETTING, "https-proxy-host");
System.setProperty(HTTPS_PROXY_PORT_SETTING, String.valueOf(1111));
System.setProperty(HTTP_PROXY_HOST_SETTING, "http-proxy-host");
System.setProperty(HTTP_PROXY_PORT_SETTING, String.valueOf(2222));
Copy link
Contributor

Choose a reason for hiding this comment

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

The above line are duplicated many times in the code. I suggest we move them into a method and reuse it.

if (!pattern.startsWith("*") && !string.startsWith(patternParts[0])) {
// Shortcut loop if string doesn't start with an exact match:
return false;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

This "else" clause is redundant, because of the above "return".

@drewhamilton
Copy link
Author

I'm not using Artifactory anymore, but feel free to make whatever refactors you like, @eyalbe4 and @paristote 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants