You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Darío Cutillas (Jira)" <ji...@apache.org> on 2020/05/04 06:49:00 UTC

[jira] [Commented] (MASSEMBLY-928) Allow declaring items within .

    [ https://issues.apache.org/jira/browse/MASSEMBLY-928?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17098717#comment-17098717 ] 

Darío Cutillas commented on MASSEMBLY-928:
------------------------------------------

No, not really. AFAIK that property is going to let me decide the name of the output file based on information from the dependency. I understand my example was not clear enough, the _key_ part was in fact the _filtering_ flag.

What I'm proposing however is about allowing the maven assembly plugin to generate content based on the dependency. 

Example use case: 

Consider a multi-module project where I have modules A, B and C that are _cli_ applications. It is expected to have D, E, F, G... cli applications in the future.
I want to create a _distribution package_ with the following structure:

* A lib/ folder containing the dependencies (direct & transitive) of all A B C. 
* All A.jar, B.jar & C.jar (in the root folder of the distribution package)
* A _run script_ for each A, B and C (in the root folder of the distribution package). The scripts look all the same, they differ only in the name of the jar file they point to.

I can create then a module which is going to use the `maven-assembly-plugin` to easily do the first thing. But in order to accomplish the rest I'd need to handle that in the A, B, C poms, which is not ideal because the _distribution package_ creation should only be a concern of the module that I create for that specific purpose. Also notice that because A, B and C scripts are equivalent, I do not wish to repeat myself and have those scripts within A B C modules. Again, also because the script is part of the distribution package creation and not of the module that produces the jar itself.

Allowing `<file>` items within`<dependencySet>` makes it possible to declaratively iterate dependencies and use dependency information to generate output. To accomplish the same today we need to make several modules target same destination folder which produces coupling between modules at packaging level.


> Allow declaring <file> items within <dependencySets>.
> -----------------------------------------------------
>
>                 Key: MASSEMBLY-928
>                 URL: https://issues.apache.org/jira/browse/MASSEMBLY-928
>             Project: Maven Assembly Plugin
>          Issue Type: New Feature
>          Components: dependencySet
>            Reporter: Darío Cutillas
>            Priority: Major
>
> I'd like to be able to express copying of files within the {{<dependencySets>}} of an assembly descriptor.
> Consider the following use-case:
> A maven module {{A}} of a multi-module project has dependencies {{B}}, {{C}}.
> A can use the maven-assembly-plugin to perform custom packaging of the dependencies {{B}} and {{C}} by means of the {{dependencySets}} element. For example, it could be creating a bundle with {{B}} and {{C}} unpacked in a folder matching the dependency artifactId by using the {{artifact.artifactId}} property (which is only available within the {{dependencySet}}).
> But as part of the packaging, we want to be able to generate and filtered file, whose content depends on the dependency artifactId, for each of the included dependencies, with the filename matching the artifact name.
> Today I only see two possibilities:
> * The file needs to have been packed in the specific dependency. This is not good because the file might not make sense outside {{A}} or {{B}} and {{C}} could be dependencies that are not own by our multi-module.
> * -A separated assembly descriptor needs to be created and multiple executions have to be specified. This requires creating per-dependency {{<filter>}} files and does not scale well.- This is not a possibility because it is not possible to have the {{<destName>}} based on a property.
> Instead I'd like to have the possibility of writing an assembly descriptor such as:
> {code:xml}
> <dependencySets>
>   <dependencySet>
>   ..
>     <files>
>       <file>
>         <source>my-template</source>
>         <destName>${artifact.artifactId}</destName>
>         <filtering>true</filtering>
>       </file>
>     </files>
>   ..
>   </dependencySet>
> </dependencySets>
> {code}
> And that filtering would expand also the {{<dependencySet>>}} specific properties such as {{${artifact.artifactId}}} in {{my-template}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)