Maven的:连接多个文物 [英] Maven: Attaching multiple artifacts

查看:142
本文介绍了Maven的:连接多个文物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用一些自定义的罐子[中的任何存储库没有发现] Maven项目。要添加它们随着Maven构建我使用Maven中的附加神器目标。以下是我的POM文件:

I have a maven project that uses some custom jars [not found in any repository]. To add them along with the Maven build I am using the attach-artifact goal in maven. Following is my pom file:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.maximus</groupId>
  <artifactId>adminbuild</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>adminbuild</name>

  <build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <outputDirectory>target</outputDirectory>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${basedir}/../../resources/dependencies/java/customjar1.jar</file>
                  <type>jar</type>
                </artifact>
                <artifact>
                  <file>${basedir}/../../resources/dependencies/java/customjar2.jar</file>
                  <type>jar</type>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

使用这些罐子我的项目[customjar1.jar,customjar2.jar]有他们的上述POM文件的依赖[adminbuild]

My projects that use these jars [customjar1.jar, customjar2.jar] have their dependency on the above pom file [adminbuild].

当我执行 MVN全新安装命令,我收到以下错误:

When I execute the mvn clean install command, I get the following error:

[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.7:attach-artifact (attach-artifacts) on project adminbuild: The artifact with same type and classifier: jar:null is used more than once. -> [Help 1]

以下是 MVN -version 命令的输出:

Apache Maven 3.0.3 (r1075438; 2011-02-28 23:01:09+0530)
Maven home: C:\maven
Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
Java home: C:\Java\jdk1.6.0_26\jre
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

看来,我附上了文物的方式不正确。我不应该在同一个POM文件附加多个文物?如果是的话那么如何。请帮助。

It seems that the way I am attaching the artifacts is incorrect. Should I not attach multiple artifacts in the same pom file? If yes then how. Please help.

推荐答案

附文物是通常用来安装由您的构建创造了额外的文件,比如web应用程序,文件或来源的类罐子。

Attached artifacts are normally used to install additional files created by your build, like the classes jar of a webapp, documentation or sources.

将文件添加到您的Maven仓库,以便它们可作为依赖,你应该使用的安装文件的目标。

To add files to your maven repository so they are available as dependencies you should use the install-file goal.

编辑:附属文物由相同的groupId和artifactId的作为您的主要项目,但使用​​不同的分类识别。在你的配置,你没有指定的分类,因此错误消息。

Attached artifacts are identified by the same groupId and artifactId as your main project but with a different classifier. In your configuration, you did not specify the classifier, hence the error message.

这篇关于Maven的:连接多个文物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆