0

I am new to Maven and I am trying to figure out whether and I can accomplish the following.

My Java project should be available both on a Linux and a Mac machine. I have a number of dependencies which I can find on the maven repository. However, I have a dependency (a jar file) which must be local on both machines.

How can I set up my POM file, and project structure to achieve this?

Update: Part of this information seems to be provided here in this other question: How to add local jar files to a Maven project?. What I still don't understand is whether having the following:

<dependency>
    <groupId>com.sample</groupId>
    <artifactId>sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/Name_Your_JAR.jar</systemPath>
</dependency>

implies that on both machines I need to manually copy the jar file.

k88074
  • 2,042
  • 5
  • 29
  • 43
  • 1
    What do you mean by multiple platforms? Do you have platform dependent code? And what do you means by `which must be local on both machines.`? – khmarbaise Aug 06 '21 at 11:42
  • I vote to close this as a duplicate. But I must say that the only answer I endorse myself is this one: https://stackoverflow.com/a/28762617/424903 – Gimby Aug 06 '21 at 11:45
  • 1
    I don't understand why there should be a local jar. Why can't you load it from a repository or at least a local repository? – J Fabian Meier Aug 06 '21 at 13:32
  • @khmarbaise Let me try: I have the same source code. It needs to be developed both on a Mac and a Linux machine, with git coordinating the efforts. Most dependencies are on maven repository. There is however a jar file which must be used. I suppose this should be on both machines, and I am trying to setup my maven project in the best way to achieve this. – k88074 Aug 06 '21 at 13:50

1 Answers1

0

Use the local repo solution. The system scope is more or less deprecated.

Beside, the local repo solution will be standard and won't enforce the user to have some path/variable: it will only have to register the local repositories in its maven settings.

This will left out the question of how to share the repository:

  • Using a shared folder or archive: you can use the assembly plugin to generate an archive will all dependencies and following the repository tree.
  • You can use the install plugin as shown in other answer to install to a local repository, which you can share using git (not the "best" usage of git).
  • You can use a repository manager such as Sonatype Nexus and the deploy plugin to deploy it (the goals and settings are almost the same as the one found in install plugin).

It really depends on the purpose and scope of your team.

NoDataFound
  • 11,381
  • 33
  • 59