-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Gradle project is created with deprecated features (Project.getConvention) #1423
Conversation
…figuration. Also created a class that provides java version constant. spring-iogh-1420
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for the PR, I've added a comment for your consideration.
@@ -6,7 +6,9 @@ plugins { | |||
|
|||
group = 'com.example' | |||
version = '0.0.1-SNAPSHOT' | |||
sourceCompatibility = '1.8' | |||
java { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an odd place to put this. Now that it isn't an attribute anymore, it should go after the dependencies IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I wouldn't move it. How the information is expressed doesn't change the importance of that information so I'd keep it where it is, although ideally preceded by a blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I guess I am biased with how things work with Maven. It's all good keeping it there and yes with a blank line.
We should consider also #211 as part of this as we could simply remove the code for Kotlin-based projects. |
@@ -118,7 +118,9 @@ void buildDotGradleIsContributedWhenGeneratingGradleProject() { | |||
"", | |||
"group = 'com.example'", | |||
"version = '0.0.1-SNAPSHOT'", | |||
"sourceCompatibility = '11'", | |||
"java {", | |||
" sourceCompatibility = JavaVersion.VERSION_11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer that we continue to use a String for the version as it's more concise and, IMO, it reads better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snicoll @wilkinsona, I read in https://docs.gradle.org/8.2-rc-1/dsl/org.gradle.api.plugins.JavaPluginExtension.html#org.gradle.api.plugins.JavaPluginExtension:sourceCompatibility
that source compatibility is going to be like java version constant. That is why I added it. So should we continue with String for version or add Java version constant ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gradle will perform the Object -> JavaVersion
conversion as it's https://docs.gradle.org/8.2-rc-1/javadoc/org/gradle/api/plugins/JavaPluginExtension.html#setSourceCompatibility-java.lang.Object- that will be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I understand now.
@snicoll @wilkinsona Thanks for the review. I have one question. Currently in Gradle Build Settings I have added source compatibility as this is the only field we used to generate. However many other options are possible for java configuration as mentioned here. Should I also add them or continue with source compatibility ? |
* Class to map common configuration for Java based projects. | ||
* | ||
*/ | ||
public static class JavaConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need this new public API? The change could be implemented by only changing the writers. We could wait to introduce a new API until a need arises to configure more of the options on JavaPluginExtension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree that it's a bit early to introduce a new API for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. I will update the PR accordingly
This reverts commit a74fc42.
…java configuration. Also created a class that provides java version constant. spring-iogh-1420" This reverts commit 1692dad.
This reverts commit 1be85a0.
…zed the test. spring-iogh-1420" This reverts commit 321d1f8.
This reverts commit e0f652a.
…oved getJavaVersionConstant as not required. spring-iogh-1420
@snicoll @wilkinsona Requested changes have been made. I have also made changes for #211. Please review it when possible. |
@prithvitewatia I don't think that works. There is a difference between the Kotlin DSL and Kotlin as a language chosen for the application. We no longer generate a Anyway, I don't like the idea of mixing two changes in the same PR. If you want us to consider this PR, please only focus on changing how the source compatibility is written, and ignoring #211 for now. The changes in the Groovy writer is a bit too invasive as well so hopefully this should simplify it. Let me know if you'd like to review the PR or if you want me to take over. |
Superseded by #1427 |
This PR closes #1420. In this PR gradle build project generation convention is updated to use Java configuration instead of
sourceCompatibility
property as they are deprecated and scheduled for removal in gradle 9.0.Upgrading source compatibility.
As so many test resources files had been updated to validate project generation according, I have tried to make small logical units of commits that may be helpful in reviewing this PR:
commit, I have removed method that used to write source compatibility. Also created a class that will provide java version constant.