我有三个生成库JAR文件的Maven项目(A,B和C)。 C取决于B,B取决于A.项目A和B是具有一些必需配置文件(XML / XSD文件)的jar,当我使用Project C(库jar)时必须存在这些文件。可执行项目D明确依赖于项目C.当运行D时,项目A,B和C所需的任何配置文件必须存在于特定目录中。
D
|runtime
v
C ----- compile -----> B ----- compile -----> A
| |runtime |
|runtime v |runtime
+----------> /spec-dir/*.xml|*.xsd <----------+
^
|
+------+-----+
| extract at |
| C's build |
A.tar.gz B.tar.gz
背景:我目前正在使用maven-assembly-plugin
捆绑A和B的配置文件,并将其作为tar.gz
程序集附加到工件A和B,如下所示:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>config</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/config</directory>
<outputDirectory>config/</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
理想情况下,我只想在C&#39 {s} pom
文件中定义对B的依赖关系(无需向A和B&#39; config&#39;分类器添加显式依赖关系)
问题1:
在构建项目C时,是否可以在开发环境中自动从A和B的tar.gz
中将配置文件提取到输出目录?请注意,如果这些文件已经存在,我会 NOT 想要覆盖它们(而是使用已经存在的XML / XSD文件)。我可以通过向项目C maven-dependency-plugin:unpack
文件添加pom
来明确解压缩,但我不愿意,因为项目B实际上将包含在其他50个项目中:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifact>GROUP_ID:PROJECT_B:VERSION:tar.gz:config</artifact>
<outputDirectory>${env.CONFIG_DIR}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
问题2:
在部署环境中,如何将项目A,B和C的配置文件聚合到一个&#39; staging&#39;然后可以将它们捆绑安装的区域?同样,我不想明确地&#34;解包&#34;每个依赖于&#39; config&#39;分类