How to remove version number from war file

蹲街弑〆低调 提交于 2019-11-30 23:00:21

Within the <build> tag specify the name that you need for the artifact as "finalName".

<build>
    <finalName>sfint</finalName>
</build>

You can configure maven-ear-plugin to omit the version information in the EAR file:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.10.1</version>
        <configuration>
           [...]
           <fileNameMapping>no-version</fileNameMapping>
        </configuration>
      </plugin>
    </plugins>
  </build>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <outputFileNameMapping>@{artifactId}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>

This will solve your problem:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>myEAR</groupId>
  <artifactId>myEAR</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ear</packaging>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.10</version>
        <configuration>
          <earSourceDirectory>EarContent</earSourceDirectory>
          <generateApplicationXml>false</generateApplicationXml>
          <version>6</version>
          <defaultLibBundleDir>lib</defaultLibBundleDir>
          <fileNameMapping>no-version</fileNameMapping>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>myWAR</groupId>
        <artifactId>myWAR</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>
  </dependencies>
</project>

your final EAR will be myEAR-0.0.1.SNAPSHOT.EAR that contains myWAR.war (without version number) if you want to remove version number from EAR also than add myEar

If the war/ejb is part of an ear project, one should use bundleFileName to change the module names in the final ear artifact.

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-ear-plugin</artifactId>
   <version>${version.ear.plugin}</version>
   <configuration>
     <modules>
       <webModule>
         <groupId>com.foo</groupId>
         <artifactId>myapp-web</artifactId>
         <contextRoot>/myapp</contextRoot>
         <bundleFileName>myapp-web.war</bundleFileName>
       </webModule>
       <ejbModule>
         <groupId>com.foo</groupId>
         <artifactId>myapp-ejb</artifactId>
         <bundleFileName>myapp-ejb.jar</bundleFileName>
       </ejbModule>
     </modules>
   </configuration>
 </plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!