0

如果我在默认配置文件中定义了工具链插件,则它不适用于某些插件,例如 maven-javadoc-plugin(对于 maven-compiler-plugin 它正在工作):

<profile>
    <id>jdk-toolchain</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>${project.javaVersion}</version>
                            <vendor>sun</vendor>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

在其他情况下,它适用于所有插件:

<build>
    <plugins>
...
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-toolchains-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>toolchain</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <toolchains>
                            <jdk>
                                <version>${project.javaVersion}</version>
                                <vendor>sun</vendor>
                            </jdk>
                        </toolchains>
                    </configuration>
                </plugin>
...
    </plugins>
</build>

为什么会这样?

4

1 回答 1

0

您必须将插件的执行绑定到验证阶段:

<executions>
    <execution>
        <phase>validate</phase>
        <goals>
            <goal>toolchain</goal>
            </goals>
    </execution>
</executions>
于 2017-08-02T11:14:38.933 回答