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

Vsevolod Golovanov edited comment on MWAR-351 at 2/21/17 6:34 AM:
------------------------------------------------------------------

In contrast, we're using {{optional}} in WAR as a way to build different WARs 
for different customers.

{code}
<dependency>
        <groupId>my.company</groupId>
        <artifactId>ui-module-a</artifactId>
        <optional>${module-a-excluded}</optional>
</dependency>
<dependency>
        <groupId>my.company</groupId>
        <artifactId>ui-module-b</artifactId>
        <optional>${module-b-excluded}</optional>
</dependency>
...
<plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
                <classifier>${customer-classifier}</classifier>
        </configuration>
</plugin>
{code}
The parent pom has profiles defining customers and their modules.

This mirrors this ear filtering:
{code}
<plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <configuration>
                <classifier>${customer-classifier}</classifier>
                <modules>
                        <ejbModule>
                                <groupId>my.company</groupId>
                                <artifactId>module-a</artifactId>
                                <excluded>${module-a-excluded}</excluded>
                        </ejbModule>
                        <ejbModule>
                                <groupId>my.company</groupId>
                                <artifactId>module-b</artifactId>
                                <excluded>${module-b-excluded}</excluded>
                        </ejbModule>
                </modules>
        </configuration>
</plugin>
{code}

I'm unaware of a another way to achieve this given this set of properties.


was (Author: vsevolod golovanov):
In contrast, we're using {{optional}} in WAR as a way to build different WARs 
for different customers.

{code}
<dependency>
        <groupId>my.company</groupId>
        <artifactId>ui-module-a</artifactId>
        <optional>${ui-module-a-excluded}</optional>
</dependency>
<dependency>
        <groupId>my.company</groupId>
        <artifactId>ui-module-b</artifactId>
        <optional>${ui-module-b-excluded}</optional>
</dependency>
...
<plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
                <classifier>${customer-classifier}</classifier>
        </configuration>
</plugin>
{code}
The parent pom has profiles defining customers and their modules.

I'm unaware of a another way to achieve this given this set of properties.

> Optional dependency not being included in the WEB-INF/lib folder
> ----------------------------------------------------------------
>
>                 Key: MWAR-351
>                 URL: https://issues.apache.org/jira/browse/MWAR-351
>             Project: Maven WAR Plugin
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Hockchai Lim
>            Priority: Minor
>
> I've a maven web module that has several dependencies that are declared with 
> <optional>true</optional> in pom.xml.  For example:
>               <dependency>
>                       <groupId>log4j</groupId>
>                       <artifactId>log4j</artifactId>
>                       <optional>true</optional>
>               </dependency>
> When performing packaging of this project, Maven WAR Plugin is not including 
> those optional dependencies to the WEB-INF/lib folder, which I think is 
> incorrect.  According to  
> https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html,
>  optional dependency should work like transitive dependency for this web 
> module.  Optional dependency should only be ignored on projects/modules that 
> reference this web modle.
> Below is the relevant sections from 
> https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
>  link:
> How do optional dependencies work?
> Project-A -> Project-B
> The diagram above says that Project-A depends on Project-B. When A declares B 
> as an optional dependency in its POM, this relationship remains unchanged. 
> Its just like a normal build where Project-B will be added in its classpath.
> Project-X -> Project-A
> But when another project(Project-X) declares Project-A as a dependency in its 
> POM, the optional dependency takes effect. You'll notice that Project-B is 
> not included in the classpath of Project-X; you will need to declare it 
> directly in your POM in order for B to be included in X's classpath.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to