I have the following project structure:
RootProject
├── lib
└── src
└── main
└── java
└── ...
├── test-project
└── src
└── main
└── java
└── ...
└── build.gradle
I trying to follow Gradle best practices for multi project builds, and therefore I describing the whole build process in single build.gradle file.
"RootProject" is just a root project without any code and its single purpose is to provide a single build.gradle for its subprojects: "lib" and "test-project".
"test-project" is a SpringBoot project (micro service) using "lib" as compile dependency.
My common build.gradle looks as the following:
plugins{
id 'java'
id 'org.springframework.boot' version '2.1.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}
allprojects {
repositories {
jcenter()
}
}
subprojects {
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
group = 'com.xxx.yyy'
version = '1.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
project(":lib"){
apply plugin: 'java-library'
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
}
bootJar { enabled = false }
jar { enabled = true }
}
project(":test-project"){
apply plugin: 'java'
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation project(":lib")
implementation ('mysql:mysql-connector-java')
}
}
Both "lib" and "test-project" are built successfully. However, when I trying to execute "bootJar" task on root project (which supposed to trigger "build" task on all subprojects) I getting the following error:
Main class name has not been configured and it could not be resolved
Any ideas?