Skip to content

Issue with generate task Jte Gradle Plugin in Multi-Module Spring Boot Project #278

@robertellam

Description

@robertellam

Issue Description:

I am encountering an issue with the generate build task using the Jte Gradle Plugin in a multi-module Spring Boot project.

In our project structure, we have a root project called "demo" and two sub-projects named "Application" and "Core." The Application module relies on the Core module. Within the Application Module, we have a template that calls another template located in the Core Module, as demonstrated below:

@template.base(title = "App Template", content = @`<p>App Template extends base</p>`)

During development, this setup works as expected, utilising the ResourceResolver or the CompositeCodeResolver which we came across in another issue. However, issues arise during the build process, leading to the following error:

> base.jte not found (tried to load file at /Users/rob/dev/spring-boot/demo/app/src/main/resources/templates/base.jte), referenced at app.jte:2

base.jte is actually located in Users/rob/dev/spring-boot/demo/core/src/main/resources/templates/base.jte but the generate task only accepts once source directory as far as I am aware?

Question:

Is there a way to configure the Jte Gradle Plugin to function correctly within this multi-module project structure?

Additional Information:

Here is a simplified version of my build.gradle:

buildscript {

    repositories {
        mavenCentral()
        gradlePluginPortal()
    }

    dependencies {
        classpath(libs.spring.boot.gradle.plugin)
        classpath(libs.jte.gradle.plugin)
    }
}

subprojects {

    ...
    apply plugin: 'gg.jte.gradle'
    ...

    jte {
        sourceDirectory = file("${project.projectDir}/src/main/resources/templates").toPath()
        generate()
    }

    ...
}

project(':app') {

    ...

    dependencies {
        api project(':core')
    }
}

project(':core') {

    dependencies {
        api(libs.spring.boot.starter.web)
        api(libs.spring.boot.starter.validation)
        api(libs.spring.boot.starter.security)
        api(libs.spring.boot.starter.data.jpa)
        runtimeOnly(libs.postgresql)
        api(libs.liquibase)
        api(libs.jte)
        api(libs.jte.starter3)
    }
}

Question:

Is it possible for the generate task to resolve templates from multiple sources or modules? Is there anything I can change in my build.gradle to handle this? I think the issue is that the generate task is trying to resolve templates from the source directory of each module independently but it needs to look in multiple directories or modules like it does during development.

Your assistance in resolving this issue is greatly appreciated. Thank you!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions