سؤال

i have huge project that contains around 200 jars, when i prepare release maven prepare for all jars but for sure there are jars that has not been modified since last build so is there any way to check if jar has been modified since last build from scm? and exclude them?

i dont want to relase jars (more than 200) individually.

for example: i want to make relase for parent but i dont want to relase jar4 that has not been modified

-Parent

---------Module1

----------------jar1*

----------------jar2*

---------Module2

----------------jar3*

----------------jar4   
هل كانت مفيدة؟

المحلول

for example: i want to make relase for parent but i dont want to relase jar4 that has not been modified

The syntax for this is

mvn -pl Module1,Module2/jar3 <your maven goals here>

(in this case you want to build all of Module1 and just jar3 of Module2)

Now the tricky part is how to assemble the parameter to -pl. I am pretty sure there is no maven way to do that, so you will probably have to write a shell script (or Ruby, Groovy, PERL python etc. script) that does that for you.

Basically, what your script must do:

  • look for all maven project directories (directories that contain a pom.xml) in the given directory, sort them in reverse (deepest paths first)
  • find all changed files in the entire hierarchy (using svn, cvs or whatever calls)
  • map each changed file to one of the projects (by comparing paths), collect all matched projects in a list
  • Now optimize the list by doing some parent/child optimization (if all children of a given parent are present, remove the children and add the parent). Do this repeatedly until you reach the root hierarchy.
  • From the remaining list, extract the relative paths, join them with a comma and start your maven process using that value for the -pl parameter.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top