Releasing Open Source Artifacts to Nexus/Maven Central via Travis CI - maven

I am actually searching for an solution on how to automatically release artifacts for my open source projects to maven central/our company nexus. I am using Maven/Gradle and Travis CI to build the artifacts.
Ideally i just change the version of my maven gradle module to an release version, travis recognizes that and deploys the resulting artifact to nexus/maven central.
Has anyone ideas how to do that without building releases locally.

Related

How to reference local Gradle project from Maven build as dependency?

I have several Gradle library projects and main Ant spring web-app project (historically). I'd like to replace Ant with Maven for main project while keeping existing Gradle projects nature.
Is it possible to refer local Gradle projects from pom.xml as local dependencies of Maven project?
Search readily gives me the opposite - "how to refer maven projects from gradle builds", but not my case.
Gradle always builds locally build/libs (or distributions); the only easy way to share the build dependencies between completely different projects is 'as maven repository dependencies'
in your case the options are
Work Local Builds only
add the maven plugin to the gradle builds - do local install
and refer them in the maven build locally.
Build Anywhere
Your Gradle builds publish artefacts to your local nexus
and you refer them properly in your dependencies
--
Gradle by default does not have 'maven install'; it can be added using the maven plugin see - https://docs.gradle.org/current/userguide/maven_plugin.html#header.

Maven- Deploy release version of jar

I am new to maven and I'm using the maven release plugin to do a release and the maven deploy to deploy it. What I am noticing is that when I do
mvn release:prepare it makes two commits, as it should be, with the first one being without the snapshot in the pom.xml and then a newer version in the pom.xml with the snapshot. However when I then do mvn deploy it deploys the snapshot jar to my internal repository. How will I get it to deploy the release version of my jar? Should I be checking out HEAD~1 and then do mvn deploy?
Your question is slightly unclear, but the goal to run after release:prepare is release:perform.
Depending on what you're trying to do, the install or deploy plugins may also be useful.
Sonatype, the people that run Maven Central, have a very helpful guide to using the release plugin, as well as other ways of releasing:
http://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin

Maven - Why Does it Keep Redownloading Dependencies?

When I add a new Maven dependency that I've never used before, I will do Maven build and see the dependencies being downloaded into my local machine from Nexus. All is good.
I will then create another project, specify the same dependency with the same version, do a Maven build, and I will again see the dependencies being downloaded from Nexus into my local machine.
Why are my dependencies re-downloaded every time? Aren't these dependencies already installed in my local repository?
Maven will NOT download artifacts repeatedly. The only exceptions are if you are deleting your local repository (in ~/.m2/repository by default), you are configuring usage of a different local repository and if a new SNAPSHOT version is available.

Importing a snapshot version of a dependency into Maven repository

I am having trouble importing dependencies for my Grails project into the company Nexus repository. The Grails plugin I would like to use is events-push (https://github.com/smaldini/grails-events-push). The latest released version of the plugin is 1.0.M7. It uses a very old version of Atmosphere library. The GutHub repository contains a more up-to-date version of events-push plugin, 1.0.0.BUILD-SNAPSHOT. I built the Grails plugin from the local clone of the repository and got it to work in my dev environment.
To deploy it on the intranet (in the production environment) I need to import all the plugin dependencies into the company Nexus repository. This is where I run into trouble. The project depends on a SNAPSHOT version of events-push plugin, which in turn depends on SNAPSHOT version of other Grails plugins and Java libraries (according to dependency report).
Nexus supports two types of repositories, Release and Snapshot. I can add artifacts to a Release repository (through the browser UI or in a batch mode using curl), but the artifact must not be a snapshot. I can change the repository to be a Snapshot repository, but then I lose the ability to add artifact to it through the browser or curl command.
How do I make these SNAPSHOT artifacts available to the Grails project through Maven?
Change them to a release version and deploy them to the release repository.

How to install a Maven/Gradle project along with all its dependencies to a local repository?

I have a Gradle project that depends on several open-source projects up on Maven Central. I'd like to install the project – along with all its direct and transitive dependencies – to my local maven repository, so that I could later zip it all up and put it on offline machines.
How do I do it with Gradle/Maven?
mvn dependency:get plugin will fetch the artifact with all dependencies to the local repository.
I had also developed a plugin to install remote artifacts to a local machine.
If you want to later ZIP up your project w/ dependencies and move them to a different machine, you could try Maven's appassembler plugin. It collects all dependencies and creates a launcher, all in the target folder, ready for deployment.
But note, this, by default, creates a flat directory structure with all dependencies, it doesn't preserve the Maven format. It also has the option to create a repository.

Resources