-
Notifications
You must be signed in to change notification settings - Fork 5k
Let version catalog be usable in Kotlin DSL plugins {}
block with IDE support
#23639
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
Merged
bot-gradle
merged 14 commits into
master
from
eskatos/kotlin-dsl/version-catalogs-plugins-block/ii
Feb 7, 2023
Merged
Let version catalog be usable in Kotlin DSL plugins {}
block with IDE support
#23639
bot-gradle
merged 14 commits into
master
from
eskatos/kotlin-dsl/version-catalogs-plugins-block/ii
Feb 7, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
698f8a4
to
71b2412
Compare
…s and plugin {} only standalone scripts This was the only script templates where the standalone one was reused by precompiled script support. Further changes will require a different implementation. Separating this will make things easier to understand.
… {}` work properly Before this commit, access to version catalogs from `buildscript {}` and `plugins {}` was working by accident. The version catalog extensions were added as "provided properties" to the kts script templates for compilation. There is no IDE editor support for this. When editing such a script the IDE showed red squiggles under the catalog access. It still found references because of the project extensions for version catalogs but their access was forbidden due to `PluginDependenciesSpecScope` having `@DslMarker`. After this commit, new accessors for version catalogs are generated to be available in `buildscript {}` and `plugins {}` and provided to the IDE. The old way using "provided properties" has been removed. Generated accessors expose the already existing project extensions for version catalogs. This is done by having `ScriptHandlerScope` (for `buildscript {}`) and `PluginDependenciesSpecScope` (for `plugins {}`) have an internal protocol that exposes access to the script target's version catalog extensions. This required moving the internal `ExternaModuleDependencyFactory` interface from `:dependency-management` up into `:core`. A new instruction was added to the `ResidualProgram` in kts script compilation to represent `buildscript {}` is a top-level script that targets `Project`. Version catalog accessors generation was coupled with plugin spec builders generation as they have the same scope. Once the `buildSrc` classloader scope is closed, it contains existing Java accessors to version catalogs and the version catalog extensions have already been added to the project instances. The `PartialEvaluator` was enhanced to distinguish `buildscript {}` blocks for `Project` in top-level projects where the version catalog accessors need to be available. Standaline KTS script compilation already generates plugin spec builders always so no more complexity was added to the `Interpreter`. If we consider computing these accessors only when necessary we can add the complexity of decoupling version catalog accessors generation from plugin spec builders generation.
Now that it encompass both version catalog accessors (available in both `buildscript` and `plugins` blocks) and plugin spec builders accessors available in `plugins` blocks. Also reorganize the Stage1BlocksAccessorClassPath.kt file to group members by responsibility
moving version catalog accessors generation to its own file moving plugin spec accessors generation to its own file keeping common code in the Stage1BlocksAccessorClassPath.kt file
It was either `scriptDefinition` or `scriptDef` in the file. This commit make all such variables named `scriptDefinition` in this file. For readability.
…m kts plugins block This is not expected but currently works.
by moving repeated comment to the top and indenting settings script source in each test
by fixing some formating by making a method static by fixing some variable names
… plugins blocks Doing this required generating new factory classes for version catalogs to hold the `@Deprecated` annotations and emit the actual deprecation warning. The classpath used to compile and load the generated code for version catalogs was amended with the :logging module in order to be able to use the DeprecationLogger. The new generated classes are produced alongside the regular version catalog factories, in the same unit-of-work with the same build-cache key. They are also classloaded the same way with the same build-tree scope caching mechanism. The version catalog factory instances for plugins blocks have the same lifecycle as the regular ones registered as project extensions.
71b2412
to
42848f6
Compare
hythloda
approved these changes
Jan 30, 2023
hythloda
reviewed
Jan 30, 2023
...t/groovy/org/gradle/integtests/resolve/catalog/CatalogPluginsKotlinDSLIntegrationTest.groovy
Outdated
Show resolved
Hide resolved
@bot-gradle test RFN |
I've triggered the following builds for you: |
jbartok
approved these changes
Feb 3, 2023
@bot-gradle test and merge |
I've triggered a build for you. |
This was referenced Feb 8, 2023
Closed
bot-gradle
added a commit
that referenced
this pull request
Feb 8, 2023
…logs in KTS `plugins {}` in upgrade guide This is a follow up to * #22797 * #23639 Co-authored-by: Paul Merlin <[email protected]>
This was referenced Mar 16, 2023
bot-gradle
added a commit
that referenced
this pull request
Mar 22, 2023
…in `buildscript {}` block of applied KTS scripts * Follow up to #23639 * Fixes #24426 Co-authored-by: Paul Merlin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
buildscript {}
andplugins {}
blocksbundles
). Onlyplugins
andversions
are allowed.See individual commits for details
No more red squiggles and deprecated usages are reported as such in the IDE