Maven 将-f选项带到多模块

Maven 将-f选项带到多模块,maven,maven-2,Maven,Maven 2,maven中有-f选项,允许指定备用pom.xml文件。是否有可能,我也可以将这种行为带到已执行的模块中?现在看来,当我有了这个结构: projectA: pom.xml pom.xml2 projectB: pom.xml pom.xml2 当我使用-f pom.xml2选项将maven作为reactor运行,并将projectB指定为模块时,看起来它从projectA中选择pom.xml2,从projectB中选择pom.xml。有没有办法,如何将-f选项传播到模块? 感谢您的回答。正如J

maven中有
-f
选项,允许指定备用
pom.xml
文件。是否有可能,我也可以将这种行为带到已执行的模块中?现在看来,当我有了这个结构:
projectA: pom.xml pom.xml2
projectB: pom.xml pom.xml2
当我使用
-f pom.xml2
选项将maven作为reactor运行,并将projectB指定为模块时,看起来它从projectA中选择
pom.xml2
,从projectB中选择
pom.xml
。有没有办法,如何将
-f
选项传播到模块?

感谢您的回答。

正如Jörn Horstmann评论的那样,我会尝试很多方法,以便在一个pom中使用配置文件。 如果这是不可能的,我能想到的唯一方法就是通过使用带有配置文件的“切换pom”来绕过正常的maven机制。此pom作为pom.xml放在每个模块中,每个pom.xml2(或其他)都有一个配置文件,在该配置文件中,通过antrun插件执行另一个maven build f.e.,对于您需要的pom,使用-f:

<profile>
            <id>xml2</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>build pom.xml2</id>
                                <phase>prepare-package</phase> <!-- whatever suits you -->
                                <configuration>
                                    <target>
                                                <echo level="info" message="Building pom.xml2..." />
                                                <exec executable="cmd" dir=".">
                                                    <arg value="/c" />
                                                    <arg value="mvn" />
                                                    <arg value="-f" />
                                                    <arg value="pom.xml2" />
                                                    <arg value="install" /> <!-- enter which phase you need -->
                                                </exec>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

xml2
maven antrun插件
构建pom.xml2
准备包装
跑

因为我们可以在模块定义中指定pom文件。 下面是一个在模块中使用替代pom文件的示例

<modules>
    <module>child1/pom-jdk14.xml</module>
    <module>child2/pom-jdk14.xml</module>
</modules>

child1/pom-jdk14.xml
child2/pom-jdk14.xml

您的pom是否不同,以在一个pom中实现为配置文件?活动概要文件将传播到反应器中的所有构建。