I’m trying to configure a jar location/flat repository dynamically.
I have a multi-project build where the task ‘download’ on project ‘get-components’ is responsible for retrieving jars from an internal repository. I cannot control the location to which the jars are downloaded (though I can copy them after they are downloaded). My problem is using the retrieved jars in other projects.
Approach 1: Define the dependencies with
compile files("$JAR_DIR/a.jar")
Defining JAR_DIR in get-components:download is too late; the location checked for a.jar is /a.jar. If JAR_DIR is defined outside of a task in project get-components then this works.
Approach 2: Define the dependencies with
compile name: 'a'
and add the following repository:
repositories {
flatDir {
dirs "$JAR_DIR"
}
}
The dependency is not found if the repository is added in get-components:download. In fact, it inexplicably isn’t even found if the repository is added outside the download task in the get-components project file (though it does work if the repository is added outside tasks in other gradle files).
Approach 3: 1. define the dependencies with
compile name: 'a'
- add the following repository:
repositories {
flatDir {
dirs '/downloaded'
}
}
- copy downloaded jars to /downloaded
Approach 3 works, though I’d rather not need to copy the dependencies after I’ve downloaded them.
Any ideas on how I could get approaches 1 or 2 working?
As an aside, I’ve noticed that adding the flat dir repository greatly increases the dependency resolution time. I assembled my project when all compilation was up-to-date; these are the dependency resolution times I got (from profile report): With flat dir repository: 2m47s With hard-coded path to jars: 9s
I’m using 1.0 milestone 6.