Roger Glover
Roger Glover

Reputation: 3256

How do I access (in gradle) an artifactory jar dependency that is not in a Maven or Ivy repo directory structure?

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.

Upvotes: 3

Views: 2035

Answers (2)

Lukas Körfer
Lukas Körfer

Reputation: 14493

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

Upvotes: 3

Triptonix
Triptonix

Reputation: 11

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.

Upvotes: 0

Related Questions