Organization help!

for anyone interested…

I was not able to do this using the gradle composite build, however I was able to implement this a modified version of the CompositePlugin in this post.

I modified the resolveDependency function to use gradle’s dependencySubstitution as follows:

if (!forceJars && projectPath) {

    Project childProject
    try {
        childProject = project.project(":${projectPath}")
    } catch (UnknownProjectException e) {
        // No local project, use maven repository for dependency resolution. This is not an error condition but an expect
        childProject = null
    }

    if (childProject) {
        project.configurations.each { cfg ->
            cfg.resolutionStrategy.dependencySubstitution {
                substitute it.module(dependencyNotation) with it.project(childProject.path)
            }
        }
        if (log.isTraceEnabled()) {
            childProject.tasks.each { log.trace(it) }
        }
        log.quiet("Found non-jar project dependency: " + childProject)
        project.composite.resolvedProject = true
    }
}

Then you can add another substitutionRule to replace the project with the module:

project.configurations.each { cfg ->
    cfg.resolutionStrategy.dependencySubstitution.all {
        if (it.target instanceof ProjectComponentSelector) {
            it.useTarget it.oldRequested.toString()
        }
    }
}
1 Like