Composite build

Hi All,
I have problem with composite build. I fall to issues when I migrate gradle project from 4.5 to 5.0. For demonstrating my problem I create empty project. Project contains two module first is gb2pp and second micu-commands. micu-commands has dependency to gb2pp.

/gb2pp
– setings.gradle
rootProject.name = 'micu-commands'

/gb2pp
– build.gradle

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

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

group = 'cz.netsystem.micu'
version = '0.1.2'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    implementation('org.springframework.boot:spring-boot-starter')
    runtimeOnly('org.springframework.boot:spring-boot-devtools')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

/micu-commands
– settings.gradle

rootProject.name = 'micu-commands'

includeBuild '../gb2pp'

/micu-commands
– build.gradle

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

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

group = 'cz.netsystem.micu'
version = '0.1.2'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    implementation('org.springframework.boot:spring-boot-starter')
    implementation('cz.netsystem.micu:gb2pp')
    runtimeOnly('org.springframework.boot:spring-boot-devtools')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

The code you can find on github repository:

When I try to run application from IntelliJ it’s run without problem, but when I try to build it from command line I get error that package from gb2pp module does not exist.

ERROR:

gradle build

> Task :compileJava FAILED
/home/bliker/Dokumenty/micu/micu/micu-commands/src/main/java/cz/netsystem/micu/micucommands/sche/TestScheduler.java:3: error: package cz.netsystem.micu.gb2pp.domain does not exist
import cz.netsystem.micu.gb2pp.domain.User;
                                     ^
/home/bliker/Dokumenty/micu/micu/micu-commands/src/main/java/cz/netsystem/micu/micucommands/sche/TestScheduler.java:12: error: cannot find symbol
        User user = new User();
        ^
  symbol:   class User
  location: class TestScheduler
/home/bliker/Dokumenty/micu/micu/micu-commands/src/main/java/cz/netsystem/micu/micucommands/sche/TestScheduler.java:12: error: cannot find symbol
        User user = new User();
                        ^
  symbol:   class User
  location: class TestScheduler
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

I will appropriate any help. Can anyone help me please, I’m totally stack.

Thank you,
Martin

Hi all,
I will answer my issue by my self :-), for thouse who can solving same issue.

After more then two days of frustration I finally figured it out.

The problem was based on changing classpath in jar files from version 1.4 of Spring Boot framework. When the gb2pp module was build to jar the micu-command module can’t find the classes in gb2pp.jar file because there were in the bad location. To change the class location i have to add one configuration to gb2pp module

jar {
enable = true
}

I figured it out when I try to changit to maven and find same problem.

These two links help me a lot:

https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/repackage-classifier.html

Martin

1 Like

Thank you so much bro!