In Maven2, what's the simplest way to build a WAR and the EAR to contain that WAR in a single POM?

前端 未结 3 676
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 13:56

Situation is pretty straightforward. I have a Java webapp that I\'m converting to be built with Maven. At present, the app is built with Ant into a single WAR file, which is the

3条回答
  •  别跟我提以往
    2021-02-04 14:36

    In Maven every single project produce an aritifact. In your situation I suggest create two project one for war and one for ear. If you need mutltiple versions of your projects you can achive that using classifiers and profiles.

    This is excerpt of richfaces examples pom.

        
            maven-war-plugin
            
              
                jee5
                package
                
                  war
                
                
                  ${project.build.directory}/${project.build.finalName}-jee5
                  jee5
                  WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/el-*
                  WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/el-*
                
              
              
                tomcat6
                package
                
                  war
                
                
                  ${project.build.directory}/${project.build.finalName}-tomcat6
                  tomcat6
                  WEB-INF/lib/el-*
                  WEB-INF/lib/el-*
                
              
            
            
              
                
                  ${basedir}/src/main/java
                  /WEB-INF/src
                
              
            
          
    

    In your ear pom use profiles to import required dependency with appropriate classifier.

    
      jee5
      
         
           org.richfaces.samples
           richfaces-demo
           ${richfaces-version}
           jee5
           war
           runtime
         
      
       
    

提交回复
热议问题