我有一个多模块(聚合器)Maven项目,它也从父pom继承属性.所以在我的父pom.xml中我有这个:
<groupId>com.something.project</groupId>
<artifactId>MyProject</artifactId>
<packaging>pom</packaging>
<version>1.0.123</version>
<modules>
<module>ModuleA</module>
<module>ModuleB</module>
<module>ModuleC</module>
</modules>
Run Code Online (Sandbox Code Playgroud)
我想让所有子模块继承父版本号1.0.123,但是孩子pom.xml要求我继续硬编码父版本号(ModuleA pom.xml示例):
<artifactId>ModuleA</artifactId>
<name>Some Amazing Thing</name>
<parent>
<relativePath>../</relativePath>
<artifactId>MyProject</artifactId>
<version>1.0.123</version>
<groupId>com.something.project</groupId>
</parent>
Run Code Online (Sandbox Code Playgroud)
我怎样才能将版本号放在父pom中,让模块继承它而不必在多个地方更新它?到目前为止,我已经尝试了$ {project.version}和$ {project.parent.version},Maven似乎对此非常不满意.我也不能完全删除版本参考.
有没有人对此有一个好的答案?
我正在尝试基于现有的(2.0)插件创建一个新的maven(3.0.3)插件,并促进以太来拾取一些依赖.
我尝试使用maven-plugin-testing-harness(版本2.0.1)创建一个简单的测试来加载mojo,但lookupMojo失败并带有guice异常:
1) Error injecting: org.sonatype.aether.impl.internal.DefaultRepositorySystem
at ClassRealm[plexus.core, parent: null]
at ClassRealm[plexus.core, parent: null]
while locating org.sonatype.aether.RepositorySystem
while locating org.codehaus.griffon.maven.plugin.MvnValidateMojo
at ClassRealm[plexus.core, parent: null]
while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.codehaus.griffon:griffon-maven-plugin:1.3.0-SNAPSHOT:validate)
Run Code Online (Sandbox Code Playgroud)
这当然是因为我需要在某个时候引用存储库系统,但现在不是:
@Component
private RepositorySystem repoSystem;
Run Code Online (Sandbox Code Playgroud)
我已经尝试过(实际上已经开始)版本2.1,但是在AbstractMojoTestCase #setUp()方法中遇到了问题.
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.repository.RepositorySystem
roleHint:
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:247)
Run Code Online (Sandbox Code Playgroud)
无论哪种方式,不确定我需要包括什么以及在哪里进行类似于食谱的香草mojo负载测试.有人有任何想法吗?