我想为多模块构建中的所有子项目生成有效的 pom。
The help:effective-pom
文档here http://maven.apache.org/plugins/maven-help-plugin/usage.html#The_help:effective-pom_Goal states
它将迭代当前构建会话中的所有项目,打印每个项目的有效 POM
我在跑mvn help:effective-pom
在根目录下这个maven项目 https://github.com/uklance/gradle-maven-transform/tree/master/example/maven-root它只为根项目生成,而不为子项目生成。
为什么没有为所有项目生成有效的 pom。注意:我有另一个现实世界的 Maven 项目,其中mvn help:effective-pom
正在正确生成一个<projects>
嵌套标签<project>
对于每个子模块。我不确定为什么它不起作用这个maven项目 https://github.com/uklance/gradle-maven-transform/tree/master/example/maven-root
这是生成的有效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>
The 是一个聚合器目标。这意味着它只会为您运行它的模块调用。但你是对的,它也应该转储所有子项目。在你的情况下它不这样做的原因是因为这一行:
if ( projects.get( 0 ).equals( project ) && projects.size() > 1 )
在您的情况下,最上面的项目位于图中的最后一个(因为任何其他模块都没有对它的依赖)。如果您将其作为父级添加到project0(并且仅适用于该模块),那么它将把您的根pom放在图表中的第一个位置,并且一切都会按您的预期工作。
我无法为这种行为找到理由。因此,如果您在错误跟踪器中提出问题,每个人都会受益:) 如果/当您得到答案时,请更新我们。
PS:如果你知道如何调试Maven插件,这样的问题很容易解决。为此,您可以使用mvnDebug
代替mvn
然后打开插件的源代码并附加到调试会话。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)