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 assignment plugin integration #22240

Merged
merged 22 commits into from Jan 13, 2023

Conversation

asodja
Copy link
Member

@asodja asodja commented Sep 29, 2022

This adds the Kotlin assignment plugin to the Gradle.

Part of #9268.


TODO:

@asodja asodja changed the title Spike for Kotlin assignment plugin integration Spike Kotlin assignment plugin integration Sep 29, 2022
@asodja asodja self-assigned this Sep 29, 2022
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch from cb085ca to e8c8512 Compare September 29, 2022 09:41
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch 6 times, most recently from 746b359 to 47617ac Compare October 17, 2022 14:55
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch 2 times, most recently from 58329b3 to d31f817 Compare October 19, 2022 14:53
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch 2 times, most recently from 00eac71 to 7344c4a Compare November 15, 2022 16:32
@gradle gradle deleted a comment from asodja Nov 15, 2022
@gradle gradle deleted a comment from bot-gradle Nov 15, 2022
@gradle gradle deleted a comment from asodja Nov 29, 2022
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch from 87ca3ad to 3348b46 Compare November 29, 2022 18:07
@gradle gradle deleted a comment from bot-gradle Nov 29, 2022
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch 2 times, most recently from 2c01741 to 46acdf5 Compare December 23, 2022 10:11
@asodja asodja changed the title Spike Kotlin assignment plugin integration Kotlin DSL assignment plugin integration Dec 23, 2022
@gradle gradle deleted a comment from asodja Dec 23, 2022
@gradle gradle deleted a comment from asodja Dec 23, 2022
@gradle gradle deleted a comment from bot-gradle Dec 23, 2022
@gradle gradle deleted a comment from bot-gradle Dec 23, 2022
@asodja asodja added this to the 8.1 RC1 milestone Dec 23, 2022
@asodja asodja requested a review from lptr January 9, 2023 13:49
@@ -73,7 +74,8 @@ import kotlin.script.templates.ScriptTemplateDefinition
"-Xjsr305=strict",
"-XXLanguage:+DisableCompatibilityModeForNewInference",
"-XXLanguage:-TypeEnhancementImprovementsInStrictMode",
]
],
provider = KotlinBuildScriptTemplateAdditionalCompilerArgumentsProvider::class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ I guess there's no way to extract these annotations to a super-class, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to answer this one: I tried it, but it seems it doesn't work with a super-class.

@@ -376,7 +379,7 @@ class CompileKotlinScript(
identityFileInputs: MutableMap<String, CurrentFileCollectionFingerprint>
): UnitOfWork.Identity {
val identityHash = newHasher().let { hasher ->
listOf("templateId", "sourceHash", "compilationClassPath", "accessorsClassPath").forEach {
listOf("assignmentOverloadEnabled", "templateId", "sourceHash", "compilationClassPath", "accessorsClassPath").forEach {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Would be nice to move these strings out into constants to avoid typos.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to constants. Also I see identity hash doesn't contain jvmTarget, I guess we should add it? /cc @eskatos

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be we missed to add it to the identity hash

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be worth extracting this listOf() as a constant close to the declaration of the other constants to avoid missing another property later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the list to constants

* limitations under the License.
*/

@file:Suppress("DEPRECATION")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Why is this necessary? If we need it, let's document why (and for how long).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We implemented deprecated ScriptTemplateAdditionalCompilerArgumentsProvider since there is no good replacement yet. Added a comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

🧐 This should not be a Javadoc comment, but instead //.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch from 799f878 to 16de9c6 Compare January 11, 2023 16:30
@gradle gradle deleted a comment from asodja Jan 11, 2023
Copy link
Member

@lptr lptr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left one small comment, decide if it's worth addressing.

@gradle gradle deleted a comment from asodja Jan 12, 2023
@gradle gradle deleted a comment from asodja Jan 12, 2023
Copy link
Member

@eskatos eskatos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should emit a message saying that Kotlin DSL property assignment is an incubating feature.

About adding more assignment extensions, did you look at what Groovy does for ConfigurableFileCollection and ListProperty & co?

// Kotlin 1.8.0 has wrong warning message for assign plugin,
// replace with 'Assign Kotlin compiler plugin is an experimental feature' once we update to 1.8.20.
// https://github.com/JetBrains/kotlin/commit/0eb34983cb38064684cfc76dacb8d4460fcc6573
"Lombok Kotlin compiler plugin is an experimental feature",
Copy link
Member

@eskatos eskatos Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ We could consider adding both messages already.
When 1.8.20 will be out, early adopters will use it before we get a chance to upgrade.

Copy link
Member Author

@asodja asodja Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I planned to add other extension methods in follow-up PR, but I can do that now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More assignment extensions could go into another PR, me thinks. It was just me being curious and wanting to make sure we don't forget.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to keeping this small and instead creating issues to make sure we don't forget adding more stuff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lptr are you referring to my original comment in this thread about the compiler warning or to the other extension methods subject?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the extension methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional message, also I added incubating message. Message is triggered from assign methods.

@gradle gradle deleted a comment from asodja Jan 12, 2023
@asodja asodja force-pushed the asodja/use-kotlin-assign-plugin branch from 172f1af to be36048 Compare January 12, 2023 16:52
@asodja
Copy link
Member Author

asodja commented Jan 12, 2023

@bot-gradle test this

@gradle gradle deleted a comment from asodja Jan 12, 2023
@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you:

@asodja
Copy link
Member Author

asodja commented Jan 13, 2023

@bot-gradle test and merge

@gradle gradle deleted a comment from asodja Jan 13, 2023
@bot-gradle
Copy link
Collaborator

I've triggered a build for you.

@bot-gradle bot-gradle merged commit 929af47 into master Jan 13, 2023
@bot-gradle bot-gradle deleted the asodja/use-kotlin-assign-plugin branch January 13, 2023 09:37
@eskatos
Copy link
Member

eskatos commented Jan 13, 2023

🎉

bot-gradle added a commit that referenced this pull request Jan 13, 2023
So we can dogfood #22240.

Co-authored-by: Anže Sodja <asodja@gradle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants