Java maven MultimultiModule中的自定义pom.xml文件名
我有一个maven3多模块项目,出于一个奇怪的原因,我需要为我的一个子模块定制POM文件名(即:module POM.xml) 是否可以在父pom中对此进行配置 奇怪的原因是有点长解释抱歉,但你会有一个简单的背景 上下文Java maven MultimultiModule中的自定义pom.xml文件名,java,maven-2,maven-3,Java,Maven 2,Maven 3,我有一个maven3多模块项目,出于一个奇怪的原因,我需要为我的一个子模块定制POM文件名(即:module POM.xml) 是否可以在父pom中对此进行配置 奇怪的原因是有点长解释抱歉,但你会有一个简单的背景 上下文 lgpl-lib [LGPL Library] lgpl-ext [LGPL Reactor Project] closed-core [Closed source module] closed-spring [Closed source module] closed-web
lgpl-lib [LGPL Library]
lgpl-ext [LGPL Reactor Project]
closed-core [Closed source module]
closed-spring [Closed source module]
closed-web [Closed source module]
closed-webserver [Closed source module]
main-dist [Main assembly module]
pom.xml [Main Reactor POM]
lgpl-api [LGPL API module]
lgpl-plugins [LGPL Plugins module]
lgpl-ext-dist [LGPL assembly module]
main-pom.xml [Main Reactor POM, copy of main pom.xml]
pom.xml [Standalone LGPL Reactor POM]
module-pom.xml [Module LGPL Reactor POM]
- 我正在从事一个封闭源代码项目,该项目也使用LGPLed项目。此项目称为
main
- 我想
声明每个项目的模块,关闭和打开。应使用唯一的main
命令进行完整构建mvn clean package
- 在
reactor项目中,我有main
multimultimodule项目,包含3个lgpl模块(API、插件和分发项目)。一些开发人员将只能访问lgpl reactor
,因此我还希望该项目能够使用lgpl reactor
命令从其文件夹中构建,就像一个完全独立的项目一样mvn clean package
- 我还有一个
项目,它是一个maven汇编插件专用项目(用于构建发行版)main dist
- 如果我向
pom.xml添加父引用,则全局lgpl reactor
构建工作正常,由main
创建的程序集有效,但lgpl reactor的独立构建失败(找不到main pom.xml)main dist
- 如果我从
pom.xml中删除父引用,则独立的lgpl reactor
构建工作正常,但由lgpl reactor
创建的程序集无效(缺失)main dist
- 将另一个POM文件module-POM.xml用于
模块声明列表中的lgpl reactor
模块声明。从main
项目执行完整构建时,main
包含对父POM的引用,并且工作正常module POM.xml
- 将默认POM文件POM.xml用于
的标准构建。此POM很难使用lgpl reactor
标记的
属性引用父POM相对路径
lgpl-lib [LGPL Library]
lgpl-ext [LGPL Reactor Project]
closed-core [Closed source module]
closed-spring [Closed source module]
closed-web [Closed source module]
closed-webserver [Closed source module]
main-dist [Main assembly module]
pom.xml [Main Reactor POM]
lgpl-api [LGPL API module]
lgpl-plugins [LGPL Plugins module]
lgpl-ext-dist [LGPL assembly module]
main-pom.xml [Main Reactor POM, copy of main pom.xml]
pom.xml [Standalone LGPL Reactor POM]
module-pom.xml [Module LGPL Reactor POM]
LGPL反应堆项目目录
lgpl-lib [LGPL Library]
lgpl-ext [LGPL Reactor Project]
closed-core [Closed source module]
closed-spring [Closed source module]
closed-web [Closed source module]
closed-webserver [Closed source module]
main-dist [Main assembly module]
pom.xml [Main Reactor POM]
lgpl-api [LGPL API module]
lgpl-plugins [LGPL Plugins module]
lgpl-ext-dist [LGPL assembly module]
main-pom.xml [Main Reactor POM, copy of main pom.xml]
pom.xml [Standalone LGPL Reactor POM]
module-pom.xml [Module LGPL Reactor POM]
主反应器POM(POM.xml&lgpl Reactor/Main POM.xml)
main dist的assembly.xml
<project>
<parent>
<groupId>main.group</groupId>
<artifactId>main</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>main-dist</artifactId>
<packaging>pom</packaging>
<description>Main Distribution</description>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>plugins-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>closed</groupId>
<artifactId>closed-webserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>closed</groupId>
<artifactId>closed-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>plugins-assembly</id>
<formats>
<format>dir</format>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>../closed-webserver/conf</directory>
<outputDirectory>conf</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<excludes><exclude>main.group:closed-webserver</exclude></excludes>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>main.group:closed-webserver</include>
</includes>
<binaries>
<outputFileNameMapping>${module.artifactId}${dashClassifier?}.${module.extension}</outputFileNameMapping>
<unpack>false</unpack>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>main.group:closed-spring</include>
</includes>
<binaries>
<outputFileNameMapping>${module.artifactId}${dashClassifier?}.${module.extension}</outputFileNameMapping>
<unpack>false</unpack>
<includeDependencies>false</includeDependencies>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>main.group:lgpl-ext-dist</include>
</includes>
<binaries>
<outputDirectory>plugins</outputDirectory>
<unpack>false</unpack>
<includeDependencies>true</includeDependencies>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
插件程序集
迪尔
拉链
假的
../closed-webserver/conf
形态
main.group:关闭的Web服务器
解放党
真的
main.group:关闭的Web服务器
${module.artifactId}${dashClassifier?}.${module.extension}
假的
假的
真的
主阀组:闭式弹簧
${module.artifactId}${dashClassifier?}.${module.extension}
假的
假的
真的
main.group:lgpl ext dist
插件
假的
真的
一个解决方案是应用反向逻辑,并使用“mvn-f standalone-pom.xml clean package”将lgpl reactor作为一个独立的项目来构建……但是如果使用标准的maven2命令行来构建独立的项目会更好。我建议将文件夹结构更改为以下内容
root (pom.xml)
+-- closed-core
+-- closed-web
+-- closed-webserver
+-- closed-spring
+-- lgpl-reactor
+-- lgpl-lib
+-- lgpl-dist
+-- lgpl-etc..
您不需要separte module-pom.xml文件。您可以使用pom.xml作为默认文件
如果您不想构建lgpl reactory,您可以简单地给出:
mvn -pl lgpl-reactory clean package
如果在lgpl的其他模块中存在依赖项,则可以使用:
mvn -am -pl lgpl-reactory clean package
这也将构建所有相关模块。您可以覆盖默认的pom.xml.Maven have-f命令选项
mvn -f <path>/pom.xml clean install
mvn-f/pom.xml干净安装
你不能告诉我们这个奇怪的原因是什么吗?这可能会帮助我们理解你为什么需要这个,然后可能会想出一个解决方案。好的,我已经添加了一些细节…自定义pom路由对你不起作用了吗?在多模块清单中,你可以指定子工件的自定义pom文件名。答案如下这里-问题是根pom.xml不会作为LGPL发布,也不会在LGPL reactor的github存储库中提供……因此,从github克隆LGPL reactor的用户不能这样做来构建项目,他们只有LGPL reactor目录。封闭的代码源位于私有Git存储库中。LGPL reactor目录位于公共目录中GitHub repository。我可以在GitHub repository中以LGPL的形式发布根pom.xml的副本,你是对的。最好是创建一个单独的lgpgl项目,该项目将单独发布,并包含您的封闭源代码部分。你没有问题。是的,我想我会选择此解决方案,但在eclipse环境中不太方便但maven似乎并没有被设计为在同一个项目中为不同的部件/许可证拥有不同的存储库。(我想象maven的其他问题:例如,发布插件,它不能在两个不同的存储库中正常工作…)在Eclipse中,您可以将这两个项目放到Eclipse中,并打开工作区解析(据我所知,这是默认的)。