maven enforcer 플러그인을 사용하고 있습니다. 부모님과 자식이 pom.xml
이라면, exclusions
및 inclusions
태그의 요소가 덮어 쓰기보다는 추가됩니다. 나는 이것을 위해 combine.children="append"
을 사용하려고 시도했지만 작동하지만 여분의 configuration
태그로 끝납니다. combine.children
을 잘못 사용하고 있으며 추가로 configuration
태그를 사용하지 않으려면 어떻게해야합니까? 부모 pom.xml
에서Maven 실행자가 자식에 추가됩니다.
: 아래의 예를 참조
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>org.apache.maven</exclude>
<exclude>org.apache.maven:badArtifact</exclude>
<exclude>*:badArtifact</exclude>
</excludes>
<includes>
<!--only 1.0 of badArtifact is allowed-->
<include>org.apache.maven:badArtifact:1.0</include>
</includes>
</bannedDependencies>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
을 아이 pom.xml
에서 :
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<bannedDependencies>
<includes combine.children="append">
<include>org.apache.maven:otherArtifact:2.0</include>
</includes>
</bannedDependencies>
</rules>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
기대 효과 POM :
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>org.apache.maven</exclude>
<exclude>org.apache.maven:badArtifact</exclude>
<exclude>*:badArtifact</exclude>
</excludes>
<includes>
<!--only 1.0 of badArtifact is allowed-->
<include>org.apache.maven:badArtifact:1.0</include>
<include>org.apache.maven:otherArtifact:2.0</include>
</includes>
</bannedDependencies>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
실제 효과 POM :
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>org.apache.maven</exclude>
<exclude>org.apache.maven:badArtifact</exclude>
<exclude>*:badArtifact</exclude>
</excludes>
<includes combine.children="append>
<!--only 1.0 of badArtifact is allowed-->
<include>org.apache.maven:badArtifact:1.0</include>
<include>org.apache.maven:otherArtifact:2.0</include>
</includes>
</bannedDependencies>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
<configuration>
<rules>
<bannedDependencies>
<includes combine.children="append">
<include>org.apache.maven:otherArtifact:2.0</include>
</includes>
</bannedDependencies>
</rules>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
예상됩니다. 상위 POM은 실행''요소를 사용하는 반면 하위 POM은 전역 구성을 사용합니다 (실행 중이 아님). 사실, 당신의'combine.children = "append"는 여기에 아무런 영향을 미치지 않는다고 생각합니다. 동일한 구성 요소를 재정의하지 않습니다. –
Tunaki
필자가 append를 사용하지 않는다면, 유효한 pom은' org.apache.maven : otherArtifact : 2.0 '만을 포함 할 것입니다. 따라서 효과가 있습니다. –
ET13