proxy without authentication in settings.xml - maven

I am looking for a way to set system proxy settings in settings.xml. If the proxy server does not need authentication, can I leave the username and password tag blank ? How can I achieve this ?
I can not find any documents from maven on this : http://maven.apache.org/guides/mini/guide-proxies.html

There is a same scenario in my team. Following are our settings. Just don't include those tag in your settings.xml
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<port><port-number></port>
<host><your-prox-server></host>
</proxy>
</proxies>

Related

maven versions plugin does not respect proxy settings

I am attempting to update my dependencies via the maven versions plugin and am unable to do so since it is not going through my proxy.
mvn versions:update-properties
My firewall log shows it is dropping connections on port 443 as it is attempting to go directly to the Internet; however, I have a proxy specified in my ~/.m2/settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<host>${HOSTNAME_GOES_HERE}</host>
<port>${PORT_GOES_HERE}</port>
<active>true</active>
</proxy>
</proxies>
Is there a way to make it work without changing my firewall rules?
Thanks,
Walter
It seems that the versions-maven-plugin uses the protocol tag in the proxy settings wrong. After I changed the protocol tag to https, the versions-maven-plugin used my proxy server as intended:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<host>${HOSTNAME_GOES_HERE}</host>
<port>${PORT_GOES_HERE}</port>
<protocol>https</protocol>
<active>true</active>
</proxy>
</proxies>
</settings>
This does go in line with the following Github Issue: https://github.com/mojohaus/versions-maven-plugin/issues/421
However, this does not reflect the usage as intended by Maven. This answer shows that the protocol tag is intended for the protocol of the proxy-server and not the target-url: https://stackoverflow.com/a/52508940/5945416
Maven worked perfectly fine for me with the protocol tag set to https instead of http and the versions plugin had problems as soon as I switched back to http, therefore I will leave it at that.
Tested on:
Maven: 3.8.1
versions-maven-plugin: 2.8.1

How to make maven search for artifacts in local repository

I have a project that worked fine on another pc. And now i'm trying to run it on another pc. There is no acces to proxy. And after any action it says that
couldn't transfer artifact. no route to host
But i have all depandencies in local repository, maven just doesn't want to take it from there. Is there a way to make him take all artifacts from local repo first?
There must be a version difference in the artifacts you have in your local repository and the ones mentioned in pom.xml
Your error : couldn't transfer artifact. no route to host
is because you have'nt added proxy to your pom. eg :
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
-->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>yourpassword</password>
<host>yourhost#host.com</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
Add it to the settings.xml file in conf folder of maven and try again

Not able to create maven project under eclipse mars even after setting the proxy

Hi Everyone ,
I am new to Maven environment . Tried all possibilities of enabling the proxy under settings.xml .But no use. Since the maven is integrated in mars I couldn't find the settings.xml and created my own under .m2 . And also tried with the external maven also .But no results .
Below is my settings.xml .
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hostname</host>
<port>port</port>
<username></username>
<password></password>
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
</settings>
The failed request from before has been cached by Maven. You need to run the command with the -U flag to retry. (Or wait until the caching has expired...)

Unable to get external maven dependencies for Junit and Selenium in IntelliJ

I'm not sure if the issue of not being able to sync the dependencies is to do with proxy or firewall.
I have been trying to make it work but no joy.
Is there any solution for someone in my situation?
I have, reinstall, imported project, run maven clean and install in cmd but still no dependency has been imported.
Message displays 'Dependency "org.seleniumhq.selenium-java:2.53.0" not found'
I believe I found the answer. The issue is indeed proxy and by adding those lines in the settings.xml between with your/company proxy details it should work.
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>xx.xx.x.xxx</host>
<port>1234</port>
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
In some instances you may need to add the username and password to make it work.
<username></username>
<password></password>

Specifying proxy for cxf-codegen-plugin

How do you specify a proxy that needs to be used by cxf-codegen-plugin. I tried specifying proxy in the maven settings.xml, but that was not picked up.
maven settings.xml in ~/.m2 folder works just fine for me for cxf-codegen-plugin. Example:
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username><!-- username --></username>
<password><!-- pass --></password>
<nonProxyHosts>*.local|*.example.com</nonProxyHosts>
</proxy>
</proxies>
I've tried:
mvn -Dhttp.proxyHost=[_] -Dhttp.proxyPort=[_] clean package
([_] -> Your proxy data)
On console and worked.

Resources