如果要在Maven之外构建工件,则需要在.pom文件中引用它们。
首先,将
packaging项目的设置为,
pom以便Maven不会尝试编译任何内容。
然后使用
build-helper-maven-plugin将您的工件文件附加到项目。这是一个例子:
<plugin> <groupId>org.prehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>build/xbnjava-0.1.1/download/mylibrary-0.1.1.jar</file> <type>jar</type> </artifact> <artifact> <file>build/xbnjava-0.1.1/download/mylibrary-0.1.1-javadoc.jar</file> <type>jar</type> <classifier>javadoc</classifier> </artifact> <artifact> <file>build/xbnjava-0.1.1/download/mylibrary-0.1.1-sources.jar</file> <type>jar</type> <classifier>sources</classifier> </artifact> </artifacts> </configuration> </execution> </executions> </plugin>
最后,
distributionManagement按照此处的指定,将其添加到您的.pom文件中。
您可以在github上参考我自己的Maven项目设置,该项目的创建是为了在Maven Central上载手动构建的.jar文件。



