[
https://issues.apache.org/jira/browse/MASSEMBLY-864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16088147#comment-16088147
]
Plamen Totev commented on MASSEMBLY-864:
----------------------------------------
Thank you for providing the example project. While the issue demonstrated by
the project is not the same as the one originally reported I wouldn't be
surprised if they are indeed related.
I took a look at it and I'm afraid I cannot help as my Maven knowledge is not
enough to fix it (I'm not even sure if it's a bug or feature :D).
I'll write what I found. I hope that it could be of help and safe time for the
next one that will look at this issue. In order to resolve the dependencies for
the dependency set phase of the assembly process, assembly plugin uses the
{{DefaultDependencyResolver}}. To actually resolve the dependencies it uses
{{LegacyRepositorySystem#resolve}}. When {{LegacyRepositorySystem#resolve}}
have to resolve the dependencies transitively it starts to resolve the
dependencies from the root artifact(in your case the - the project itself -
{{com.axelfontaine:massembly-864}}) and checks all it's dependencies and the
dependencies of the dependencies (that's why it needs the pom files of the
dependencies) and so on. So far so good. The problem is that when it resolves
the dependencies of the root artifact it does not take into account what
profiles are active - it just picks all dependencies plus the dependencies from
the active by default profiles. To me it looks like as if it checks the pom
that is in the repository and not the current project model.
I'm not sure if the behavior of {{LegacyRepositorySystem}} (not part of the
assembly plugin) is broken or the assembly plugin calls it with wrong
arguments. Or maybe it should use different class(or dependency resolution
strategy) altogether. Or maybe this behavior is intentional and desired
(although I cannot imagine why, maybe there could be a good reason). Would be
great of somebody could throw some light on the matter.
Meanwhile I think I have workaround for your problem. You could set
{{useTransitiveDependencies}} to {{false}}. Not sure if it's applicable to your
actual project but for the example project the following works as expected:
{code:xml}
<dependencySet>
<outputDirectory>lib</outputDirectory>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<include>org.flywaydb:flyway-core</include>
</includes>
</dependencySet>
{code}
Setting {{useTransitiveDependencies}} to {{false}} means that all {{include}}
and {{exclude}} filters will be applied only to the direct dependencies and no
transitive dependencies will be added to the assembly. As I said I'm not sure
if that is OK for you actual project.
> Dependencies specified in activeByDefault profile not picked up.
> ----------------------------------------------------------------
>
> Key: MASSEMBLY-864
> URL: https://issues.apache.org/jira/browse/MASSEMBLY-864
> Project: Maven Assembly Plugin
> Issue Type: Bug
> Affects Versions: 3.0.0
> Reporter: Axel Fontaine
>
> I have the following dependencySet in my assembly XML:
> <dependencySet>
> <outputDirectory>jre</outputDirectory>
> <includes>
> <include>com.oracle:server-jre</include>
> </includes>
> <unpack>true</unpack>
> <unpackOptions>
> <includes>
> <include>jdk8.74/jre/**/*</include>
> </includes>
> </unpackOptions>
> </dependencySet>
> And the following dependency in my pom.xml:
> <dependency>
> <groupId>com.oracle</groupId>
> <artifactId>server-jre</artifactId>
> <classifier>linux-x64</classifier>
> <version>8.74</version>
> <type>tar.gz</type>
> <scope>provided</scope>
> </dependency>
> The dependency gets correctly picked up when it is declared within the main
> dependencies section of the POM. However when it is only present within a
> profile:
> <profiles>
> <profile>
> <id>CommercialDBTest</id>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> <dependencies>
> <dependency>
> <groupId>com.oracle</groupId>
> <artifactId>server-jre</artifactId>
> <classifier>linux-x64</classifier>
> <type>tar.gz</type>
> <scope>provided</scope>
> </dependency>
> I then get
> [WARNING] The following patterns were never triggered in this artifact
> exclusion filter:
> o 'com.oracle:server-jre'
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)