0

我有一个项目可能会根据所选配置文件采用不同的来源/资源。有些配置文件是互斥的,有些应该是可组合的,例如,在下面的代码段中定义的配置文件local应该wildfly是可组合的

<profiles>
    <profile>
        <id>local</id>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>add-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>profiles/local/src/main/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                            <execution>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>add-resource</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>profiles/local/src/main/resources</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>

    <profile>
        <id>wildfly</id>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>add-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>profiles/wildfly/src/main/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                            <execution>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>add-resource</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>profiles/wildfly/src/main/resources</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>
</profiles>

如果我在 Eclipse 下执行此操作,我注意到实际上只应用了后者 - 我只看到wildfly配置文件中定义的源/资源。

同样在生成的完整 POM 中,我注意到仅wildfly应用了后者 ( ) 配置文件的配置,因此删除了local配置文件中定义的源和资源。

这是插件应该工作的方式,还是我错过了什么?

4

1 回答 1

0

好的....只有我一个人。

我给处决起了相同的名字,因此它们被覆盖了。我的错。

版主可能会关闭/删除此问题。

于 2017-05-09T10:52:07.620 回答