jscherman
jscherman

Reputation: 6179

Gradle bootRun from parent folder in multi-module project

I have my Gradle project, which has 2 modules: project A and project B, where the latter depends on the former. Note that both projects are Spring Boot applications, so when I execute gradle bootRun from their respectives directories, they will start fine.

The problem is that I want to start, from parent directory, the service of project A when I execute gradle bootRun, and it is starting project B. It seems that I am missing some Gradle config.

build.gradle (project A)

group = 'com.oni'
version = '0.0.2-SNAPSHOT'
sourceCompatibility = 1.8



dependencies {
    compile("org.springframework.boot:spring-boot-starter-data-mongodb")
    compile 'org.javassist:javassist:3.18.2-GA'
    testCompile("de.flapdoodle.embed:de.flapdoodle.embed.mongo")
}

build.gradle (project B)

group = 'com.oni'
version = '0.0.2-SNAPSHOT'
sourceCompatibility = 1.8

dependencies {
    def withoutInflux = { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-mongodb' }

    compile project(':projectA'), withoutInflux
    compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.7'
}

build.gradle(parent)

buildscript {
    ext {
        springBootVersion = '2.0.5.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}


subprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'


    repositories {
        mavenCentral()
//        mavenLocal()
    }


    dependencies {
        implementation('org.springframework.boot:spring-boot-starter')
        testImplementation('org.springframework.boot:spring-boot-starter-test')
        compile('org.springframework.boot:spring-boot-starter-web')
        compile('org.springframework.boot:spring-boot-starter-actuator')
        compile('org.influxdb:influxdb-java')
        compile('org.mockito:mockito-core')
        compile('ma.glasnost.orika:orika-core:1.4.2')
        compile 'com.google.guava:guava-annotations:r03'
    }
}

settings.gradle(parent)

rootProject.name = 'project'


include 'projectA'
include 'projectB'

Thanks in advance.

Upvotes: 4

Views: 3430

Answers (1)

h3adache
h3adache

Reputation: 1386

You can run this by using

./gradlew :projectA:bootRun
./gradlew :projectB:bootRun

Upvotes: 6

Related Questions