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

Kotlin DSL should not declare the dependency management plugin #903

Closed
snicoll opened this issue May 17, 2019 · 7 comments
Closed

Kotlin DSL should not declare the dependency management plugin #903

snicoll opened this issue May 17, 2019 · 7 comments

Comments

@snicoll
Copy link
Contributor

snicoll commented May 17, 2019

As of Spring Boot 2, the Spring Boot plugin provides the reference of the dependency management plugin so we should just apply it rather than declaring it with a version.

At the moment, the version is wrong on start.spring.io as the version we declare is for Spring Boot 1.x.

@snicoll snicoll added this to the 0.8.0 milestone May 17, 2019
@wilkinsona
Copy link
Contributor

There's a trade-off to be made here. The current approach allows boms to be imported like this:

plugins {
    //
    id("org.springframework.boot") version "2.1.5.RELEASE"
    id("io.spring.dependency-management") version "1.0.7.RELEASE"
}

dependencyManagement {
    imports {
        mavenBom("example:bom:1.0")
    }
}

If the plugin is applied instead, we lose the need to specify the version but the syntax for importing a bom is more cumbersome:

plugins {
    //
    id("org.springframework.boot") version "2.1.5.RELEASE"
}

apply(plugin = "io.spring.dependency-management")

the<DependencyManagementExtension>().apply {
    imports {
        mavenBom("example:bom:1.0")
    }
}

@sdeleuze
Copy link
Contributor

sdeleuze commented May 20, 2019

I think I understand why the dependency management plugin was just applied (in order to leverage automatically the version bundled with Boot plugin) but with the new plugins syntax the apply(plugin = "io.spring.dependency-management") looks weird from a Gradle user POV, and with Gradle Kotlin DSL it is very important to allow access via the dependencyManagement as pointed out by @wilkinsona, so I would vote for keep using the pluign syntax and fixing the version in a consistent way for both Groovy and Kotlin DSL.

I guess the challenge here is to be able to infer io.spring.dependency-management version from org.springframework.boot, but for Gradle users that would be the best outcome and would be less confusing.

@snicoll
Copy link
Contributor Author

snicoll commented May 20, 2019

I am not keen to have to manage the version of the plugin if that can be inferred by the Spring Boot maven plugin. This is double maintenance on our end with a very easy way of using the wrong version.

@sdeleuze
Copy link
Contributor

sdeleuze commented May 20, 2019

IMO the ideal solution could be to retrieve version of plugins from Spring Boot artifact metadata, that could be used for dependency management plugin, Kotlin, etc. Not sure exactly yet how to do that (compute a cache with that info during build time?) but that would give users idiomatic Gradle build files with explicit non confusing versions defined and would improve maintenance cost.

@snicoll
Copy link
Contributor Author

snicoll commented May 20, 2019

compute a cache with that info during build time?

We can't do that as the version of Spring Boot changes dynamically according to the info in Sagan.

@sdeleuze
Copy link
Contributor

sdeleuze commented May 20, 2019

We can't do that as the version of Spring Boot changes dynamically according to the info in Sagan.

For middle term solution, maybe Initializr could get the info from Sagan and/or Maven central via WebClient and use the awesome caching feature you built to make that fast and reliable?

snicoll added a commit to spring-io/start.spring.io that referenced this issue May 20, 2019
Upgrade the default dependency management plugin version as only the
Kotlin DSL uses it at the moment. Ideally, we should be able to infer
that one way or the other via the version of Spring Boot

See spring-io/initializr#903
@snicoll
Copy link
Contributor Author

snicoll commented Aug 12, 2019

So we've decided to keep the declaration as it is. #977 will take care of retrieving the version from the maven metadata as we already do for Kotlin.

@snicoll snicoll closed this as completed Aug 12, 2019
@snicoll snicoll removed this from the 0.8.0 milestone Aug 12, 2019
davsclaus pushed a commit to davsclaus/start.spring.io that referenced this issue Nov 1, 2019
Upgrade the default dependency management plugin version as only the
Kotlin DSL uses it at the moment. Ideally, we should be able to infer
that one way or the other via the version of Spring Boot

See spring-io/initializr#903
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

3 participants