[英]Configuring Maven with YAML - maven-enforcer-plugin to be specific - not working
我的 Maven POM 是 YAML(感谢io.takari.polyglot
),我很难在 YAML 中编写配置,因为该示例有值,但我相信我应该配置maven-enforcer-plugin
的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
但插件抱怨:
[错误] 无法在项目 my-app 上执行目标 org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (enforce-ban-transitive-deps):无法解析 mojo 组织的配置.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.() -> [帮助 1]
这是文档: https : //maven.apache.org/enforcer/enforcer-rules/banTransitiveDependencies.html
并遵循该示例将包含和排除我目前不想做的事情 - 因为一旦我弄清楚了配置,我想设置它来玩!
我也尝试通过https://www.site24x7.com/tools/xml-to-yaml.html放置他们的 XML,但它仍然给出相同的错误。
如果你想尝试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>
根据Ban Transitive Dependencies 文档的规则,它是:
banTransitiveDependencies:
message: ...
而不是:
banTransitiveDependencies:
comment: ...
此规则支持以下参数:
• ...
• ...
• message - 如果规则失败,给用户的可选消息。 将替换生成的报告消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.