Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Add the org.springframework.experimental:spring-native dependency automatically when the org.springframework.experimental.aot plugin is applied #545

Closed
wilkinsona opened this issue Mar 2, 2021 · 9 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link

When the org.springframework.experimental.aot plugin is applied, it could automatically add a dependency upon org.springframework.experimental:spring-native to the implementation configuration. This would simplify things a little bit for users and would also remove the need to keep the versions of the plugin and the spring-native dependency in alignment.

@wilkinsona
Copy link
Author

This may complicate things from a start.spring.io perspective. This would be the first entry that's just a plugin when generating a Gradle project.

/cc @snicoll

@snicoll
Copy link
Contributor

snicoll commented Mar 2, 2021

I think that's fine. We can remove the dependency as part of customising the build for Gradle.

@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 3, 2021

I am not sure we should do that, currently both should always be used together, but that's likely to change since the AOT plugin will be usable without spring-native, see #488.

@snicoll
Copy link
Contributor

snicoll commented Mar 3, 2021

When that happens, we can update the plugin to not add the dependency then. What am I missing?

@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 3, 2021

If it is added automatically on Gradle side, we won't be able to use spring-native dependency as a trigger for native related AOT transformations, so I tend to think it should remain explicit (and symmetric between Maven and Gradle).

@wilkinsona
Copy link
Author

If it is added automatically on Gradle side, we won't be able to use spring-native dependency as a trigger for native related AOT transformations

Sorry, I didn't realise that was a requirement. That's a good reason to keep the separate dependency declaration.

and symmetric between Maven and Gradle

We used this as a guiding principle in Spring Boot 1.x and it was one of the biggest mistakes we made. A Gradle plugin that's symmetric with Maven won't be idiomatic and, in our experience at least, will become very difficult to maintain. Not directly related to this issue as there's a good reason to keep the dependency declaration beyond symmetry with Maven, but I thought it worth mentioning as I think it would be mistake to keep the plugins symmetrical purely for the sake of it.

Back to this specific issue, it would still be nice to avoid the need for the dependency to have a version when it should match the version of the plugin. Perhaps the plugin could provide some dependency management or a helper method so the user doesn't need to worry about this?

@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 3, 2021

Thanks for your feedback.

@bclozel Any thoughts?

@bclozel
Copy link
Contributor

bclozel commented Mar 3, 2021

I thought the main driver behind renaming the build tools as "aot" was that we would consider them for the native and for the JDK use cases?

Taking a step back, we really want the developers to express an opinion that says whether we should include native-related AOT or not. Maybe that dependency is not necessarily the best marker we would like here - would a Gradle DSL option work better in this case?

In any case, we can make things easier by configuring the dependency and/or contributing dependency management for it.

@wilkinsona
Copy link
Author

wilkinsona commented Mar 3, 2021

A DSL might be nice. You could do something like this:

springAot {
    native()
}

Or this:

springAot {
     native {
         // Set some native settings here
     }
}

When native has been called, the exact setup – adding a dependency or whatever – becomes an implementation detail.

@bclozel bclozel self-assigned this Mar 3, 2021
@bclozel bclozel added this to the 0.9.0 milestone Mar 3, 2021
@bclozel bclozel closed this as completed in 5a0880d Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement A general enhancement
Development

No branches or pull requests

4 participants