1

The problem: My software uses a library that every developer (and user) has installed in a different location.

The following works in pom.xml:

<project ...>
    ...
    <dependencies>
        <dependency>
            <groupId>myGroup</groupId>
            <artifactId>myName</artifactId>
            <version>1.2.3</version>
            <scope>system</scope>
            <systemPath>C:\...\....jar</systemPath>
        </dependency>
    </dependencies>
</project>

But when I check this into source control, every developer who needs to change it, has to change the pom.xml, thus having to ignore it at every commit afterwards or to commit partially if he has to change anything else in the pom.xml, such as adding another dependency.

  1. Using a property does not help, it just moves the problem to another location inside the pom.xml.

  2. Using a property and reading it from an external file (properties-maven-plugin) seems not to work since the plugin is called after the dependency checks of e.g. Eclipse: Dynamically adding a Maven dependency from a property

  3. Using environment variables ${env.MY_VARIABLE} seems not to work either: [ERROR] 'dependencies.dependency.systemPath' for myGroup:myName:jar must specify an absolute path but is ${env.MY_VARIABLE} @line 123, column 45

Any ideas on how to solve that?

Community
  • 1
  • 1
Bowi
  • 1,124
  • 12
  • 26
  • You're going in the wrong direction. `system` is something you should very probably not use, and will be removed some day. Refer to http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them for a proper approach. – Tunaki Dec 07 '16 at 12:54
  • It is not my jar, so I cannot distribute it with my application. The jar is heavily protected, so I cannot add it to local repositories, process it or even move it around -- it has to sit where it has been installed by the person in front of the keyboard. I do not see any way how to solve that without the `system`. Or is there any at your linked page I didn't get? – Bowi Dec 07 '16 at 13:07
  • *The jar is heavily protected, so I cannot add it to local repositories* Why not? There are probably thousands of JARs in your local repo right now that are not yours and were downloaded from other Maven repo. This particular one isn't available on remote repositories, but that doesn't mean you can't install it. – Tunaki Dec 07 '16 at 13:11
  • I *could* add it to a local repository, but even if that would work together with the encryption/obfuscation/xyz included, that would only solve the problem for me. Everybody else checking out my project from VCS would have to do the same steps -- and they would have to be done every time the third-party jar gets updated, which it does frequently. – Bowi Dec 07 '16 at 13:17
  • Then you need to start looking into a repository manager, like Artifactory or Nexus. You can host the JAR there, and every developer will download it from there without issues. The fact that it is encrypted is not relevant, it's just a JAR like any other. – Tunaki Dec 07 '16 at 13:26
  • There, the *It is not my jar* comes to place: Every person needing it for work has to get a license and to install it. I am simply not allowed to "redistribute" it, even internally only. – Bowi Dec 07 '16 at 13:31

2 Answers2

0

I would use a repoistory for my jars. Something like nexus or artifactory.

Tobias Otto
  • 1,512
  • 10
  • 18
  • (Copied from my reply to @Tunaki's comment) It is not my jar, so I cannot distribute it with my application. The jar is heavily protected, so I cannot add it to local repositories, process it or even move it around -- it has to sit where it has been installed by the person in front of the keyboard. – Bowi Dec 07 '16 at 13:08
0

this option works for me:

3. Using environment variables ${env.MY_VARIABLE} seems not to work either: [ERROR] 'dependencies.dependency.systemPath' for myGroup:myName:jar must specify an absolute path but is ${env.MY_VARIABLE} @line 123, column 45

you have to put the jar name included in the path, for example, ${env.MY_VARIABLE/my_jar.jar}. Also make sure that MY_VARIABLE exists in your environment. at the end execute the mvn clean and mvn compile commands

Miguel Veces
  • 135
  • 1
  • 7