Skip to content

Precompiled script plugin with @file annotation loses package and breaks #34101

@rnett

Description

@rnett

Current Behavior

Kotlin @file: annotations are required to go at the first line of the file. However, when this is done, Gradle fails to detect the package statement, and does not include it in the precompiled script plugin's plugin ID.

Expected Behavior

Adding @file: annotations does not change a script plugin's detected package.

Context (optional)

This is particularly important as the Kotlin plugin has started using @RequiresOptIn declarations and IntelliJ likes to add them to the file by default (at least in scripts).

In my reproducer, this causes plugin application to fail even with the package-less ID because the plugin class (e.g. Bad_plugin_gradle) is generated in the package but BadPluginPlugin is not and does not use the package in the class name. For some reason, in my actual project, importing the plugin using the package-less ID seemed to work.

Self-contained Reproducer Project

wrong-package-reproducer.zip

Gradle version

8.14.2

Build scan URL (optional)

No response

Your Environment (optional)

Windows 11

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions