Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you provide a Spring Boot + Kotlin sample? #19

Closed
ghost opened this issue May 6, 2024 · 4 comments
Closed

Can you provide a Spring Boot + Kotlin sample? #19

ghost opened this issue May 6, 2024 · 4 comments

Comments

@ghost
Copy link

ghost commented May 6, 2024

I am trying to setup it by myself and keep getting the The Kotlin Gradle plugin was loaded multiple times message.

@jjohannes
Copy link
Owner

jjohannes commented May 14, 2024

Hi @patrick-at-ifood. To understand this error one hast to understand that Gradle can load different sets of plugins for each (sub)project. However, some plugins – like the Kotlin Gradle plugin – cannot deal with this and give such errors. To avoid this, we have to "force" Gradle to load the same plugins for all (sub)projects.

The current setup of this project may cause this, because the plugins are split up into multiple "plugin projects". From each of this projects, a Jar is created (containing all the plugins of the corresponding project). The Jars are only loaded by a project, if a plugin from the Jars is used (a lot of Gradle magic).

current structure

└── gradle
    └── plugins
        ├── base-plugins
        ├── build.gradle.kts
        ├── dependency-analysis-plugins
        ├── dependency-rules-plugins
        ├── java-application-plugins
        ├── java-base-plugins
        └── java-library-plugins

I plan to change the setup of this project, to only have one plugins project. Issues like this and my own experience in multiple projects showed, to me, that this splitup has mostly disadvantages. (Note: we discussed this topic here.)

new structure

└── gradle
    └── plugins
        └── build.gradle.kts <-- only one "build.gradle.kts" for all plugins!

All external plugins should then be in the dependencies block of that one build.gradle.kts.

dependencies {
    implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.30.0")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
    implementation("org.springframework.boot:spring-boot-gradle-plugin:2.7.18")
}

Would that change be possible in you case and does it solve the issue for you?

@ghost
Copy link
Author

ghost commented Jun 6, 2024

I believe that might work just fine, looks to me that it even makes things easier.
Right now I can spend much time on it but I'll return when it's done.

@jjohannes
Copy link
Owner

👍 It's still work in progress, but I have started work on updating this project and have a branch that follows the setup I was talking about: https://github.com/jjohannes/gradle-project-setup-howto/tree/next_iteration/

@jjohannes
Copy link
Owner

The new setup is now on main and the Readme has been updated.

With this structure, I combined the kotlin and spring_boot branch, and it seems to work fine:
https://github.com/jjohannes/gradle-project-setup-howto/tree/kotlin%2Bspring_boot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant