Maven:在项目之间共享资源(Maven: share sources between projects)

编程入门 行业动态 更新时间:2024-10-26 11:23:04
Maven:在项目之间共享资源(Maven: share sources between projects)

我有两个项目是一个共同的父项目的孩子。 还有一个发电机项目和相应的发电机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; ...

}

Currenlty,这个input.gen在src/main/generator/input.gen和src/main/generator/input.gen的src/main/generator/input.gen中重复。 这是个问题。 我想只有一个版本的input.gen 。

我应该如何构建我的项目以及如何在<configuration><input>...</input></configuration>为两个子项目的pom中的generator-plugin插件引用此共享副本?

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

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, 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.

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.

Here is an example.

更多推荐

本文发布于:2023-08-01 18:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363792.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:共享资源   项目   Maven   projects   sources

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!