Conditional dependency substitution of war-file

Hello,

I’m trying to get a conditional dependency substitution working with a project that produces a war file.

The basic idea is that for use in a local workspace, I have a root project that contains a whole lot of individual projects as subprojects. The root project applies conditional dependency substitution for all the project that are part of this local workspace using this code:

allprojects {
    configurations.all {
        resolutionStrategy.dependencySubstitution.all { DependencySubstitution dependency ->
            if (dependency.requested instanceof ModuleComponentSelector && dependency.requested.group == "myGroup") {
                def targetProject = findProject(":${dependency.requested.module}")
                if (targetProject != null) {
                    dependency.useTarget targetProject
                }
            }
        }
    }
}

In our CI toolchain, all the projects are built independently using dependencies that are pointing toward our nexus, but in the local workspace, the projects all depend on one another such that a developer can quickly test their changes (there are a lot of interconnections between the code of the different projects, so to change one feature, one often has to change code in multiple projects - it’s definitely not optimal, but this is the only really workable solution for the current state of the projects).

This mechanism works well for projects that produce jar files using the java plugin. However, now I have a new project “projectA” that produces a war file (using the war-plugin) and another project “projectB” that has a dependency on this war file. In projectB i currently declare a dependency like this:

deploy "myGroup:projectA:theVersion:@war"

I can get it to work correctly in the local workspace by replacing this line with

deploy project(path:":projectA", configuration: "archives")

but I don’t want to have to change the build file of projectB for it to work locally. The dependency substitution mechanism above correctly determines that the dependency should be replaced by projectA and does so, but then the build fails saying

Could not resolve all files for configuration ‘:projectB:deploy’.
Could not find projectA.war (project :projectA).

I’m not sure how i can tell the dependency-substitution how to find the war file that is produced by the war task. It seems like everything is already pointing in the right direction and I just need to add something either to the dependency substitution or to the build-file of projectA. But I don’t know what information is missing or how I could add this information.