Hi Adrian,

Adrien Ruffié wrote:

> Hello all,
> 
> I have maven 3
> 
> I have a webapp which derived from a first webapp, I have read this
> article:
> 
> http://ovaraksin.blogspot.fr/2011/09/inheritance-in-maven-based-web-projects
> .html
> 
> But when I try to done following command, "mvn clean package" or a simple
> "mvn dependency:tree" I get the following error:
> 
> [ERROR] Failed to execute goal on project mycompany-ci: Could not resolve
> dependencies for project com.mycompany:mycompany-ci:jar: 001-SNAPSHOT:
> Could not find artifact com.mycompany:mycompany-webapp:war:webapp:003 in
> central (http://192.168.1.160:8081/artifactory/libs-release) -> [Help 1]
> 
> However I have 3 artifacts inside libs-release-local of my artifactory:
> mycompany-webapp-003-classes.jar
> mycompany-webapp-003.jar
> mycompany-webapp-003.pom
> mycompany-webapp-003.war
> 
> I attached also my pom.xml of the second webapp, and below a extract of my
> first webapp (the base webapp)

[snip]

> Do you have an idea of the problem ?

The problem is, that Oleg only published half of the truth in his blog. He 
did not inform, how the jar and the war plugin have to be configured in the 
first project. And the produced artifacts from above clearly shows, that you 
do not have an artifact of type "war" with "webapp" classifier.

============= %< ==============
 <project>
   ...
   <type>jar</type>
   ...
   <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-jar-plugin</artifactId>
       <configuration>
         <outputDirectory>${project.build.directory}/webapp/WEB-
INF/lib</outputDirectory><!--*-->
       </configuration>
     </plugin>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-war-plugin</artifactId>
       <executions>
         <execution>
           <id>war</id>
           <phase>package</phase><!--*-->
           <goals>
             <goal>war</goal><!--*-->
           </goals>
           <configuration>
             <classifier>webapp</classifier><!--*-->
             
<webappDirectory>${project.build.directory}/webapp</webappDirectory>
             <packagingExcludes>WEB-INF/classes/**</packagingExcludes>
             <archiveClasses>false</archiveClasses>
             ...
           </configuration>
         </execution>
       </executions>
     </plugin>
     ...
   </plugins>
   ...
 </project>
============= %< ==============

The war is build as attached artifact. It contains no .class files, but the 
jar generated as main target. However, that one has to be generated into the 
right location that the war plugin includes it into the war artifact.

The project that used these two artifacts as dependency must also use a 
special configuration for the war plugin:

============= %< ==============
 <project>
   ...
   <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-war-plugin</artifactId>
       <configuration>
         <dependentWarExcludes>META-INF/MANIFEST.MF,WEB-
INF/lib/*.*</dependentWarExcludes>
         ...
       </configuration>
     </plugin>
     ...
   </plugins>
   ...
 </project>
============= %< ==============

It is used to exclude any stuff from WEB-INF/lib (you may chose to exclude 
WEB-INF/classes/** also) from overlayed wars, since all dependencies are 
taken now into account for the resolve algorithm.

You can move most of the configuration values into properties and the 
configuration itself in the pluginManagement section of a shared parent so 
your projects may just contain the settings marked with "<!--*-->".

I've published this solution here on the list before and Oleg was a 
colleague of mine.

Cheers,
Jörg




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to