2014-06-18 12 views
9

Ecco una sfida: perché questa costruzione fallisce?Perché manca il plugin maven-war in mancanza di web.xml se l'ho configurato per non fallire sul file web.xml mancante?

Ho configurato Maven-guerra-plugin di Maven per non fallire su un file web.xml abscent, a quanto pare:

<plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <executions> 
      <execution> 
       <id>prepare-war</id> 
       <phase>prepare-package</phase> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
        <archiveClasses>false</archiveClasses> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <classpathPrefix /> 
         </manifest> 
         <manifestEntries> 
          <Implementation-Build>${build.number}</Implementation-Build> 
          <Implementation-Title>${project.name}</Implementation-Title> 
          <Built-By>${user.name}</Built-By> 
          <Built-OS>${os.name}</Built-OS> 
          <Build-Date>${build.date}</Build-Date> 
         </manifestEntries> 
        </archive> 
        <webResources> 
         <resource> 
          <!-- this is relative to the pom.xml directory --> 
          <directory>./target/dist</directory> 
         </resource> 
        </webResources> 
       </configuration> 
      </execution> 
     </executions> 
    </plugin> 

Ma nonostante questa configurazione mantiene in mancanza in questo modo:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project com.specktro.orchid.operations.portal.frontend: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1] 

In realtà non ho il web.xml, quindi ho bisogno di assemblare la guerra senza di essa.

Ho provato ad aggiungere un fasullo <webXml>none</webXml> nella configurazione, ma questo non cambia nulla ...

Che cosa mi manca?

risposta

6

L'ID di esecuzione in POM è prepare-war. Maven esegue la sua esecuzione predefinita del plugin war per i progetti con il tipo di imballaggio war. L'esecuzione predefinita ha ID default-war. Poiché il POM è attualmente configurato, l'obiettivo war è in esecuzione due volte.

Se si guarda il messaggio di errore:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project com.specktro.orchid.operations.portal.frontend: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1] 

Si può visualizzare l'ID di esecuzione che non riesce tra parentesi (default-war). Se cambi l'ID di esecuzione a default-war il tuo problema andrà via, e non avrai più due esecuzioni dell'obiettivo di guerra in esecuzione.

9

Questo dovrebbe funzionare:

<plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
      <executions> 
       <execution> 
        <id>prepare-war</id> 
        <phase>prepare-package</phase> 
        <configuration> 
         <archiveClasses>false</archiveClasses> 
         <archive> 
          <manifest> 
           <addClasspath>true</addClasspath> 
           <classpathPrefix /> 
          </manifest> 
          <manifestEntries> 
           <Implementation-Build>${build.number}</Implementation-Build> 
           <Implementation-Title>${project.name}</Implementation-Title> 
           <Built-By>${user.name}</Built-By> 
           <Built-OS>${os.name}</Built-OS> 
           <Build-Date>${build.date}</Build-Date> 
          </manifestEntries> 
         </archive> 
         <webResources> 
          <resource> 
           <!-- this is relative to the pom.xml directory --> 
           <directory>./target/dist</directory> 
          </resource> 
         </webResources> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

Si prega di notare che la sezione <failOnMissingWebXml>false</failOnMissingWebXml> è stato spostato fino alla configurazione del plugin, piuttosto che l'esecuzione.

Problemi correlati