0

Currently I'm working with a Java back-end server which needs a specific external API: http://repo.ehealth.fgov.be/artifactory/maven2-cache/be/fgov/ehealth/connector/connector-packaging-technical/3.14.2/

The problem I am currently facing is as follows:

I compile the dependency with gradle and gradle can successfully download this API. But, I cannot use the jars in my code. The reason is, the zip contains several other folders like documentation, and the jars are located in the lib folder of the zip. So the only content I need is located in zip.

Currently I compile the dependency like this:

compile(group: 'be.fgov.ehealth.connector', name: 'connector-packaging-technical', version: '3.14.2', classifier: 'java', ext: 'zip')

Is there any possibility to be able to use all the jars in the lib folder?

Iliasvw
  • 11
  • 1
  • 3

2 Answers2

0

Local JAR option

  • First you would make your own lib folder for your project, which would be in the project root directory.
  • Then you would extract the JARs you want to there, so the directory would contain the JARs you want to use.
  • Finally, you add the JAR to gradle like this: source

    dependencies {
      compile files('lib/something_local.jar')
    }
    

Private repo option

Assuming the JARs are not publicly accessible, and assuming the license does not ban this, you could host it on a private repo that only you have access to, so that the dependencies can be shared between projects.

jrtapsell
  • 6,719
  • 1
  • 26
  • 49
  • Is there a possibility to compile all the files in one command? Like a wildcard? I already tried something similar, but when I try to push my server online, it crashes as it can't find the dependencies. – Iliasvw Mar 06 '18 at 20:09
  • I wouldn't advise it, you can use a wildcard in gradle to include the dependencies, and then use something like shadowjar to make a single release jar, manually merging the jars may cause issues if the jars provide services. – jrtapsell Mar 06 '18 at 21:25
0

Honestly, after looking quickly at that public repository, I recommend to not depend on the zip packaging but instead go fetch the jars you explicitly need.

For example, the zip file contains a number of connector-* jar files, and after a quick look these can be found at http://repo.ehealth.fgov.be/artifactory/maven2-cache/be/fgov/ehealth/connector/.

For example, the file lib/connector-utilities-etee-3.14.2.jar can be found and even has a proper maven pom file that indicates the dependencies it requires.

And so already doing:

dependencies {
  compile 'be.fgov.ehealth.connector:connector-utilities-etee:3.14.2'
}

will bring a lot of dependencies in scope for your project.

Note: you should have direct use of transitive dependencies. It is always better in the long run to have these explicitly declared, even when they already appear transitively.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43