3

Given an artifactory repo with the url:

http://myrepo.myworld.com/my-stuff

that contains a jar immediately at the root of the repo:

http://myrepo.myworld.com/my-stuff/doofus-lib-1.0-SNAPSHOT.jar

no metadata, no pom, no other files except for other versions of the jar, how do I write the repositories settings and the dependencies settings so that the jar is included in the build?

Notes:

  1. This solution needs to be something that will build cleanly from a gradle command-line after the download of the git repo. It has to work in our CI/CD system.

  2. I know that I can download the jar, add it to my git repo, and add a flatDir config to my gradle repositories. I do not want to do this. I don't want to add a large binary file to my git repo.

BalRog
  • 2,796
  • 18
  • 25

2 Answers2

3

I can't test it right now, but you should be able to utilize the functionality for custom Ivy repositories in your setup:

repositories {
    ivy {
        url 'http://myrepo.myworld.com/my-stuff'
        metadataSources {
            artifact()
        }
        patternLayout {
            artifact "[artifact]-[revision].[ext]"
        }
    }
}

The metadataSources closure tells Gradle to just watch for artifacts and to not expect any kind of metadata (like a .pom or a .ivy). The patternLayout closure describes how the artifact path should be formed. This might be dependent on how you define the dependency in your dependencies block later on. The supported placeholders are:

  • organization
  • module
  • revision
  • artifact
  • classifier
  • extension
Lukas Körfer
  • 10,509
  • 6
  • 35
  • 51
  • I actually tried exactly that just before submitting this question and it didn't work. – BalRog May 07 '19 at 18:14
  • Gradle should tell you the URLs it requested to resolve your dependencies. Could you post your `build.gradle` and the Gradle output? – Lukas Körfer May 07 '19 at 23:15
0

You should just be able to drag the jar file into your project from where its located. For example, if you drag it into your workspace it will show in your project folder. From there you can simply hit right click the jar file and select build path. This will include it in the build and set the path.

Triptonix
  • 11
  • 5
  • Should add it in the reference libraries – Triptonix May 06 '19 at 18:56
  • Has to be IDE independent. I need to build it from a command-line in my CI/CD system. – BalRog May 06 '19 at 18:57
  • ... or are you suggesting that I download the jar and include it in my git repo? (yuk) – BalRog May 06 '19 at 19:02
  • Look here https://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file – Triptonix May 06 '19 at 19:09
  • What are your repositories? – Triptonix May 06 '19 at 19:09
  • RE repositories: `http://myrepo.myworld.com/my-stuff`, like I said. :) They're behind a company firewall, so what does it matter what the real URL is? – BalRog May 06 '19 at 19:12
  • RE look here: The jar is remote, in a company artifactory repo, not local. Yes, I could make it local by downloading the jar and adding it to the git repo, but I specifically do not wish to do that. I would like to access the jar, *in situ*, from artifactory, without adding a large binary file to my git repo. – BalRog May 06 '19 at 19:15
  • Thanks, sincerely, for the attempt. Given my original problem statement (without the clarifying notes) your solution would actually be pretty good. It's just not what I'm looking/hoping for. – BalRog May 06 '19 at 19:35