Hi,
I have a set up that looks roughly like this:
project_1
--> module_1:version_1
--> module_1:version_2
--> module_2:version_1
project_2
--> module_3:version_1
--> module_3:version_3
--> module_4:version_1
--> module_4:version_5
(you can assume that all modules have different names)
I need to be able to build each module (a "project" is just a collection of
"modules" and doesn't need to be built). Now if module_X depends on
module_Y:version_Z, then I need to do the following:
-- If module_Y:version_Z is checked out locally, then I need to build
module_Y:version_Z and add all artifacts it produces to the dependency list
of module_X
-- If module_X is not checked out, then I need to fetch module_X-Z.jar (and
its dependencies) from our artifact repository (I have already set up gradle
to fetch all artifacts from this repository)
So the relevant parts of my build.gradle look like this:
configurations {
internalDependency
}
dependencies {
compile group: 'X', name: 'Y', version: 'Z'
internalDependency group: 'A', name: 'B', version: 'C'
}
def isCheckedOutLocally(dep) {
// Checks if the project is checked out locally
// I know how to implement this function
}
def buildModule(dep) {
// Builds this module and adds all artifacts it produces to the list of
dependencies for this module
// DON'T KNOW HOW TO IMPLEMENT THIS
}
def addRepoDependency(dep) {
// Adds a dependency on a repository artifact to this module
// DON'T KNOW HOW TO IMPLEMENT THIS
// Cannot do
// dependencies { compile group: dep.group, name: dep.name, version:
dep.version }
// at this point in the build process
}
def resolveInternalDependencies() {
for (dep in configurations.internalDependency.dependencies) {
if (isCheckedOutLocally(dep)) {
buildModule(dep)
} else {
addRepoDependency(dep)
}
}
}
compileJava {
// have to use doFirst instead of dependsOn because gradle thinks this
task is always up-to-date
doFirst {
resolveInternalDependencies()
}
}
So my question is: how can I implement buildModule() and
addRepoDependency()?
A few alternatives that I looked into:
1. Custom dependency resolver: when dependencies are resolved, all
"standard" dependencies are resolved as expected, but when a
"internalDependency" is encountered, the custom resolver either fetches it
from our repo, or builds the dependency and fetches all artifacts it
produces. Problems: couldn't find any doc/example on how to install a custom
dependency resolver.
2. Multi-project build: I need to be able to add subprojects dynamically,
and I couldn't find any doc that explains how to do that (or even if it is
possible).
Any help would be greatly appreciated.
Thanks!
--
View this message in context:
http://gradle.1045684.n5.nabble.com/Multi-project-build-dynamically-add-subprojects-dependencies-tp4824341p4824341.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email