0

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

  1. Compiled jars are copied to a lib directory
  2. Dependencies are copied to a extlib directory
  3. 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?

3
  • 1
    First doing the assembly in parent is simply wrong because a parent is executed first before all childs. If you like to package some deps into a .tar.gz you have to add a supplemental child module which has the dependencies to the parts you would like to add. Apart from that using mvn clean package install duplicates several steps... using mvn clean install instead... And using install to make a deployment to a remote server is a wrong way using Maven. install is intended to install artifacts into local cache and deploy is intended to transfer to remote repo... Commented Sep 14, 2021 at 21:44
  • So you mean I should create a child module, add dependency in it for all other modules, and have it only for assembly and installation? Commented Sep 15, 2021 at 7:16
  • Yes exactly. That makes a separation of concern; runs the assembly at the correct time... Commented Sep 15, 2021 at 7:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.