将Artifact项检索为属性

时间:2013-04-18 09:52:12

标签: java maven-2

我试图通过名称检索maven-dependecy-plugin中的工件项目作为在我的war清单文件中写入其值的属性。 我需要像${project.artifactItems["name"].value}之类的东西来检索我的值,而不必将每个jar清单文件作为一个流程序来读取。

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
  <execution>
    <id>copy-installed</id>
    <phase>test</phase>
    <goals>
      <goal>copy</goal>
    </goals>
    <configuration>
      <artifactItems>
        <artifactItem>
          <groupId>${project.groupId}</groupId>
          <artifactId>prj-applet</artifactId>
          <version>${test.project.version}</version>
          <type>jar</type>
        </artifactItem>
        <artifactItem>
          <groupId>${project.groupId}</groupId>
          <artifactId>prj-pdf-render-applet</artifactId>
          <classifier>jar-with-dependencies</classifier>
          <version>${test.project.version}</version>
          <type>jar</type>
        </artifactItem>
      </artifactItems>

我需要使用war插件在清单文件中插入每个检索到的值:

<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>test</warName>
  <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
   <!-- <warName>test</warName> -->
  <failOnMissingWebXml>false</failOnMissingWebXml>
  <archive>
    <manifestEntries>

      <applicationVersion>${pom.version}</applicationVersion>
      <applicationBuildTimestamp>${maven.build.timestamp}</applicationBuildTimestamp>
    </manifestEntries>
  </archive>
</configuration>

1 个答案:

答案 0 :(得分:1)

假设你有这种依赖

<dependency>
    <groupId>some-groupid</groupId>
    <artifactId>some-artifactid</artifactId>
    <type>jar</type>
</dependency>

你可以通过$ {maven.dependency.some-groupid.some-artifactid.jar.path}来获得你的依赖