gradle/gradle · error · GradleException
Duplicate configuration for repository '<name>'.
Error message
Duplicate configuration for repository '<name>'.
What it means
DefaultJavaToolchainRepositoryHandler.configureRepository creates the repository and adds it to a Set; DefaultJavaToolchainRepository equality is keyed by name, so repositories.add returning false means a repository with that name was already configured, and the duplicate declaration throws GradleException 'Duplicate configuration for repository <name>'.
Source
Thrown at platforms/jvm/toolchains-jvm/src/main/java/org/gradle/jvm/toolchain/internal/DefaultJavaToolchainRepositoryHandler.java:102
}
}
@Override
public void repository(String name, Action<? super JavaToolchainRepository> configureAction) {
assertMutable();
DefaultAuthenticationContainer authenticationContainer = new DefaultAuthenticationContainer(instantiator, CollectionCallbackActionDecorator.NOOP);
for (Map.Entry<Class<Authentication>, Class<? extends Authentication>> e : authenticationSchemeRegistry.getRegisteredSchemes().entrySet()) {
authenticationContainer.registerBinding(e.getKey(), e.getValue());
}
AuthenticationSupporter authenticationSupporter = new AuthenticationSupporter(instantiator, objectFactory, authenticationContainer, providerFactory);
DefaultJavaToolchainRepository repository = objectFactory.newInstance(DefaultJavaToolchainRepository.class, name, authenticationContainer, authenticationSupporter, providerFactory);
configureAction.execute(repository);
boolean isNew = repositories.add(repository);
if (!isNew) {
throw new GradleException("Duplicate configuration for repository '" + name + "'.");
}
}
@Override
public List<JavaToolchainRepository> getAsList() {
ArrayList<JavaToolchainRepository> copy = repositories.stream()
.map(it -> (JavaToolchainRepositoryInternal) it)
.map(ImmutableJavaToolchainRepository::new)
.collect(Collectors.toCollection(ArrayList::new));
return Collections.unmodifiableList(copy);
}
@Override
public int size() {
return repositories.size();
}
@OverrideView on GitHub (pinned to 534f27719b)
Solutions
- Give each repository declaration a unique name in toolchainManagement.repositories
- Check settings plugins you apply - one of them may already declare the same repository name
- Consolidate the duplicate declarations into a single block (or move ownership fully into the plugin)
Example fix
// before - settings.gradle.kts declares 'nexus' twice
repositories { nexus { ... } }
repositories { nexus { ... } } // Duplicate configuration
// after
repositories { nexus { ... } }
repositories { vendorMirror { ... } } Defensive patterns
Strategy: validation
Validate before calling
// settings lint: no duplicate repository declarations
def names = []
settings.toolchainManagement.repositories.getAsList().each { names << it.name }
assert names == names.toUnique().toList() : 'duplicate toolchain repository names' Prevention
- Keep a naming convention for toolchain repositories (e.g. <vendor>-mirror)
- Review which settings plugins declare repositories before adding local ones
- Centralize repository declarations in one settings plugin
When it happens
Trigger: Two declareRepository blocks (or a settings plugin plus the settings script) declare repositories with the same name under toolchainManagement.repositories in settings evaluation.
Common situations: Copying an example block and forgetting to rename it; a convention/settings plugin and the local settings.gradle.kts both declaring 'myRepo'; refactoring that accidentally left the old block in place.
Related errors
- Mutation of toolchain repositories declared in settings is o
- Duplicate registration for '<className>'.
- Cannot add '%s' to '%s' as it is a filtered collection
- Toolchain installation '{}' could not be probed: {}
- Toolchain installation '{}' does not provide the required ca
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/2d9b2cb52e31aebe.
Report an issue: GitHub.