附加的工件必须与其对应的主工件具有不同的 ID

An attached artifact must have a different ID than its corresponding main artifact

我在使用 maven 命令后得到这个错误

执行目标失败org.codehaus.izpack:izpack-maven-plugin:5.1.3:izpack (默认)在项目 izpack-example 上:目标的执行默认值 org.codehaus.izpack:izpack-maven-plugin:5.1.3:izpack 失败:对于工件 {com.example.test.installer:izpack-example:1.0-SNAPSHOT:jar }:附加的工件 必须与其对应的主要工件具有不同的 ID。 -> [帮助 1]

我尝试搜索解决方案,一定是依赖项有问题(如错误所述),但仍然无法解决。

这是我的 pom.xml 文件:

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example.test.installer</groupId>
<artifactId>izpack-example</artifactId>
<version>1.0-SNAPSHOT</version>
<name>An Example of an installer using izpack</name>

<!-- seems like this needs to be "jar" to accomplish a build of java code too? a bit confused
on the difference between putting "pom" and "jar" here. -->
<packaging>jar</packaging>

<!-- maven repository where the izpack-maven-plugin  and such live -->
<repositories>
 <repository>
  <id>codehaus-releases</id>
  <url>https://nexus.codehaus.org/content/repositories/releases</url>
 </repository>
</repositories>

<properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <staging.dir>${project.build.directory}/staging</staging.dir>
 <izpack.version>5.1.3</izpack.version>
</properties>

<!-- must have a dependency on our separate package that contains the custom
panels -->
<dependencies>
  <dependency>
   <groupId>com.example.test.installer</groupId>
   <artifactId>izpack-panels</artifactId>
   <version>1.0-SNAPSHOT</version>
  </dependency>
</dependencies>


<build>

<defaultGoal>package</defaultGoal>

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.codehaus.izpack</groupId>
      <artifactId>izpack-maven-plugin</artifactId>
      <version>${izpack.version}</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-clean-plugin</artifactId>
      <version>2.4.1</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>2.6</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-install-plugin</artifactId>
      <version>2.3.1</version>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <version>2.3</version>
    </plugin>
  </plugins>
</pluginManagement>


<plugins>

  <!-- copy all resources to the staging directory. -->
  <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <!-- here the phase you need -->
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${staging.dir}</outputDirectory>
          <!-- recursive copy of all resource under src/main/izpack. this is the stuff to install as well as install.xml and panel data and such -->
                        <resources>
                            <resource>
                                <directory>src/main/izpack</directory>
                                <includes>
                                    <include>**/*</include>
                                </includes>
                                <filtering>false</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>


  <plugin>
   <artifactId>maven-dependency-plugin</artifactId>
      <executions>
         <execution>
           <!-- copy izpack custom (custom panels, etc.) jars to izpack staging custom -->
           <id>copy-izpack-dependencies</id>
           <phase>prepare-package</phase>
           <goals>
              <goal>copy-dependencies</goal>
           </goals>
           <configuration>
              <outputDirectory>${staging.dir}/custom</outputDirectory>
              <excludeTransitive>false</excludeTransitive>
              <stripVersion>true</stripVersion>
              <overWriteReleases>true</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
              <includeArtifactIds>izpack-panels</includeArtifactIds> <!-- IMPORTANT: this causes *only* our custom panels to be copied -->
           </configuration>
        </execution>
   </executions>
  </plugin>

<!--
 We need to tell the izpack-maven-plugin what to use as the base directory (this is our staging area), and also tell it the install file to use:
-->
<plugin>
   <groupId>org.codehaus.izpack</groupId>
   <artifactId>izpack-maven-plugin</artifactId>
   <!-- <version>${izpack.version}</version> -->
   <configuration>
      <descriptorEncoding>UTF-8</descriptorEncoding>
    </configuration>
   <executions>
      <execution>
         <phase>package</phase>
         <goals><goal>izpack</goal></goals>
         <configuration>
            <!-- base for relative paths in izpack descriptor -->
            <baseDir>${staging.dir}</baseDir>
            <installFile>${staging.dir}/install.xml</installFile>
             <output>${project.build.directory}/${outname}</output>
         </configuration>
      </execution>
   </executions>
   <!-- must have a dependency here on any code used in the installer, otherwise the classloader
   will not find it.  So in this case we need our panels and then the package that contains the base classes
   for the panels -->
   <dependencies>
      <dependency>
        <groupId>org.codehaus.izpack</groupId>
        <artifactId>izpack-panel</artifactId>
        <version>${izpack.version}</version>
      </dependency>
      <dependency>
        <groupId>com.example.test.installer</groupId>
        <artifactId>izpack-panels</artifactId>
        <version>1.0-SNAPSHOT</version>
      </dependency>
    </dependencies>
</plugin>

</plugins>
</build>

</project>

非常感谢

您的问题是您正在调用 izpack-maven-plugin,它目前正在尝试生成一个与另一个人工制品(主要人工制品)同名的人工制品

要解决这个问题,您应该使用 finalNameclassifier 字段来配置此插件。

在此处查看文档:https://izpack.atlassian.net/wiki/spaces/IZPACK/pages/491628/IzPack+Maven+Plugin+Reference

izpack 5.1.3 有同样的问题,恢复到 5.1.2 并且错误消失了。我在这两种情况下都定义了 finalName

编辑:izpack 5.1.3 有效,但正如@Prim 所建议的,您需要在配置中同时拥有 finalNameclassifier