Search code examples
javamavenantm2eclipsepackaging

Maven packaging of jars and other files


I'm new to maven and have got a project with some dependencies. Now Maven should create a jar file of all /src/main/java files and put them into a directory A. I want to achieve these things in the build process :

  • Put all dependency jars into a folder B
  • Put some other files in the project into C.
  • Then I need it gzipped and zipped
  • Set some execution permissions set in the gzip,
  • Finally pushing the two archives onto some network drive.

I've got that working with ANT but I want to do a clean port to Maven and not invoke the big ANT file.

Can someone point me in the right direction? Which plugins should I use?


Solution

  • First, have look at Maven Assembly Plugin. It might satisfy all your needs. I have used it but just little bit so I can just point you to information that you might need.

    You create XML configuration file for this plugin called Assembly Descriptor that guides its operation.

    There are some predefined available on the page of the plugin. http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html At least the one with sources in zip will help you.

    Assembly description is on http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html.

    • You can copy dependencies in dependencySets.
    • In fileSet, you can define file rights.
    • For GZipping you can look at this topic Creating a tar.gz archive with Maven
    • If copying on shared drive cannot be handled by Assembly plugin, have look at maven-copy-plugin.

    In case that Maven Assembly plugin won't handle all the thing you need, you can use: - Maven Copy Plugin - http://evgeny-goldin.com/wiki/Maven-copy-plugin to copy source files - Maven Dependency Plugin -http://maven.apache.org/plugins/maven-dependency-plugin/ for copy of all dependency JARs (goal copy-dependencies of the plugin) - Maven Resources plugin http://maven.apache.org/plugins/maven-resources-plugin/ - if resources are what you need to copy.