How to setup Travis-CI to consume dependencies from oss.sonatype.org - maven

I currently have a travis-ci setup that runs a build out of a github repository. Previously I had no need for snapshots in oss.sonatype.org but now I do. I'm getting an error saying that the dependency can't be found meaning that travis-ci I assume does not use it as the default maven repo. How can I tell travis to use oss.sonatype.org as well as its default repo's setup?
edit 1: Upon further investigation i found that travis is apparently setup to use central and sonatype mirrors so i'm not sure what's going on at all.
https://travis-ci.org/FINRAOS/herd/builds/298071150

Related

How do you get maven child projects to build in Jenkins when using CI Friendly versions?

I am using CI Friendly versioning in my Parent-Child Maven project. I can't get the child to build on the Jenkins server. It builds fine on my server. I am getting the "Failed to parse POMs" error saying it can't find "myProj-parent:pom:${revision}" in nexus. I am using the Maven Flatten Plugin and as I said it works when I run Maven from my server. But for some reason in Jenkins it is not resolving.
The "revision" is set in the properties section of the parent POM.
Any hints?
We have the same problem when we do a sparse checkout of the child module only.
We solved it by adding a sparse checkout of all pom.xml files.
I hope this will help you.
If you're using the Jenkins maven-plugin, the failure may be due to an old unresolved bug. A workaround from the JIRA conversation is to use the pipeline-maven-plugin (withMaven step).
The pipeline-maven-plugin exposes a similar bug in Maven that was fixed in version 3.8.5. My build works using the pipeline-maven-plugin after upgrading Maven on the Jenkins server.

maven build from different repos from one pom.xml

Is it possible to build(and not download) a dependency in same pom.xml?
Another team builds/maintains a code in git repo A. I have to use that as a library in my code.
When I build my code using maven, I want this to be checked out and built and then the jar be included as a dependency.
I understand this can be achieved using Jenkins jobs.
And in dev stage, I can install an already built jar in m2 repo and use the jar as dependency.
However, I would want to confirm if its possible to solve this scenario outside Jenkins. That is, I as a developer, can I configure the build of repo A during build my code?
I hope I am able to explain the scenario.
Thanks.

Clean my maven local repository

i am trying to find a automatic way to clean my Maven local repository.
i am already tried using the purge plugin but he didn't work as i expected (was no consistent). then i tried the remove-project-artifact plugin. This plugin work as i expected, but then i had new problem, i have more then one Maven project that use the same local repository, so when a few build run in the same time (only one of the build operator the remove-project-artifact plugin), some of the build are failing because of this plugin.
so my question is if someone had the same problem and managed to solve it?

Maven deploy multi module project only if all modules build successfully

I have a maven multi module project with several modules. I want to deploy them (mvn deploy) only if they all pass a full mvn install (which includes the tests).
Currently, I run a mvn install on the project. If all modules pass, I run mvn deploy to do the deployment. The problem I see is the waste of time calling mvn twice (even if I skip tests on the second run).
Does anyone have an idea on this?
EDIT: I have learned that using Artifactory as a repository manager and the maven-artifactory-plugin with your maven setup will add the atomic deploy behaviour to the mvn deploy command. See the Build Integration section in the Artifactory documentation.
[DISCLOSURE - I'm associated with JFrog. Artifactory creator.]
Take a look at the deployAtEnd parameter of Maven Deployment plugin: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
This is a bit tricky. Maven is not atomic when it executes the build life-cycle. So a broken set of artifacts may end up in a repository.
One solution I know is Nexus Pro: http://www.sonatype.com/Products/Nexus-Professional/Features - it allows you to promote builds or define certain repos as staging. So only verified versions get promoted to be used. Maybe artifactory has something similar - I just don't know.
If that solution is too expensive you probably need to create a cleanup build or profile to remove artifacts that where already uploaded. My first guess would be to write a Maven plugin to use the the proxy remote API or maybe the maven features are already sufficient. But since deploy means update the meta-data xml files too I dont think there is a delete - not sure on this either.

Maven cannot find richfaces 3.3.x in Central repo

I am trying to follow this tutorial:
http://docs.jboss.org/richfaces/latest_3_3_X/en/cdkguide/html_single/
I am hitting a roadblock with the maven commands.
First the org.richfaces.cdk version 3.3.3.Final was not found in the central repository, so I had to manually install version 4.2.2.Final to my local repository by downloading the file maven-richfaces-resources-plugin-4.2.2.Final.jar
I then had to manually install the org.richfaces.cdk plugin to my local respository.
Next, to run the command in section 4.1. I had to change archetype:create to archetype:generate. Running this command showed that maven couldn't find META-INF/archetype.xml in the jar file. I am stuck at this point. Any pointers?
Per this thread, that version of richfaces is in the JBoss Maven Repo, not Central
https://community.jboss.org/thread/172034?_sscc=t
In general, Software Vendors maintain their own Maven repos and do not push out every release to Central. SpringSource, Atlassian, and Oracle (java.net) come to mind.
Archetypes are dependencies just like project dependencies / plugins, so you will likely need to add the JBoss repository to your pom.xml or settings.xml in order for the archetype to work. See the above link for how to do that.
I figured it out! noahz's answer helped but wasn't the complete solution. I am still going to accept his answer. After substituting the Atlassion repo for the Jboss maven repo in settings.xml, I was still seeing the 'BUILD FAILURE' error saying it couldn't find the richfaces artifact. Maven was still looking in the central repo not in the Atlassian repo. So after a bit of research found that the central repo could be overriden with a tag. Follow this link:http://maven.apache.org/guides/mini/guide-mirror-settings.html.
Build is now successful.

Resources