我有两个项目,它们是共同父项目的子项目。还有一个生成器项目和生成器对应的maven插件项目。此外,两个子项目都使用相同的输入文件,该文件用于代码生成:
parent: pom
child1: jar
src/main/generator/input.gen
child2: jar
src/main/generator/input.gen
generator: jar
generator-plugin: maven-plugin
生成器插件是一个内部制作的 Maven 插件:
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class GeneratorPlugin extends AbstractMojo {
@Parameter(required = true, readonly = true, defaultValue = "${project}")
private MavenProject project;
@Parameter(required = true, defaultValue = "${project.basedir}/src/main/generator/input.gen")
private File input;
...
}
当前,这个input.gen
重复于 src/main/generator/input.gen
两者 child1
和child2
。这是个问题。我只想拥有 input.gen
的一个版本.
我应该如何构建我的项目以及如何在 <configuration><input>...</input></configuration>
中引用此共享副本对于generator-plugin
两个子项目的 pom 中都有插件吗?
最佳答案
Maven Remote Resources Plugin可能就是您正在寻找的。p>
这是一个example .
关于java - Maven:在项目之间共享源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46133900/