I am using Maven for my project everything work fine but now i need some third party jar which are not available on Maven Central repository.
So i installed Archiva in my server and added Archiva repository entry in pom.xml file
<repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
<url>http://ipaddress:8888/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
But when i am running mvn command i am getting
> Could not transfer artifact
> org.jbosscaches:jboss-common-core:pom:2.2.19.GA from/to internal
> (http://ipaddress:8999/repository/internal/): Not authorized ,
> ReasonPhrase:Unauthorized. -> [Help 1
What changes i have to do maven settings.xml file
Have a look at this http://archiva.apache.org/docs/2.1.0/userguide/deploy.html.
I'm pretty sure this will help you :-)
Olivier
Related
In BitBucket Pipeline, I am using mvn clean compile command to build the project.
The project has pom.xml where it used some private bitbucket maven repository.
<repositories>
<repository>
<id>private-maven-repository</id>
<name>Private Maven Repository</name>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://api.bitbucket.org/2.0/repositories/sdas/maven_repository/src/releases</url>
</repository>
</repositories>
In pipeline, the most of the Central artifacts are getting downloaded and also able to connect the private maven repository, but still it stuck after some time to download some artifacts from private maven repository.
It is not about a specific artifact of private maven repository. Can someone help me to identify the problem or how to debug this issue in BitBukcket pipeline.
Note: When I run mvn clean compile in my local git bash, build was successful.
I managed to fix this problem after overriding the repository with central maven repository. By means, forcing to download the artifacts first from maven central repository and then from private maven repository.
<repository>
<id>central</id>
<name>Default Repository</name>
<layout>default</layout>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
We are using TFS GIT and trying to build the project and getting below error (the same code works fine on my local when i do mvn clean install but fails in tfs server):
Unresolveable build extension: Plugin org.mule.tools.maven:mule-maven-plugin:3.3.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.mule.tools.maven:mule-maven-plugin:jar:3.3.5 -> org.mule.tools.maven:mule-packager:jar:3.3.5 -> org.mule.tools.maven:mule-classloader-model:jar:3.3.5 -> commons-io:commons-io:jar:2.6: Failed to read artifact descriptor for commons-io:commons-io:jar:2.6: Could not transfer artifact commons-io:commons-io:pom:2.6 from/to central (http://repo1.maven.org/maven2): Failed to transfer file http://repo1.maven.org/maven2/commons-io/commons-io/2.6/commons-io-2.6.pom with status code 501 -> [Help 2]
2020-07-01T16:27:19.7473940Z org.apache.maven.plugin.PluginManagerException: Plugin org.mule.tools.maven:mule-maven-plugin:3.3.5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.mule.tools.maven:mule-maven-plugin:jar:3.3.5 -> org.mule.tools.maven:mule-packager:jar:3.3.5 -> org.mule.tools.maven:mule-classloader-model:jar:3.3.5 -> commons-io:commons-io:jar:2.6
Agree with khmarbaise.
I encountered into the same problem when I used Central Repository with http communication.
To solve this issue, you need to change the reference of Central Repository in the Pom file to https communication.
For example:
<Project>
....
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
....
</project>
Then the Maven task could work as expected.
Hope this helps.
When trying to run a NetBeans project, I get the following error message:
Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.10:test
(default-test) on project MyNetBeansProject: Execution default-test of goal
org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed:
Plugin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of
its dependencies could not be resolved: Failed to collect dependencies
for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 (): Failed
to read artifact descriptor for
org.apache.maven.surefire:surefire-booter:jar:2.10: Could not transfer
artifact org.apache.maven.surefire:surefire-booter:pom:2.10 from/to
central (http://repo.maven.apache.org/maven2): Failed to transfer
file:
http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.10/surefire-booter-2.10.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]
The following part of the error message is the most important one:
Failed to transfer file:
http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.10/surefire-booter-2.10.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required.
Services -> Maven Repositories -> Central Repository -> right mouse click on "Central Repository" gives the following information:
As one can see, the Remote Repository URL is "http://repo.maven.apache.org/maven2/". I think it should instead be "https://repo.maven.apache.org/maven2/".
However, the problem is that I can't seem to change the Remote Repository URL.
Does anybody know how to change maven's Remote Repository URL in the NetBeans IDE?
UPDATE:
Under NetBeans -> Preferences one can see that the maven version used by my NetBeans IDE is Version 3.0.5:
Within the Netbeans installation, this worked for me:
Goto Netbeans installation folder > java > maven > conf, and here I updated the settings.xml file using administrative privilege.
as http repo link will not work now, just I created an mirror for central repo that is pre-built with IDE which cannot be changed.
Add this inside mirrors tag of settings.xml
<mirror>
<id>mirror1</id>
<mirrorOf>central</mirrorOf>
<name>mirror1</name>
<url>https://repo.maven.apache.org/maven2/</url>
</mirror>
after this restart netbeans IDE, and central repository will be overridden with the mirror we specify.
I think you have three options.
1. Migrate to 11.0
You can migrate to Netbeans 11.0 LTS (or 11.2), it uses a built-in Maven 3.3.9 version. It already uses https.
2. Install standalone Apache Maven
You can stay with Netbeans 8.2 but download standalone apache maven, install it to your system and set the path to the new maven home directory in Options -> Java -> Maven -> Maven Home.
You need just:
Download apache-maven-3.6.3-bin.zip (or apache-maven-3.6.3-bin.tar.gz) from Apache
Unzip it to any directory. It will be the Maven home.
Set the Maven home directory in NetBeans to the directory where you have extracted zip file.
Ensure than you have set JAVA_HOME in your environment variables
Instructions how to install standalone version here.
If you set the Maven Home in NetBeans correctly it will show you updated version:
3. Quick and not recommended
Just add repositories into your pom.xml with https (for example like that)
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
Maven Central Migrated to https
The problem comes from this:
As of January 15, 2020, The Central Repository no longer supports
insecure communication over HTTP and requires that all requests to the
repository are encrypted over HTTPS.
Here is the relevant improvement that was resolved and relevant changes.
Go maven>conf and update settings.xml
<profile>
<id>maven-https</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
I try to make my Project offline and build the project with an in-project-repo. So the ~/.m2/ directory is empty at the beginning. I added the following into my poms:
<repositories>
<repository>
<id>project</id>
<url>file://${basedir}/lib</url>
</repository>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>project</id>
<url>file://${basedir}/lib</url>
</pluginRepository>
</pluginRepositories>
Then I deleted everything in my .m2 folder and build my project with internet with the option
-dependency:go-offline
This works. Then I copy everything out of the .m2/repository directory into my lib directory in my project and delete the content in .m2/repository. Now I disconnect from the internet and try to build my project with the option -o. This dont work and I get the following error:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: The repository system is offline but the artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 is not available in the local repository. -> [Help 1]
In my lib folder(in-project-repo) exist this plugin and all the other plugins.
I have some sources who are not availbable in the internet. I copyed them to my lib folder(in-project-repo) and they get copyed into the local m2 repository when I build my project. So I guess my in-project-repo is working. I don't understand this.
If I let the content int the ~/.m2 folder I can build my project without internet.
I hope someone can help me!
Kindly Regards
EDIT: I made it work with the option:
-Dmaven.repo.local=/path/to/project/lib clean package -X -o
Is there a better way?
Is it possible to download dependencies in maven using multiple plugin-repos?
I have my settings.xml configured to get dependencies from a custom repo and because of this, i am unable to get dependencies from the main maven repo server.
Is this possible to setup more then one plugin Repo?
Here is what i have setup so far for my custom repo:
</profiles>
<profile>
<id>custom-config</id>
<repositories>
<repository>
<id>custom-snapshots</id>
<name>customSnapshots</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http:/custom/repo</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>custom-plugins</id>
<urlhttp:/custom/repo/public-snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
I have not included the dependencies here, but I am unable to pull and resolve some library dependencies.
The maven repo that I use is http://mvnrepository.com/ but I dont have details on the exact repo settings to use as the one I defined for a custom one.
The default maven repository is called "central". Its url is: http://repo1.maven.org/maven2/ or nowadays: http://repo.maven.apache.org/maven2/
But it is usually configured as mirrorOf. If you create a repository in your settings.xml and give it the id *central" it will replace it.
So I wonder why you can't resolve dependencies from there. Usually adding a repository in settings.xml does not turn of central.
could you execute mvn help:effective-settings and mvn help:effective-pom and have a loook at all repositories, profiles and mirrorOf elements in the xml? central should be there.
I would also recommend using a Maven proxy like Nexus or Artifactory. It simplifies a lot of things within a company.