构建模块在Maven的不同版本的库 [英] Build module with different versions of libs in Maven

查看:402
本文介绍了构建模块在Maven的不同版本的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NetBeans的模块( Module.jar )有很多其声明的依赖的pom.xml

I have a Netbeans' module (Module.jar) with a lot of dependencies declared on its pom.xml:

<groupId>com.company</groupId>
<artifactId>module</artifactId>
<packaging>nbm</packaging>
...
<dependency>
    <groupId>org.netbeans.api</groupId>
    <artifactId>org-netbeans-modules-editor-lib</artifactId>
    <version>${netbeans.version}</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.netbeans.api</groupId>
    <artifactId>org-netbeans-modules-editor-lib2</artifactId>
    <version>${netbeans.version}</version>
</dependency>
...
<properties>
    <netbeans.version>RELEASE701</netbeans.version>
</properties>

正如你所看到的,该版本被声明为变量 netbeans.version

现在我已经使用这个模块有两个NetBeans平台应用程序: ApplicationA 使用NB平台版本6.9.1和 ApplicationB 使用NB平台7.0.1。双方将宣布模块作为一个依赖:

Now I have two Netbeans Platform applications that use this module: ApplicationA uses NB Platform version 6.9.1 and ApplicationB uses NB Platform 7.0.1. Both will declare Module as a dependency:

<dependency>
    <groupId>com.company</groupId>
    <artifactId>module</artifactId>
    <version>3.0.10</version>
</dependency>

模块编译罚款与平台的两个版本,但只会正常运行,如果它是用相同版本的库编译当前应用程序的用途(即模块将只有在编译6.9.1版本,只能在<$ C $正常运行 ApplicationA 正常运行C> ApplicationB 如果编译了7.0.1版本)。

Module compiles fine with both versions of the platform, but will only run properly if it was compiled with the same version of the libs the current application uses (i.e., Module will only run properly on ApplicationA if compiled with version 6.9.1, and will only run properly on ApplicationB if compiled with version 7.0.1).

如何/我在哪里可以定义变量 netbeans.version ,所以模块将正确版本编译根据应用程序,将使用它的库

How/where can I define the variable netbeans.version, so Module will compile with the proper version of the libs according to the application that will use it?

推荐答案

您应该包括NetBeans的直接依赖关系在正确版本ApplicationA和ApplicationB的荧光棒。这样你会得到这个应用程序需要确切版本。

You should include netbeans dependencies directly in poms of ApplicationA and ApplicationB with correct versions. This way you will get exact version this application needs.

这篇关于构建模块在Maven的不同版本的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆