{"record":{"id":"3aff4d83299cff4a","repo":"gradle/gradle","slug":"duplicate-entry-for-plugin-is-replaced-wi","errorCode":null,"errorMessage":"Duplicate entry for plugin '{}': {} is replaced with {}","messagePattern":"Duplicate entry for plugin '(.+?)': (.+?) is replaced with (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platforms/software/dependency-management/src/main/java/org/gradle/api/internal/catalog/DefaultVersionCatalogBuilder.java","lineNumber":598,"sourceCode":"        private final String id;\n\n        @Inject\n        public DefaultPluginAliasBuilder(DefaultVersionCatalogBuilder owner, String alias, String id) {\n            this.owner = owner;\n            this.alias = alias;\n            this.id = id;\n        }\n\n        @Override\n        public void version(Action<? super MutableVersionConstraint> versionSpec) {\n            MutableVersionConstraint versionBuilder = new DefaultMutableVersionConstraint(\"\");\n            versionSpec.execute(versionBuilder);\n            owner.aliasesInProgress.remove(alias);\n            ImmutableVersionConstraint version = owner.versionConstraintInterner.intern(DefaultImmutableVersionConstraint.of(versionBuilder));\n            PluginModel model = new PluginModel(owner.intern(id), null, version, owner.currentContext);\n            Supplier<PluginModel> previous = owner.plugins.put(owner.intern(alias), () -> model);\n            if (previous != null) {\n                LOGGER.warn(\"Duplicate entry for plugin '{}': {} is replaced with {}\", alias, previous.get(), model);\n            }\n        }\n\n        @Override\n        public void version(String version) {\n            StrictVersionParser.RichVersion richVersion = owner.strictVersionParser.parse(version);\n            version(vc -> {\n                configureRequiredRichVersion(vc, richVersion);\n            });\n        }\n\n        @Override\n        public void versionRef(String versionRef) {\n            owner.aliasesInProgress.remove(alias);\n            owner.createPluginAliasWithVersionRef(alias, id, versionRef);\n        }\n    }\n","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/catalog/DefaultVersionCatalogBuilder.java#L580-L616","documentation":"The plugin alias builder's version(Action) method builds a PluginModel and puts it into the plugins map under the normalized alias. If a previous supplier exists, this warning is logged and the newer plugin model replaces the older. Effectively the last plugin declaration with a version block wins.","triggerScenarios":"Declaring plugin(\"foo\", \"com.example.foo\") { version { ... } } twice in a versionCatalogs block; same plugin alias defined in TOML and re-declared programmatically; aliases normalizing to the same key.","commonSituations":"Overriding a plugin version from code while the TOML still declares it; merging catalogs during a monorepo consolidation; copy-paste of plugin blocks between projects.","solutions":["Remove the duplicate plugin alias declaration, keeping the one with the intended version.","Manage overrides via [versions] and version.ref instead of re-declaring the whole plugin alias.","Verify the applied plugin version after cleanup, because the replacement is silent."],"exampleFix":"// before\nplugin(\"spotless\", \"com.diffplug.spotless\").version { it.require(\"6.20.0\") }\nplugin(\"spotless\", \"com.diffplug.spotless\").version { it.require(\"6.25.0\") } // wins silently\n// after\nplugin(\"spotless\", \"com.diffplug.spotless\").version { it.require(\"6.25.0\") }","handlingStrategy":"validation","validationCode":"// dedupe check for plugin aliases\nval norm = { s: String -> s.replace('-', '.').replace('_', '.') }\nval plugins = listOf(\"spotless\", \"spot-less\")\ncheck(plugins.map(norm).toSet().size == plugins.size) { \"duplicate plugin alias after normalization\" }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare each plugin alias exactly once, ideally only in [plugins] of the TOML.","Manage version changes through [versions] + version.ref rather than re-declaring the plugin.","When merging catalogs, prefix third-party plugin aliases (e.g. 'vendor-xyz') to avoid collisions."],"tags":["version-catalog","plugin","duplicate","last-write-wins"],"backgroundTag":"duplicate-version-catalog-entry","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}