Multi-Git Composite build, not compiling, not cloning, how can I do this?


(Caleb Cushing) #1

So I’m trying to figure out how to do a composite build with multiple git repos, but it seems I can’t even get the composite build working. I’ve put together these repos as a demo

https://bitbucket.org/account/user/xenworks/projects/GCPD

the clone structure is

composite/
    a/
    b/
$ ./gradlew build

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':b:compileJava'.
> Could not resolve all dependencies for configuration ':b:compileClasspath'.
   > project :b:a was not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

what seems to be happening to me is that for some reason it thinks that :a is a sumbodule of :b

settings.gradle

rootProject.name = 'composite'
includeBuild( 'a' )
includeBuild( 'b' ) {
    dependencySubstitution {
        substitute module( 'com.xenoterracide.demo:a:1.0-SNAPSHOT' ) with project( ':a' )
    }
}

composite/build.gradle

plugins {
    id 'com.brightsparklabs.gradle.multi-git' version '1.3.0'
}
multiGitPluginConfig {
    repositoriesDir = new File( '.' )
    repositories = [
            'a': 'git@bitbucket.org:xenworks/a.git',
            'b': 'git@bitbucket.org:xenworks/b.git',
    ]
}
beforeEvaluate( { gitClone } )

group 'com.xenoterracide.demo'
version '1.0-SNAPSHOT'

apply plugin: 'idea'
apply plugin: 'java-library'

compileJava.dependsOn gitClone


build.dependsOn gradle.includedBuild( 'a' ).task( ':build' )
build.dependsOn gradle.includedBuild( 'b' ).task( ':build' )

b/build.gradle

group 'com.xenoterracide.demo'
version '1.0-SNAPSHOT'

apply plugin: 'idea'
apply plugin: 'java-library'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.xenoterracide.demo:a:1.0-SNAPSHOT'
}

i’m also trying to use brightsparklabs mult-git plugin, but I noticed that with the composite build, if the projects aren’t available when I run gradlew gitClone then includeBuild will complain, and thus will not allow me to clone.

How can I get this composite setup working?

update so I did get some help on why this isn’t building on SO. I don’t really understand the answer though when reading the composite docs. I also don’t understand why when I was including build but not doing the calling of the submodule task build, why tests didn’t run (not actually sure what worked).