Maven:在项目之间共享资源 [英] Maven: share sources between projects
问题描述
我有两个项目是共同父项目的子项目。还有一个发电机项目和相应的发电机maven插件项目。此外,两个子项目都使用相同的输入文件,用于代码生成:
I have two projects which are child of a common parent project. There is also a generator project and a corresponding maven plugin project for the generator. Also, both child projects are using the same input file, which is used for the code generation:
parent: pom
child1: jar
src/main/generator/input.gen
child2: jar
src/main/generator/input.gen
generator: jar
generator-plugin: maven-plugin
生成器插件是一个内部制作的Maven插件:
The generator plugin is an in-house made Maven plugin:
@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;
...
}
Currenlty,这个 input.gen
重复在 src / main / generator / input.gen
两个 child1
和 child2
。这是个问题。我想只有一个版本的 input.gen
。
Currenlty, this input.gen
is duplicated in src/main/generator/input.gen
of both child1
and child2
. This is a problem. I would like to have just one version of input.gen
.
我应该如何构建我的项目以及如何构建我在< configuration>< input> ...< / input>< / configuration>
中为生成器引用此共享副本-plugin
两个子项目的pom中的插件?
How should I structure my projects and how should I refer to this shared copy in <configuration><input>...</input></configuration>
for the generator-plugin
plugin in the pom of the two child projects?
推荐答案
Maven远程资源插件可能正是您所需要的。
The Maven Remote Resources Plugin might be what you're looking for.
这是示例。
这篇关于Maven:在项目之间共享资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!