How can I change the war name generated by maven assembly plugin

前端 未结 3 558
栀梦
栀梦 2020-12-23 11:18

How can I change the name from 1.0.snapshot-jar-with-dependencies to something else, below are contents of my POM:



        
相关标签:
3条回答
  • 2020-12-23 11:22

    In the case of packaging a JAR with dependencies, the won't work. You will fix it by using the dependency plugin:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>project.group.id</groupId>
                                    <artifactId>artifact-id</artifactId>
                                    <version>0.0.1-SNAPSHOT</version>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${basedir}/some/dir</outputDirectory>
                                    <destFileName>custom-name.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    
    0 讨论(0)
  • 2020-12-23 11:24

    Use the following in the configuration of the maven-assembly-plugin:

    <configuration>
      <finalName>custom-name</finalName>
      <appendAssemblyId>false</appendAssemblyId>
    </configuration>
    

    Full details in the official documentation of the assembly:single mojo.

    0 讨论(0)
  • 2020-12-23 11:33

    You can achieve this by specifying the finalName property in your pom, e.g.

    <build>
        <finalName>something-else</finalName>
        ...
    </build>
    
    0 讨论(0)
提交回复
热议问题