2

The situation is largely similar as in this SO question except for the resource I'm trying to point to is outside the project folder.

The background is that I have a git repo that contains a few projects. One of the projects requires a jar from another project for running so the intended dependency should be smth like this:

<dependency>
    <groupId>another-proj-jar</groupId>
    <artifactId>another-proj-jar</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>../another-proj/build/another-proj.jar</systemPath>
</dependency> 

another-proj is not a Maven project (and converting it to a Maven proj is an issue of itself, let's skip it here) so I create that jar manually through Eclipse import.

However, I am not sure whether it is possible to indicate a relative path beyond the project directory because all examples point to //${basedir}/my-repo where ${basedir} is essentially the current project folder. I need to make it one level up the current project's folder.

Could you tell me whether it's possible and how or what could be a workaround?

Zoe
  • 27,060
  • 21
  • 118
  • 148
alisa
  • 1,336
  • 2
  • 15
  • 21
  • Never start with things like a system scope dependency ...install the needed file into your repository or better having a repository manager and install it there or use [Stephens Plugin](https://github.com/stephenc/non-maven-jar-maven-plugin) as a step for migration the other build to maven..that will make your life easier... – khmarbaise Aug 01 '17 at 19:26

1 Answers1

2

Really this should just be a normal dependency. In the project you are dependent on (another-proj in your example) run a mvn clean install. This will copy the .jar file to your ~/.m2/repository directory. Then in the project that requires the library have a dependency like:

<dependency>
    <groupId>another-proj-jar</groupId>
    <artifactId>another-proj-jar</artifactId>
    <version>1.0-SNAPSHOT</version>  <!-- or whatever it is set to -->
</dependency> 

The huge advantage with this is that if the jar you're pulling in requires anything else then that'll get pulled in too.

stdunbar
  • 16,263
  • 11
  • 31
  • 53
  • Oh, the other project, e.g. `another-proj`, is not Maven based. I create a jar from it manually... So I'll need to pull all additional stuff manually as well I guess – alisa Aug 01 '17 at 18:55
  • I have kept dependencies outside project folder but don't know how to give path in dependency – Naveen Kumar Feb 13 '20 at 13:02