gpt4 book ai didi

java - Maven `help:effective-pom` 只为单个项目生成,而不是所有项目

转载 作者:搜寻专家 更新时间:2023-10-31 19:59:52 27 4
gpt4 key购买 nike

我想为多模块构建中的所有子项目生成一个有效的 pom。

help:effective-pom文档 here

It will iterate over all projects in the current build session, printing the effective POM for each

我在跑 mvn help:effective-pomthis maven project的根目录下并且它只为根而不是为子项目生成。

为什么没有为所有项目生成有效的 pom。注意:我有另一个真实世界的 Maven 项目,其中 mvn help:effective-pom正在正确生成 <projects>带有嵌套 <project> 的标签对于每个子模块。我不确定为什么它不适用于 this maven project

这里是生成的有效pom

<!-- ====================================================================== -->
<!-- -->
<!-- Generated by Maven Help Plugin on 2017-11-12T09:56:26 -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/ -->
<!-- -->
<!-- ====================================================================== -->

<!-- ====================================================================== -->
<!-- -->
<!-- Effective POM for project -->
<!-- 'org.gradle.test.performance:project:pom:1.0' -->
<!-- -->
<!-- ====================================================================== -->

<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>
<groupId>org.gradle.test.performance</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>project0</module>
<module>project1</module>
<module>project2</module>
<module>project3</module>
<module>project4</module>
<module>project5</module>
<module>project6</module>
<module>project7</module>
<module>project8</module>
<module>project9</module>
</modules>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\src\main\java</sourceDirectory>
<scriptSourceDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\src\test\java</testSourceDirectory>
<outputDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target\classes</outputDirectory>
<testOutputDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\src\test\resources</directory>
</testResource>
</testResources>
<directory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target</directory>
<finalName>project-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>C:\code\gradle-maven-transform\example\smallJavaMultiProject\target\site</outputDirectory>
</reporting>
</project>

最佳答案

EffectivePomMojo是聚合器目标。这意味着它只会为您运行它的模块调用。但你是对的,它也应该转储所有子项目。在你的情况下它不这样做的原因是因为这一行:

if ( projects.get( 0 ).equals( project ) && projects.size() > 1 )

在你的例子中,最上面的项目在图中是最后一个(因为没有任何其他模块对它的依赖)。如果您将它作为父项添加到 project0(并且仅针对该模块),那么它会将您的根 pom 放在图中的第一个位置,一切都会按您预期的那样工作。

我无法为这种行为找到理由。因此,如果您在 bugtracker 中提出问题,每个人都会受益 :) 如果/当您得到答案时请更新我们。

PS:如果你知道如何调试Maven插件,这样的问题很容易解决。为此,您可以使用 mvnDebug 而不是 mvn,然后打开插件的源代码并附加到调试 session 。

关于java - Maven `help:effective-pom` 只为单个项目生成,而不是所有项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47254798/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com