Uploaded image for project: 'Maven Assembly Plugin'
  1. Maven Assembly Plugin
  2. MASSEMBLY-877

give priority to module files when using jar-with-dependencies descriptor

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • component descriptor
    • None

    Description

      Currently, when you create an uber jar using jar-with-dependencies descriptor if there is resource duplicates between current module and dependencies there is no guarantee the module one will be chosen.

      E.g. :
      module A depends on module B.
      module A and module B contains a configuration file with the same name/ same path.

      If I build A using jar-with-dependencies descriptor I have no guarantee my assembly will contains the configuration file of A.

      I think this is because jar-with-dependencies use <useProjectArtifact>true</useProjectArtifact> and so there is no priority between the module and its dependencies.

      A solution could be to change the descriptor and use something like this :

      <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
      	<id>jar-with-dependencies</id>
      	<formats>
      		<format>jar</format>
      	</formats>
      	<includeBaseDirectory>false</includeBaseDirectory>
      	<fileSets>
      		<fileSet>
      			<directory>${project.build.outputDirectory}</directory>
      			<outputDirectory/>
      		</fileSet>
      	</fileSets>
      	<dependencySets>
      		<dependencySet>
      			<outputDirectory>/</outputDirectory>
      			<useProjectArtifact>false</useProjectArtifact>
      			<unpack>true</unpack>
      			<scope>runtime</scope>
      		</dependencySet>
      	</dependencySets>
      </assembly>
      

      As FileSet have priority on dependencySet, it should do the tricks.

      Does it make sense ?

      Attachments

        Activity

          People

            Unassigned Unassigned
            sbernard Simon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: