maven-assembly-plugin icon indicating copy to clipboard operation
maven-assembly-plugin copied to clipboard

[MASSEMBLY-877] give priority to module files when using jar-with-dependencies descriptor

Open jira-importer opened this issue 7 years ago • 2 comments

Simon opened MASSEMBLY-877 and commented

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 ?


No further details from MASSEMBLY-877

jira-importer avatar Feb 19 '18 17:02 jira-importer