Multi-module Maven project and jetty:run

后端 未结 6 549
无人共我
无人共我 2020-12-12 17:40

I\'m trying to split a Maven WAR project into two modules, so that I can build a separate JAR file with command line tools. The result has the following structure:

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 18:00

    Create a profile inside the war module (project-war). Within this profile, configure jetty to attach to a lifecycle phase and execute the run goal explicitly. Now when maven runs from the toplevel project with that profile enabled, it will invoke jetty:run and have sister module dependency resolution (as is normal when executing maven commands from the toplevel project).

    The example configuration, when placed in the pom.xml of the web module (project-war), arranges for jetty:run to execute during the test phase. (You may choose another phase, but make sure it's after compile.)

    Run from toplevel: mvn test -Pjetty-run or mvn test -DskipTests=true -Pjetty-run. This will compile dependencies as required and make them available but invoke jetty:run within the correct module.

    
      ...
      
      
        jetty-run
        
          
            
              org.mortbay.jetty
              jetty-maven-plugin
              7.1.6.v20100715
              
                ...
                
                  ${project.build.directory}/${project.build.finalName}
                
                ...
              
              
                
                  jetty-run
                  test
                  
                    run
                  
                
              
            
          
        
      
    ...
    
    

提交回复
热议问题