使用 YAML 配置 Maven - 具体来说是 maven-enforcer-plugin - 不工作
Configuring Maven with YAML - maven-enforcer-plugin to be specific - not working
我的 Maven POM 是 YAML(感谢 io.takari.polyglot
),我很难用 YAML 编写配置,因为示例有值,但我相信我应该配置 maven-enforcer-plugin
' s banTransitiveDependencies
规则不接受 includes
或 excludes
.
这是我目前的尝试:
modelVersion: 4.0.0
artifactId: my-app
groupId: com.adam.stuff
version: 3.3.1
packaging: jar
properties:
spring.boot.version: 1.5.10.RELEASE
spring.core.version: 4.3.14.RELEASE
dependencies:
- artifactId: spring-boot-dependencies
groupId: org.springframework.boot
version: ${spring.boot.version}
type: pom
- artifactId: spring-boot-starter-web
groupId: org.springframework.boot
version: ${spring.boot.version}
- artifactId: spring-boot-starter-test
groupId: org.springframework.boot
version: ${spring.boot.version}
- artifactId: spring-context
groupId: org.springframework
version: ${spring.core.version}
- artifactId: spring-web
groupId: org.springframework
version: ${spring.core.version}
build:
plugins:
- artifactId: maven-enforcer-plugin
groupId: org.apache.maven.plugins
version: 3.0.0-M1
executions:
- id: enforce-ban-transitive-deps
goals: [enforce]
configuration:
rules:
banTransitiveDependencies:
comment: "Don't be a dummy"
- artifactId: spring-boot-maven-plugin
groupId: org.springframework.boot
version: ${spring.boot.version}
executions:
- goals: [repackage]
configuration:
fork: true
executable: true
但是插件抱怨:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (enforce-ban-transitive-deps) on project my-app: Unable to parse configuration of mojo org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce for parameter rule: Cannot create instance of interface org.apache.maven.enforcer.rule.api.EnforcerRule: org.apache.maven.enforcer.rule.api.EnforcerRule.() -> [Help 1]
这是文档:https://maven.apache.org/enforcer/enforcer-rules/banTransitiveDependencies.html
按照该示例将包括和排除一些东西,我现在不想这样做 - 因为一旦我弄清楚了配置,我想设置它来玩!
我也试过将他们的XML通过https://www.site24x7.com/tools/xml-to-yaml.html,但它仍然给出同样的错误。
如果你想尝试 pom.yml
然后创建一个名为 .mvn/extensions.xml
的目录和文件并将它放在项目的根目录中(在 pom.xml
旁边)然后开始:
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>io.takari.polyglot</groupId>
<artifactId>polyglot-yaml</artifactId>
<version>0.2.1</version>
</extension>
</extensions>
根据 the rule Ban Transitive Dependencies' doc 是:
banTransitiveDependencies:
message: ...
而不是:
banTransitiveDependencies:
comment: ...
The following parameters are supported by this rule:
• ...
• ...
• message - an optional message to the user if the rule fails. Will replace generated report message.
我的 Maven POM 是 YAML(感谢 io.takari.polyglot
),我很难用 YAML 编写配置,因为示例有值,但我相信我应该配置 maven-enforcer-plugin
' s banTransitiveDependencies
规则不接受 includes
或 excludes
.
这是我目前的尝试:
modelVersion: 4.0.0
artifactId: my-app
groupId: com.adam.stuff
version: 3.3.1
packaging: jar
properties:
spring.boot.version: 1.5.10.RELEASE
spring.core.version: 4.3.14.RELEASE
dependencies:
- artifactId: spring-boot-dependencies
groupId: org.springframework.boot
version: ${spring.boot.version}
type: pom
- artifactId: spring-boot-starter-web
groupId: org.springframework.boot
version: ${spring.boot.version}
- artifactId: spring-boot-starter-test
groupId: org.springframework.boot
version: ${spring.boot.version}
- artifactId: spring-context
groupId: org.springframework
version: ${spring.core.version}
- artifactId: spring-web
groupId: org.springframework
version: ${spring.core.version}
build:
plugins:
- artifactId: maven-enforcer-plugin
groupId: org.apache.maven.plugins
version: 3.0.0-M1
executions:
- id: enforce-ban-transitive-deps
goals: [enforce]
configuration:
rules:
banTransitiveDependencies:
comment: "Don't be a dummy"
- artifactId: spring-boot-maven-plugin
groupId: org.springframework.boot
version: ${spring.boot.version}
executions:
- goals: [repackage]
configuration:
fork: true
executable: true
但是插件抱怨:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (enforce-ban-transitive-deps) on project my-app: Unable to parse configuration of mojo org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce for parameter rule: Cannot create instance of interface org.apache.maven.enforcer.rule.api.EnforcerRule: org.apache.maven.enforcer.rule.api.EnforcerRule.() -> [Help 1]
这是文档:https://maven.apache.org/enforcer/enforcer-rules/banTransitiveDependencies.html
按照该示例将包括和排除一些东西,我现在不想这样做 - 因为一旦我弄清楚了配置,我想设置它来玩!
我也试过将他们的XML通过https://www.site24x7.com/tools/xml-to-yaml.html,但它仍然给出同样的错误。
如果你想尝试 pom.yml
然后创建一个名为 .mvn/extensions.xml
的目录和文件并将它放在项目的根目录中(在 pom.xml
旁边)然后开始:
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>io.takari.polyglot</groupId>
<artifactId>polyglot-yaml</artifactId>
<version>0.2.1</version>
</extension>
</extensions>
根据 the rule Ban Transitive Dependencies' doc 是:
banTransitiveDependencies:
message: ...
而不是:
banTransitiveDependencies:
comment: ...
The following parameters are supported by this rule:
• ...
• ...
• message - an optional message to the user if the rule fails. Will replace generated report message.