如何更改maven程序集插件生成的war名称

Gan*_*row 83 maven-2

如何将名称更改为其他名称1.0.snapshot-jar-with-dependencies,以下是我的POM的内容:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2-beta-5</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.package.example.MainClass</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

Pas*_*ent 162

在配置中使用以下内容maven-assembly-plugin:

<configuration>
  <finalName>custom-name</finalName>
  <appendAssemblyId>false</appendAssemblyId>
</configuration>
Run Code Online (Sandbox Code Playgroud)

assembly:singlemojo 的官方文档中的完整详细信息.

  • 程序集:程序集已弃用,请使用[assembly:single](https://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html) (8认同)

Pét*_*rök 88

您可以通过finalName在pom中指定属性来实现此目的,例如

<build>
    <finalName>something-else</finalName>
    ...
</build>
Run Code Online (Sandbox Code Playgroud)

  • 实际上,你需要Pascal建议的`<appendAssemblyId> false </ appendAssemblyId>`标签. (7认同)
  • 再次,我得到了一些东西 - 其他jar-with-dependencies这个工作,我怎么能摆脱jar-with-dependencies,当我删除descriptorRefs我得到构建错误 (4认同)

Ric*_*ckB 5

在使用依赖项打包JAR的情况下,将无效.您将使用依赖项插件修复它:

        <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>
Run Code Online (Sandbox Code Playgroud)