I have a multi-module gradle project using proto to generate the DTOs. The root project has two different modules, inventory
, and inventory-api
. The *-api module is the one that has all the .proto
definitions. inventory
has a dependency on inventory-api
Here is the root gradle file
plugins {
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
}
subprojects {
group = 'com.yasinbee.apifirst'
version = '0.0.1-SNAPSHOT'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java-library'
repositories {
jcenter()
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.1.9.RELEASE")
}
}
compileJava {
sourceCompatibility = 11
targetCompatibility = 11
}
}
Here is the inventory gradle file
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
}
dependencies {
implementation project (':inventory-api')
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
implementation "org.springframework.boot:spring-boot-starter-jdbc"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.mapstruct:mapstruct:1.4.0.Final"
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.0.Final'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
And the inventory-api gradle file that has all the proto stuff
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'com.google.protobuf'
dependencies {
implementation 'com.google.protobuf:protobuf-java:3.11.0'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.13'
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.10.1'
}
}
I am able to use the generated proto files within the inventory-api module. However, when I am trying to access the generated files from the inventory module, I am getting a compilation error.
It seems that the generated proto files are not added to the source sets of the inventory
app. How can I add the generated source files of *-api modules into other modules that depends on them?
The issue was resolved by changing the
build.gradle
file forinventory-api
module fromto