Hi, a common application pattern is to define a java backend subproject, and an SPA frontend project driven mainly by npm/yarn. The frontend files could be packaged as a webjar and served from the backend as static files.
How should such 2 gradle backend and frontend subprojects be defined and linked to each other cleanly?
Both
- GitHub - coditory/gradle-webjar-plugin-sample: Sample usage of gradle-webjar-plugin
- frontend-gradle-plugin/examples/multi-projects-war-application at master · siouan/frontend-gradle-plugin · GitHub
- GitHub - TheKojuEffect/spring-boot-angular-gradle-multi-project: Spring Boot Angular Gradle Multi Project Configuration
- A Minimalistic Guide to Building and Deploying Monolithic Spring Boot React Applications | by Shekhar Gulati | Xebia Engineering Blog | Medium
- How to integrate output of non-java task to a java project
provide different ways, neither of which seems idiomatic gradle, or anyway I cannot tell which one is clean (with respect to build isolation, incremental builds, etc.)
And when I tried to copy the first, I got:
> No matching variant of project :frontend was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
- Variant 'apiElements' capability kotlin-spring-boot:frontend:unspecified declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 14 and the consumer needed a runtime of a component compatible with Java 11
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
The general pattern is that base subproject A has a task that creates a jar, and java subproject B wants to include that jar in it’s classpath at runtime.
This answer is a start, but not very verbose: Multiproject configurations
I could not find documentation of how to achieve that in the gradle docs.