Maven:没有要安装的主要工件,而是安装附加的工件 [英] Maven: No primary artifact to install, installing attached artifacts instead
问题描述
我有一个父 Maven POM看起来像这样(可以看到oss-parent 这里):
I have a parent Maven POM that looks like this (the oss-parent can be seen here):
<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>
<parent>
<groupId>com.blockwithme</groupId>
<artifactId>oss-parent</artifactId>
<version>0.0.5</version>
</parent>
<groupId>com.blockwithme</groupId>
<artifactId>xtend-contrib-parent</artifactId>
<version>0.0.3</version>
<packaging>pom</packaging>
<inceptionYear>2013</inceptionYear>
<name>Xtend Contrib Parent</name>
<dependencies>
<dependency>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.lib</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
</plugins>
</build>
<modules>
<module>base</module>
<module>examples</module>
</modules>
</project>
子项基数POM如下所示:
With a child "base" POM that looks like this:
<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>
<parent>
<groupId>com.blockwithme</groupId>
<artifactId>xtend-contrib-parent</artifactId>
<version>0.0.3</version>
</parent>
<artifactId>xtend-contrib-base</artifactId>
</project>
它在本地仓库中创建并安装子Jar。但我也想安装源和/或javadoc。所以我将它添加到父 POM:
It creates and install the child Jar in the local repo. But I would like to install the source and/or javadoc too. So I add this to the parent POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
但如果我这样做,那么源代码和javadoc就会安装,但编译后的代码jar 停止安装,这对我没用。 Maven发出此警告:
But if I do that, the source and javadoc get installed, but the compiled code jar stops being installed, which makes no sense to me. Maven gives this warning:
[INFO] No primary artifact to install, installing attached artifacts instead.
如果我不尝试获取源代码,不会出现安装。添加maven-jar-plugin插件没有帮助。也没有添加< packaging> jar< / packaging>给孩子POM。
Which does not appear, if I do not try to get the source installed. Adding the maven-jar-plugin plugin does not help. Nor does adding "<packaging>jar</packaging>" to the child POM.
推荐答案
您可以尝试从 jar <更改源插件的目标/ code>到
jar-no-fork
。使用 source:jar
目标作为生命周期的一部分,Maven将重新运行绑定到generate-sources及其前身的所有目标。我的假设是在该循环中有一个干净的执行,擦除主jar文件。相比之下, jar-no-fork
将不会再次运行绑定目标。
You could try to change a goal for the source plugin from jar
to jar-no-fork
. With source:jar
goal as part of the lifecycle, Maven will re-run all of the goals bound to generate-sources and its predecessors. My assumption is that there is a clean executed somewhere during that loop, erasing the main jar file. In contrast, jar-no-fork
will not run the bound goals again.
因此插件配置应该看起来像
Plugin configuration should therefore look like
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
这篇关于Maven:没有要安装的主要工件,而是安装附加的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!