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

时间:2018-10-18 08:54:08

标签: maven dependencies pom.xml

使用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>

非常感谢您

2 个答案:

答案 0 :(得分:1)

您的问题是您正在呼叫izpack-maven-plugin,它目前正在尝试生产一种与另一人工制品(主要是人工制品)同名的人工制品。

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

在此处查看文档:{​​{3}}

答案 1 :(得分:0)

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

编辑:izpack 5.1.3可以工作,但是如@Prim所建议,您需要在配置中同时包含finalNameclassifier