When I'm trying to use Robolectric I got following errors (I can't paste more, because I'm new here). How can I solve it?
Downloading: org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.pom from repository central at
http://repo1.maven.org/maven2
[WARNING] Unable to get resource 'org.robolectric:android-all:pom:4.3_r2-robolectric-0' from repository sonatype
https://oss.sonatype.org/content/groups/public/
Error transferring file: Connection refused: connect
UPDATE:
I solved my problem. Using proxy caused that.
You should write correct proxy settings for maven.
Create settings.xml file in your ~/.m2 directory
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host></host>
<port></port>
<username></username>
<password></password>
</proxy>
</proxies>
</settings>
You can read additional info here https://maven.apache.org/guides/mini/guide-proxies.html
Related
I am trying to publish third-party private package directly to my Azure Artifacts feed with mvn deploy:deploy-file command like this:
mvn deploy:deploy-file -Dpackaging="jar" -DrepositoryId="PXXXXX-inccoming" -Durl="https://pkgs.dev.azure.com/XxxXxxxXxxx/XxxXxx/_packaging/PXXXXX-incoming/maven/v1" -DgroupId="pl.group.id" -DartifactId="artifact" -Dversion="0.0.2" -Dfile="C:\path\pl\group\id\0.0.2\artifact-0.0.2.jar"
But I am getting strange error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project CAST_2015: Failed to deploy artifacts: Could not transfer artifact pl.group.id:artifact:jar:0.0.2 from/to PXXXXX-inccoming (https://pkgs.dev.azure.com/XxxXxxxXxxx/XxxXxx/_packaging/PXXXXX-incoming/maven/v1): Transfer failed for https://pkgs.dev.azure.com/XxxXxxxXxxx/XxxXxx/_packaging/PXXXXX-incoming/maven/v1/pl/group/id/artifact/0.0.2/artifact-0.0.2.jar 401 Unauthorized ProxyInfo{host='proxy-host', userName='null', port=8080, type='http', nonProxyHosts='null'}
The provided user has full access for packaging in Azure.
Both proxy and server settings are actually in my setting.xml file.
What am I doing wrong?
Azure Artifacts deploy packages
When we receiving a 401 it is because maven is sending the wrong login credentials, or no credentials at all.
To resolve this issue, please add the following configuration to the <servers>...</servers> configuration node in the maven setting configuration file:
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
Note:
The id configured in setting.xml must be the same as the id
configured in pom.xml.
If you try to publish something to a releases repository and that
version already exists in the repository
If it not work for you, please check below thread for some more details:
Why am I getting a "401 Unauthorized" error in Maven?
I have a Maven project and want to build it using mvn clean deploy so that the built artifact is deployed into a Nexus repository.
The access data (username and password) for that repository are stored in Jenkins credentials.
I want to call mvn deploy in Jenkins so that the credentials for that Nexus repository are read from Jenkins (not hardcoded in settings.xml).
How can I do it, if I cannot access settings.xml on the Jenkins server?
Update 1:
I created an entry in "Config File Management" (JENKINS_URL/configfiles/index) with following data:
Type: Maven settings.xml
Replace All: Yes
Server ID: myServer
Credentials: Credentials for the Nexus repository
Content:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<servers>
<server>
<id>myServer</id>
<username>foo</username>
<password>bar</password>
</server>
</servers>
</settings>
myServer is also used in the pom.xml of the artifact I want to build:
<distributionManagement>
<repository>
<id>myServer</id>
<url>http://nexus.mycompany.com</url>
</repository>
</distributionManagement>
In the configuration of the job, I include those settings as shown below. Nexus settings.xml is the configuration from "Config File Management".
But it does not work -- I get "Forbidden" error when the build attempts to deploy artifacts to Nexus.
Update 2: When I run mvn -X deploy locally with the same credentials as in Jenkins (stored in my local settings.xml), I see following output:
[DEBUG] Failed to decrypt password for server XXX release repository: org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: java.io.FileNotFoundException: /XXXXXXXXXXXXXXX/.m2/settings-security.xml (No such file or directory)
org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: java.io.FileNotFoundException: /XXXXXXXXXXXXXXX/.m2/settings-security.xml (No such file or directory)
at org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher.decrypt(DefaultSecDispatcher.java:121)
at org.apache.maven.settings.crypto.DefaultSettingsDecrypter.decrypt(DefaultSettingsDecrypter.java:107)
at org.apache.maven.settings.crypto.DefaultSettingsDecrypter.decrypt(DefaultSettingsDecrypter.java:63)
at org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory.newRepositorySession(DefaultRepositorySystemSessionFactory.java:165)
However, the password in settings.xml is not encrypted at all:
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>NEXUS_REPOSITORY_SNAPSHOTS</id>
<username>user</username>
<password>password</password>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
I found a report about similar error here.
You can use the Jenkins config-file-provider plugin ( link: https://plugins.jenkins.io/config-file-provider/ ) to create one or several Maven settings.xml files.
NOTE: Really this helps also if you need differents settings.xml for
different projects.
Then on the maven deploy step of your Jenkins project you can select to point to one of the settings.xml files defined ( instead of pointing to the general Jenkins server /.m2/settings.xml )
I need to develop applications here at the company. And inside the company's network there is a *.pac file that determine the destination according to the request.
I'm using git as the version control and maven as the dependency manager, after searching on the internet I've found the following link which helped me configure git to work properly:
Getting git to work with a proxy server
Unfortunately, for Maven I couldn't find a way to make it work.
I've checked the following links but none seemed to work either:
https://www.mkyong.com/maven/how-to-enable-proxy-setting-in-maven/
https://maven.apache.org/guides/mini/guide-proxies.html
Some comments were telling to configure the settings.xml file in the .m2 folder, I configured it like that:
<proxies>
<proxy>
<id>p1</id>
<active>true</active>
<protocol>http</protocol>
<host>hostname</host>
<port>3129</port>
<username>user</username>
<password>password</password>
</proxy>
<proxy>
<id>p2</id>
<active>true</active>
<protocol>https</protocol>
<host>hostname</host>
<port>3443</port>
<username>user</username>
<password>password</password>
</proxy>
</proxies>
Even so it doesn't work.
Has anyone went through this problem, does anyone know how to solve it?
Man, cut this id off and use only http, something like:
<proxy>
<!--<id>optional</id> -->
<active>true</active>
<protocol>http</protocol>
<username>user</username>
<password>passwrod</password>
<host>proxy address without "http://" </host>
<port>proxyport</port>
<nonProxyHosts>*.yourdomain.com</nonProxyHosts>
</proxy>
I put the file setting.xml with this configuration only in my .m2 folder and works like a charm to me.
I am working on a java maven project in eclipse using the m2e plugin. I configured maven plugin with eclipse but some problems occurred.
1.
Alfesco maven sdk link is not working in eclipse its not downloading the required Archetype which is alfresco- amp archtype.
I searched them alot bu I am new to maven and eclipse and, after a day of googling, I still haven't managed to find a solution for this.
Update
Maven Settings are given as follows is there any problem in maven settings. Is there any problem with local repository/catalog then how to change it?
Setttings.xml:
http://maven.apache.org/xsd/settings-1.1.0.xsd">
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>172.16.0.9</host>
<port>8080</port>
</proxy>
</proxies>
</settings>
I Created a Maven project following this tutorial, and it worked properly. Now when I create a Maven project again, it gives the following error.
Could anyone help me to solve this issue?
I found same error and resolved using this question of StackOverflow
solution-1 (please follow this link for further assistance)
By following below steps
Open Window > Preferences
Open Maven > Archetypes
Click 'Add Remote Catalog' and add the
following:
Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
Description: maven catalog
Maven > User Setting > c:\Users\xxxxxxxx.m2\settings.xml
If you are a proxy, you need this configuration:
<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>
<password>*******</password>
<host>*****proxy_host*****</host>
<port>8080</port>
</proxy>
</proxies>