Hello World! I am seeking to understand the efficiency(usage) of the command above when working with openMRS modules.
After making changes in my code base, when is the mvn clean install effective to a commit? Before running git add -i or after adding the changes
Does running again mvn clean install on a module after making changes overrides the previous dependencies located in .m2 directory in case this command was once triggered on the same module. Or I manually need to first delete these dependencies from the respective directory for the new dependencies to take effect
How does maven [.m2 directory] handle multiple local branches when mvn clean install is triggered on different branches of the same module. cc: @mksd@ibacher@dkayiwa
Hello @kdaud as long as i know mvn clean install contains two commands bundled into one.
mvn clean:
This cleans/deletes all of the downloaded dependence resources as specified in the project’s pom file from the .m2 folder.
mvn install:
This downloads maven dependencies into the .m2 folder from the internet or from other folders inside the .m2 folder as specified in the pom file.
Hence, there is no need to delete the contents if u run mvn clean install because maven has already done that for you.
As far as I know mvn clean does not touch .m2. It only cleans the build’s files:
The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.
Ideally mvn clean install has not helped out. Going through a manual process to first delete the respective old folder where these dependencies were stored within .m2 directory then build again resolved the concern. However, this looks tiresome doing it manually; is there a way i can do this at build time some thing like a flag added on the command. cc @mksd
As @mksd highlighted, clean install leans your target folder and recompiles. If you are handling any faulty artefacts, you need to manually handle those as you have done
@jnsereko whether Maven attempts to download again dependencies or not depends on a lot of things, including settings that may be picked up from .m2/settings.xml.
It makes sense that a clean install will have to do more things than a mere install, including attempting to download stuff that otherwise may already be lingering in the build folders (in /target typically.) But this is speculative since I don’t know what you’re doing exactly.
The only thing I can say for sure from the top of my head is that you can force Maven to always fetch dependencies by using -U:
Git is a version control System and its main purpose is to track the changes you make to files, so you have a record of what has been done .
Maven is an automation and management tool .It helps to build Projects, dependency and documentation. It simplifies the build process.
The only case when the two workflows would overlap , is when maven is used to makes some changes in your source files like applying formatting , adding LIcenece headers etc .Thats when you would probably run a mvn clean install before git add ,
other wise the work flows are independent of each other