jira-importer opened a new issue, #181:
URL: https://github.com/apache/maven-war-plugin/issues/181

   **[Hockchai 
Lim](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=hockchailim)** 
opened 
**[MWAR-351](https://issues.apache.org/jira/browse/MWAR-351?redirect=false)** 
and commented
   
   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.
   
   
   ---
   
   **Affects:** 2.2
   
   1 votes, 5 watchers
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to