maven versions plugin does not respect proxy settings - maven

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

Related

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>

Unable to create spring-mvc project in STS

I am trying to create a spring mvc project. I am creating a Maven project and then selecting the archetypes as
GroupId : co.ntier
ArtifactId : spring-mvc-archetype
Version: 1.0.2
I am getting this error:
Unable to create project from archetype [co.ntier:spring-mvc-archetype:1.0.2 -> http://maven-repository.com/artifact/co.ntier/spring-mvc-archetype/1.0.2]
The defined artifact is not an archetype
Try cleaning up your .m2\repository\ folder. Don't forget to set your proxy in settings.xml. settings.xml is manually created therefore you need to make your own and set the proxy. Here's a sample template for setting up your proxy inside 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>
<active>true</active>
<protocol>http</protocol>
<host> --your proxy here-- </host>
<port> --your port no here-- </port>
</proxy>
</proxies>
</settings>
When you make a new Maven Project and add a new archetype, use this Repository URL instead: http://repo1.maven.org/maven2/
By the way I'm using Eclipse Luna and it works on my end.
In my case i have only change repository URL. try with this url:http://repo.maven.apache.org/maven2/
Try by deleting /co folder inside m2/repository and then add a new archytype while creating Eclipse project. . use this for Repository URL :http://repo.maven.apache.org/maven2/

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