mvn install running before package - java-8

So I have a parent maven project with a few child modules. All child projects generate jars and have dependencies. As part of the package phase, following are done
Compiled jars are copied to a lib directory
Dependencies are copied to a extlib directory
A tar.gz package is created in the end (I am worried about the order as assembly is done in parent while copy is done in child project poms)
Once packaging is complete, I want to install the package on a remote server, so I have then antrun plugin which takes care of it, inside install phase.
The problem is that I cannot control the order in which things are done. I would like to keep the responsibilities separate but if I run the command: mvn clean package install, it will run the install phase first which I think is because it is part of parent pom deployment which is done first. I have to run it in two commands i.e. mvn clean package and then mvn install to make sure latest is deployed.
Is there anyway to run this install phase at the end when packaging is done?

Related

Can I split dependency resolution in maven into separate command?

I want to split a mvn install command into 2 separate ones - dependency resolution and build itself, like it can be done in NPM (with npm run ci and npm run webpack separately). The reason to do so is to measure how much time is spend on dependency resolution and how much on build itself.
I have tried to use mvn dependency:go-offline with mvn install -o afterwards. According to docs this is exactly what I need, however it does not work. Plugin dependencies are not downloaded (mentioned in pom file under build/plugins).
Can this goal be achieved somehow?
Indeed, it seems the dependency:go-offline standard goal is not "perfect" as some plugins may still trigger some (re)downloading during the mvn package phase.
(I had noticed this when looking at this SO question about how to optimally rely on Docker's cache.)
To fix this, you can try mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies after installing the corresponding plugin mentioned in this SO answer by #user2813807.

<Maven> How is the command "mvn dependency:resolve" different from "mvn clean install"?

I would like to ask about the use of the command "mvn dependency:resolve". When I executed the command in project folder, it seems it download jars and build the application. I wonder if it has the same functions as "mvn clean install". Thanks.
Install will compile, test & package your Java project and even install/copy your built .jar/.war file into your local Maven repository.
But dependency:resolve compile your application and print resolved dependencies.

Compile ODL controller

I am trying to follow this example but I found one problem. I am trying to compile ODL controller but the files structure have changed compared to the previous versions and I don't know in what path I have to be to compile the controller.
I am following
git clone https://git.opendaylight.org/gerrit/p/controller.git
Check that the used Yang tools version is >= 0.5.8-SNAPSHOT.
But I have 0.8.0 (downloaded today in the same link).
And then I have to do this to compile the ODL controller:
cd controller/opendaylight/distribution/opendaylight
mvn clean install
But this path doesn exist on the version I have donwloaded.
¿In what directory I have to be to run the mvn clean install?
The ping example wiki is old and outdated. That was back when everything was in the controller project except for yangtools and before ODL was converted to use karaf. So the controller/opendaylight/distribution/opendaylight directory is long gone. So if you want to create and run the ping example, you would create a karaf feature and run the karaf distro in the controller project. You can follow what is done with the toaster sample and its associated wiki which is pretty up-to-date: https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Toaster_Step-By-Step.
just run 'mvn clean install' in the root dir (so, the "controller" dir).
also, to be safe, I'd delete your "repository" directory in your .m2
dir (usually, in ~/.m2/repository).
Finally, make sure your mvn .settings.xml file is correct. here's a
link for that.

Maven: non lifecycle-related goal

I have project for which you need to have a few dependency downloadable from an internal repo.
If this is not possible I'd like to provide an option to install the deps locally (using maven-install-plugin).
Point is: since this is fully optional I do not want this to be part of the regular lifecycle (I've seen solutions where the install plugin is executed in the clean phase). Which is the terser and more elegant way to provide an option to install prerequisites locally?

Maven RPM Packaging After *.jar creation

I researched everywhere, but could not find answer. My problem is that I would like to create my *.jar file with all its dependencies using the usual mvn install scheme. But once the *.jar is created, I like to package it using Mojo RPM plugin.
The problem is that Mojo RPM plugin is executed during mvn install lifecycle. However the *.jar is not created until after the install phase is complete. So when the rpm plugin runs, it will not have any *.jar to install.
How can we build, install the jar and then package it into an rpm using Mojo RPM plugin?

Resources