0

I am distributing a Java package via git for other people to use. I am currently supplying a jar file to go with the source. This way, the user only needs to clone the project once into Intellij IDEA. Projects using the package can then follow this procedure

Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project

to use the package.

This works, but distributing a jar does not feel nice security-wise. On the other hand, this discussion

IntelliJ IDEA - adding .java file to project dependencies

suggests that to use the source code, you need to copy it into your src folder.

Is there a way to distribute source code (java files) only so that if multiple projects use the same package

  1. the package only needs to be downloaded once
  2. the package can be kept up to date with git pull?
jhu
  • 432
  • 2
  • 10

2 Answers2

0

I would really recommend not include jar or any binaries in a Git repo and the best approach to keep these dependencies in a local Nexus repository and use maven or Gradle as your dependency management tool.

Sam
  • 4,046
  • 8
  • 31
  • 47
  • I can explore this option, but it would seem like an overkill for such a simple task. – jhu Sep 25 '20 at 13:13
0

I found a working solution:

  1. Supply an Ant build file with the package. The build file compiles classes and packages them into a jar file. The default target is building the jar, which depends on compiling the classes.
  2. Provide users with instructions on how to set the given Ant build file as a build file in Intellij IDEA and build the default target.
  3. Then instruct them to follow the steps in the first link above to add the jar as a dependency.
jhu
  • 432
  • 2
  • 10