我创建了POM.xml文件,它完美运行,直到我删除了第三方jar,这依赖于我的项目 . 问题是jar丢失了,但它是使用maven-antrun-plugin创建的 . 以下是创建jar的插件的来源:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<property environment="env" />
<property name="appname" value="hellojavaworld" />
<echoproperties />
<exec dir="" executable="respawn.exe" searchpath="true">
<arg value="${basedir}\src\aion\${appname}.app" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
进一步在POM.xml文件中是这样的:
<dependency>
<groupId>hellojavaworld</groupId>
<artifactId>hellojavaworld</artifactId>
<scope>system</scope>
<systemPath>${basedir}\src\aion\hellojavaworld.bin\hellojavaworld.jar</systemPath>
<version>1.0</version>
<optional>true</optional>
</dependency>
如果手动编译hellojavaworld.jar,一切正常,但是如果jar不存在,则会出现错误缺失的工件 .
问题是如何编写POM.xml,在没有手动干预的情况下创建在一个POM.xml文件中用作依赖关系的jar?
谢谢
2 回答
一种解决方案是使用多模块构建 . SonaType书有一个chapter致力于这个主题 .
基本上你需要三个POM文件 .
父母:
hellojavaworld的POM:
图书馆消费者的POM:
你会组织这样的目录结构:
创建一个多模块maven项目:参见Maven的chapter 6示例 . 第一个模块是hellojavaworld,第二个是依赖hellojavaworld的应用程序 .
pom.xml中:
应用程序/ pom.xml的