gradle/gradle · warning

Duplicate entry for plugin '{}': {} is replaced with {}

Error message

Duplicate entry for plugin '{}': {} is replaced with {}

What it means

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.

Source

Thrown at platforms/software/dependency-management/src/main/java/org/gradle/api/internal/catalog/DefaultVersionCatalogBuilder.java:598

        private final String id;

        @Inject
        public DefaultPluginAliasBuilder(DefaultVersionCatalogBuilder owner, String alias, String id) {
            this.owner = owner;
            this.alias = alias;
            this.id = id;
        }

        @Override
        public void version(Action<? super MutableVersionConstraint> versionSpec) {
            MutableVersionConstraint versionBuilder = new DefaultMutableVersionConstraint("");
            versionSpec.execute(versionBuilder);
            owner.aliasesInProgress.remove(alias);
            ImmutableVersionConstraint version = owner.versionConstraintInterner.intern(DefaultImmutableVersionConstraint.of(versionBuilder));
            PluginModel model = new PluginModel(owner.intern(id), null, version, owner.currentContext);
            Supplier<PluginModel> previous = owner.plugins.put(owner.intern(alias), () -> model);
            if (previous != null) {
                LOGGER.warn("Duplicate entry for plugin '{}': {} is replaced with {}", alias, previous.get(), model);
            }
        }

        @Override
        public void version(String version) {
            StrictVersionParser.RichVersion richVersion = owner.strictVersionParser.parse(version);
            version(vc -> {
                configureRequiredRichVersion(vc, richVersion);
            });
        }

        @Override
        public void versionRef(String versionRef) {
            owner.aliasesInProgress.remove(alias);
            owner.createPluginAliasWithVersionRef(alias, id, versionRef);
        }
    }

View on GitHub (pinned to 534f27719b)

Solutions

  1. Remove the duplicate plugin alias declaration, keeping the one with the intended version.
  2. Manage overrides via [versions] and version.ref instead of re-declaring the whole plugin alias.
  3. Verify the applied plugin version after cleanup, because the replacement is silent.

Example fix

// before
plugin("spotless", "com.diffplug.spotless").version { it.require("6.20.0") }
plugin("spotless", "com.diffplug.spotless").version { it.require("6.25.0") } // wins silently
// after
plugin("spotless", "com.diffplug.spotless").version { it.require("6.25.0") }
Defensive patterns

Strategy: validation

Validate before calling

// dedupe check for plugin aliases
val norm = { s: String -> s.replace('-', '.').replace('_', '.') }
val plugins = listOf("spotless", "spot-less")
check(plugins.map(norm).toSet().size == plugins.size) { "duplicate plugin alias after normalization" }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/3aff4d83299cff4a. Report an issue: GitHub.