chore(gradle): deprecate @nx/gradle/plugin-v1 entry#35610
Conversation
Marks the plugin-v1 subpath export as deprecated and emits a runtime warning on module load. The entry remains functional through Nx 23 and is scheduled for removal in Nx 24, giving users on the legacy non-atomized plugin one major to switch to the default @nx/gradle entry.
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 166ea4e
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
🎓 Learn more about Self-Healing CI on nx.dev
| if (typeof emitPluginWorkerLog === 'function') { | ||
| emitPluginWorkerLog( | ||
| 'warn', | ||
| '`@nx/gradle/plugin-v1` is deprecated and will be removed in Nx 24. ' + | ||
| 'Switch your `nx.json` plugins entry from `@nx/gradle/plugin-v1` to `@nx/gradle`. ' + | ||
| 'Note that the default `@nx/gradle` plugin generates atomized targets — ' + | ||
| 'see https://nx.dev/nx-api/gradle for configuration options.' | ||
| ); | ||
| } |
There was a problem hiding this comment.
The typeof guard will not protect against older Nx versions lacking emitPluginWorkerLog. If the export doesn't exist in @nx/devkit/internal, the import statement at line 1 will throw a module resolution error before reaching the type check. This breaks the stated goal of supporting "@nx/devkit supports nx at +/-1 major" for Nx < 22.7.
Fix: Use dynamic import with try-catch:
try {
const { emitPluginWorkerLog } = await import('@nx/devkit/internal');
if (typeof emitPluginWorkerLog === 'function') {
emitPluginWorkerLog('warn', '...');
}
} catch {
// Gracefully degrade on older Nx versions
}Or conditionally import only when needed and handle the error.
| if (typeof emitPluginWorkerLog === 'function') { | |
| emitPluginWorkerLog( | |
| 'warn', | |
| '`@nx/gradle/plugin-v1` is deprecated and will be removed in Nx 24. ' + | |
| 'Switch your `nx.json` plugins entry from `@nx/gradle/plugin-v1` to `@nx/gradle`. ' + | |
| 'Note that the default `@nx/gradle` plugin generates atomized targets — ' + | |
| 'see https://nx.dev/nx-api/gradle for configuration options.' | |
| ); | |
| } | |
| try { | |
| const { emitPluginWorkerLog } = await import('@nx/devkit/internal'); | |
| if (typeof emitPluginWorkerLog === 'function') { | |
| emitPluginWorkerLog( | |
| 'warn', | |
| '`@nx/gradle/plugin-v1` is deprecated and will be removed in Nx 24. ' + | |
| 'Switch your `nx.json` plugins entry from `@nx/gradle/plugin-v1` to `@nx/gradle`. ' + | |
| 'Note that the default `@nx/gradle` plugin generates atomized targets — ' + | |
| 'see https://nx.dev/nx-api/gradle for configuration options.' | |
| ); | |
| } | |
| } catch { | |
| // Gracefully degrade on older Nx versions that lack emitPluginWorkerLog | |
| } | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
Current Behavior
@nx/gradle/plugin-v1is the legacy non-atomized Gradle plugin entry. In Nx 21, when v2 (the atomized default) became the new@nx/gradle, existing users were migrated toplugin-v1to preserve their behavior. Since then it's been a stable opt-out, with no@deprecatedannotation, no runtime warning, and no docs note signaling it's going away.Expected Behavior
The
@nx/gradle/plugin-v1entry remains fully functional in Nx 23 but emits a clear deprecation warning on plugin load and is annotated@deprecatedon every public symbol. Removal is scheduled for Nx 24, giving users on the legacy non-atomized plugin one major to switch to the default@nx/gradleentry.What changed
packages/gradle/plugin-v1.ts— emits a deprecation warning on module load viaemitPluginWorkerLogso the message surfaces to the user even when the daemon is enabled. Routing it throughlogger.warnwould have been swallowed into the daemon log file.packages/gradle/src/plugin-v1/{nodes,dependencies}.ts—@deprecatedJSDoc on the publiccreateNodesV2/createDependenciesexports.packages/nx/src/devkit-internals.ts+packages/devkit/internal.ts— re-exportemitPluginWorkerLogso@nx/devkit/internalbecomes the canonical path for plugin authors who want a daemon-aware warning channel (instead of deep-importing intonx/src/project-graph/plugins/isolation/).Notes
typeof emitPluginWorkerLog === 'function'to handle the@nx/devkit@23 + nx@22.0–22.6skew (the helper shipped in nx@22.7).@nx/gradle/plugin-v1→@nx/gradleinnx.json) will ship alongside the v24 removal.Related Issue(s)