简体   繁体   中英

Maven tar target output folder

I currently have a maven project structured as such:

-parent module/   
  -child_module1/
     -scripts_directory/
     -src/
        -main/
           -java/
           -resources/
     -test/

  -child_module2/
     -scripts_directory/
     -src/
        -main/
           -java/
           -resources/
     -test/  

  -child_module3/     
    ... (same structure as above child modules)

When the project is built it creates a jar for each child module and transfers it to a common directory outside of the execution path; copies all the dependencies of each child module into this same directory as well; copies the contents of each child module's scripts_directory into another common directory; and finally all its resources into another common directory

So the final structure after running mvn install is:

/packages/mymavenapp/
  -conf/ (contains all the resources of each child module's resources)
  -lib/ (contains all the child module jars (compiled) and their dependencies)
    -child_module1.jar
    -child_module2.jar
    -child_module3.jar
    -spring jars 
    -more dependency jars
  -scripts/ (contains all the contents of each child's scripts_directory)
    -run_child1_jar.pl
    -run_child2_jar.pl
    -run_child3_jar.pl

I currently have this build structure working. I would like to tar the directory /packages/mymavenapp into mymavenapp.tar.gz and push it to its nodes.

I know I can have a shell script that tars this directory but would like to know if I can do this in the maven build cycle easily

EDIT:

The location of the final target directory is not as important so the target directory

 mymavenapp/

could be inside the parent module's directory so as long as the structure inside mymavenapp/ stays the same along with its contents ie. mymavenapp/conf/ ; mymavenapp/lib/ ; mymavenapp/scripts/

You can use maven-assembly plugin in saperate build profile, at the end of build invoke maven build with that build profile

assembly plugin is very flexible and it takes a configuration file where you can define your input files and the location of that file inside tar file and the location of final tar file for example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM