Create a module with different versions of libs in Maven

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> 

As you can see, the version is declared as a variable netbeans.version .

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> 

Module compiled in both versions of the platform, but will only work if it has been compiled with the same version of libs that the current application is using (i.e. Module will only work correctly on ApplicationA if compiled with version 6.9.1, and will only work on ApplicationB if compiled with version 7.0.1).

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

0
source share
1 answer

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

+1
source

Source: https://habr.com/ru/post/1392876/


All Articles