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>
Related
Here is my situation:
I am able to run mvn install on my personal computer and the build successful.
But when I run the same at workstation, I get the following error. This is most likely because I have a settings.xml in ${user.home}/.m2/settings.xml which refers to my company's repo and DOES NOT allow to fetch from remote maven repo. How can I overcome this behavior?
Both my workstation and personal computer runs mac OS X.
Here is the settings.xml(I have replaced real names with dummy ones)
<profiles>
<profile>
<id>dummy</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<dummy-groupId>com.mycompany.mydummy</dummy-groupId>
<dummy-name>my-java-ee-app</dummy-name>
<dummy-Mode>FALSE</dummy-Mode>
</properties>
<repositories>
<repository>
<id>mycompany Release Repository</id>
<name>central maven release repository</name>
<url>
http://maven1.mycompany.com:8080/myartifactories/repo
</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mycompany Snapshot Repository</id>
<name>central maven snapshot repository</name>
<url>
http://maven1.mycompany.com:8080/myartifactories/repo
</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mycompany Release Plugin Repository</id>
<name>central maven release repository</name>
<url>
http://maven1.mycompany.com:8080/myartifactories/repo
</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>mycompany Snapshot Plugin Repository</id>
<name>maven snapshot repository</name>
<url>
http://maven1.mycompany.com:8080/myartifactories/repo
</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
Error:
Could not resolve dependencies for project org.glassfish.javaeetutorial:roster-ejb:ejb:7.0.5: Failure to find org.glassfish.javaeetutorial:roster-common:jar:7.0.5 in http://maven1.mycompany.com:8080/myartifactories/repo was cached in the local repository, resolution will not be reattempted until the update interval of mycompany Release Repository has elapsed or updates are forced -> [Help 1]
EDIT:
I DO see the central repo in my effective pom:
Here is the condensed version of it
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
Simplest solution is to configure a repository manager on your mac and configure the different repositories in the repository manager. Or you can use git to switch your ${HOME}/.m2/settings.xml to different state.
Update:
Create a git repository in ${HOME}/.m2/ via git init there
add an appropriate .gitignore file which contains a single line
repository. Checkin your settings.xml file. Create a branch
for example git co -b company make the appropriate changes for
your company and check in that state. Afterwards you can simply
switch by changing into the appropriate branch in git.
Setup Repository manager like Nexus (on your machine)
and configure there necessary repositories you need. If you working
on company site you can activate/deactivate the appropriate repository
via the UI of Nexus which means you have no change in your
settings.xml.
My preference is the local git repository which make life easier for me as well.
It seems your repo is cached locally and needs to be updated forcefully.
Try following to force the updates:
mvn clean install -U
I see in your error you have pasted:
"...was cached in the local repository, resolution will not be
reattempted until the update interval of mycompany".
so you want to delete this cache, i.e. to delete it from the local repo. Go to your local repo (usually .m2/...) and delete the "placeholder": go to directory org/glassfish/javaeetutorial/7.0.5 and there you should see roster-common.XXX cached - delete it.
If this keep happening, after you deleted the 'cached' from the repo, it means that maven cannot find it in any repo. So you have to re-check your repositories definitions. For example, why don't you have the "central" repo defined in your settings.xml (like all other repos)?
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
How can I configure a maven project to take one of the artifacts from a different repository?
I would like to include this in the project https://github.com/twitter/hadoop-lzo but I can find it only in the twitter repository, not on the central maven repository.
You can set the repositories you want to use in your settings.xml, or in your POM.
If you have a team working on the project, you might want to put this in the POM so everybody has the conf.
You can do it like :
<repositories>
<repository>
<id>Maven Central</id>
<url>http://repo1.maven.org/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
.... other repos
</repositories>
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.
We have an internal Apache Archiva based repository and we have configured the repositories tag in pom.xml to be as follows. Can I assume that all dependency access will get resolved by internal repository if you have access to it and will get resolved by other repositories listed below, if internal repository is down for a certain reason.
<repositories>
<repository>
<id>internal</id>
<name>Internal Repository</name>
<url>http://192.168.1.2/archiva/repository/internal</url>
</repository>
<repository>
<id>jboss</id>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
....
</repositories>
EDIT:
I want to do away with the .m2/settings.xml file. I want to define this in my pom.xml file, so that if my repository manager is UP and running I would want the runtime to connect there, else would want to fallback into the other repositories. Would this be possible?
Maven 3.0 had it fixed as you can see in Maven developer's Jira below. The lookup will be done in the order they are declared.
https://issues.apache.org/jira/browse/MNG-4400