0

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 the 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 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).

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?

Marcelo
  • 4,580
  • 7
  • 29
  • 46
  • Are you sure it is a matter of compilation or maybe rather the fact your module pulls in different versions of org-netbeans-modules-editor-lib jars for runtime execution? – mrembisz Feb 01 '12 at 12:27
  • Why don't you just compile the module against the lower version and make the netbeans dependency non-transitive or exclude it when adding the module to the project? That way the project would have to define the netbeans version and the module would not add that dependency transitively. – Thomas Feb 01 '12 at 12:31
  • @mrembisz, it could be its loading different versions at runtime - either way, shouldn't the version be specified somewhere so it will always load the right one? Also edited question because some (not all) libs use `runtime`. – Marcelo Feb 01 '12 at 12:34

1 Answers1

1

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.

mrembisz
  • 12,722
  • 7
  • 36
  • 32
  • `Module` uses about 30 dependencies exclusive to it (not related to `AppA` neither `AppB`). Would copying it to both applications' `pom.xml` be a good practice/only solution? I can see how that could quickly become a maintenance disaster. – Marcelo Feb 01 '12 at 12:52
  • @Marcelo You need to copy dependencies only if you want to enforce a particular version. Your problem description suggests ApplicationA indeed depends on 6.9.1 version of netbeans library so it seems natural to define this dependency explicitly. – mrembisz Feb 01 '12 at 13:20