I tried to convert a Maven project to Gradle, our setup is that there is a ~/.m2/settings.xml that explicitly overrides “central” with broken URL, and defines a mirror pointing to our curated Nexus.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>com.company.tools.maven</pluginGroup>
</pluginGroups>
<mirrors>
<mirror>
<id>nexus-central</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus.company.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<snapshots><enabled>true</enabled><updatePolicy>daily</updatePolicy></snapshots>
<releases ><enabled>true</enabled><checksumPolicy>fail</checksumPolicy></releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<snapshots><enabled>true</enabled><updatePolicy>daily</updatePolicy></snapshots>
<releases ><enabled>true</enabled><checksumPolicy>fail</checksumPolicy></releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Gradle correctly detected the settings.xml file, resolved all the required artifacts (I can see it in the maven’s local repo), but when setting up the repos in the generated Gradle script sets it to the broken central repository and not to the mirror.
repositories {
maven { url "http://central" }
}
I would say that in such case it should set both repositories, the mirror first and fallback to the invalid second.