Maven:基于配置文件选择父项目 [英] Maven: Selecting Parent Project Based On Profile
问题描述
我有一个Maven项目-它是jenkins的插件.它的父母应该是:
I have a maven project - it is a plugin for jenkins. It's parent should be a:
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.414</version>
</parent>
但是与此同时,此插件也可以用于hudson,而无需更改任何代码行.但是它的父项目应该是:
But at the same time this plugin can be also used for hudson, without changing any line of code. But the parent project for it should be:
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>hudson-plugin-parent</artifactId>
<version>2.0.1</version>
</parent>
我可以为此指定两个不同的配置文件,并使用它们分别为jenkins或hudson构建插件吗?这样我就这样称呼:
Can I specify 2 different profiles for that and use them to build plugin for jenkins or hudson accordingly? So that I call something like that:
mvn package -P jenkins
或
mvn package -P hudson
我尝试在配置文件中指定属性,但是这些属性不会被<parent>
标记内的值替换.那么,是否还有其他为这两者构建插件的可能性,但是要使用尽可能多的通用代码和文件?
I have tried to specify properties in profiles, but those are not replaced by their values inside the <parent>
tag. So is there any other possibility to build plugin for both, but with as much as possible common code and files?
已添加:那么,如果我做不到,那我该怎么办?如何重构?新的结构应该是什么?
Added: So, if I cannot do that, what should I do then? How to refactor? What the new structure should be?
推荐答案
当前,我们决定坚持使用1个存储库和2个单独的pom.xml文件,并提供pom.xml用于构建项目的maven密钥.
Currently we decided to stick with 1 repository and 2 separate pom.xml files, giving maven key which pom.xml use to build the project.
mvn package -f pom-jenkins.xml
mvn package -f pom-hudson.xml
这篇关于Maven:基于配置文件选择父项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!