【发布时间】:2014-01-17 13:24:45
【问题描述】:
我正在一个多模块项目中开发一个 Maven 插件,我想稍后在同一个项目中使用它。这是项目的布局:
sk:a:1.0:pom
|
--sk:a0:1.0:jar (the custom plugin)
|
--sk:a1:1.0:pom
| |
| --sk:a11:1.0:jar (a simple JAVA jar)
| |
| --sk:a12:1.0:jar (a simple JAVA jar)
|
sk:a2:1.0:pom
sk:a2:1.0 依赖于 sk:a11:1.0 和 sk:a12:1.0 和插件 sk:a0:1.0:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sk</groupId>
<artifactId>a</artifactId>
<version>1.0</version>
</parent>
<artifactId>a2</artifactId>
<dependencies>
<dependency>
<groupId>sk</groupId>
<artifactId>a11</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>sk</groupId>
<artifactId>a12</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>sk</groupId>
<artifactId>a0</artifactId>
<version>1.0</version>
<executions>
...
</executions>
</plugin>
</plugins>
</build>
</project>
来自 sk:a0:1.0 的自定义插件在其 execute() 中调用
Set<Artifact> artifacts = project.getDependencyArtifacts();
方法并迭代所有工件,其中:
for(Iterator<Artifact> iterator = artifacts.iterator(); iterator.hasNext();)
{
Artifact artifact = iterator.next();
getLog().info((artifact.getFile() == null ? "artifact NULL" : "artifact OK"));
}
现在它显示“artifact NULL”。在我的插件中,我需要能够读取工件的文件(如 java.io.File)。如何获取每个依赖项的文件?
谢谢,
SK
【问题讨论】:
-
你能描述一下你想用这个插件实现什么吗?
标签: maven plugins dependencies