Wednesday, June 21, 2023

Alternative artifact creation in Maven using Ant

 HOWTO

Set target artifact, skip standard generation 

   <plugin>
      <groupId>org.codehaus.gmaven</groupId>
      <artifactId>gmaven-plugin</artifactId>
      <version>1.4</version>
      <executions>
        <execution>
          <id>set-main-artifact</id>
          <phase>package</phase>
          <goals>
            <goal>execute</goal>
          </goals>
          <configuration>
            <source>
              project.artifact.setFile(new File(project.build.directory+'/'+project.artifactId+'-'+project.version+'.war'))
            </source>
          </configuration>
        </execution>
      </executions>
    </plugin>
Skip compilation
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <executions>
     <execution>
       <id>default-compile</id>
       <phase>compile</phase>
       <goals>
          <goal>compile</goal>
       </goals>
       <configuration>
         <skipMain>true</skipMain> <--Skip
       </configuration>
     </execution>
   </executions>
</plugin>
Skip WAR generation