mirror of https://github.com/apache/maven.git
[MNG-4645] Move Central repo definition out of Maven's core so it can be more easily changed (#1139)
Co-authored-by: Christian Schulte <schulte@apache.org>
This commit is contained in:
parent
0a8491c329
commit
229b31b626
|
@ -43,9 +43,9 @@ under the License.
|
||||||
| values (values used when the setting is not specified) are provided.
|
| values (values used when the setting is not specified) are provided.
|
||||||
|
|
|
|
||||||
|-->
|
|-->
|
||||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.3.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.3.0 https://maven.apache.org/xsd/settings-1.3.0.xsd">
|
||||||
<!-- localRepository
|
<!-- localRepository
|
||||||
| The path to the local repository maven will use to store artifacts.
|
| The path to the local repository maven will use to store artifacts.
|
||||||
|
|
|
|
||||||
|
@ -166,6 +166,38 @@ under the License.
|
||||||
</mirror>
|
</mirror>
|
||||||
</mirrors>
|
</mirrors>
|
||||||
|
|
||||||
|
<!-- repositories
|
||||||
|
| Specifies the list of default remote repositories that maven will search artifacts for.
|
||||||
|
-->
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<name>Central Repository</name>
|
||||||
|
<url>https://repo.maven.apache.org/maven2</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<!-- plugin repositories
|
||||||
|
| Specifies the list of default remote repositories that maven will search plugins for.
|
||||||
|
-->
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>central</id>
|
||||||
|
<name>Central Repository</name>
|
||||||
|
<url>https://repo.maven.apache.org/maven2</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<releases>
|
||||||
|
<updatePolicy>never</updatePolicy>
|
||||||
|
</releases>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
|
|
||||||
<!-- profiles
|
<!-- profiles
|
||||||
| This is a list of profiles which can be activated in a variety of ways, and which can modify
|
| This is a list of profiles which can be activated in a variety of ways, and which can modify
|
||||||
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
|
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
|
||||||
|
|
|
@ -65,6 +65,20 @@ under the License.
|
||||||
</params>
|
</params>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>modello-site-docs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>xdoc</goal>
|
||||||
|
<goal>xsd</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<configuration>
|
||||||
|
<version>1.3.0</version>
|
||||||
|
<models>
|
||||||
|
<model>src/main/mdo/settings.mdo</model>
|
||||||
|
</models>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -223,6 +223,39 @@
|
||||||
<multiplicity>*</multiplicity>
|
<multiplicity>*</multiplicity>
|
||||||
</association>
|
</association>
|
||||||
</field>
|
</field>
|
||||||
|
<field xdoc.separator="blank">
|
||||||
|
<name>repositories</name>
|
||||||
|
<version>1.3.0+</version>
|
||||||
|
<description>
|
||||||
|
<![CDATA[
|
||||||
|
The lists of the remote repositories.
|
||||||
|
]]>
|
||||||
|
</description>
|
||||||
|
<association>
|
||||||
|
<type>Repository</type>
|
||||||
|
<multiplicity>*</multiplicity>
|
||||||
|
</association>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>pluginRepositories</name>
|
||||||
|
<version>1.3.0+</version>
|
||||||
|
<description>
|
||||||
|
<![CDATA[
|
||||||
|
The lists of the remote repositories for discovering plugins.
|
||||||
|
]]>
|
||||||
|
</description>
|
||||||
|
<association>
|
||||||
|
<type>Repository</type>
|
||||||
|
<multiplicity>*</multiplicity>
|
||||||
|
</association>
|
||||||
|
<comment>
|
||||||
|
<![CDATA[
|
||||||
|
This may be removed or relocated in the near
|
||||||
|
future. It is undecided whether plugins really need a remote
|
||||||
|
repository set of their own.
|
||||||
|
]]>
|
||||||
|
</comment>
|
||||||
|
</field>
|
||||||
<field xdoc.separator="blank">
|
<field xdoc.separator="blank">
|
||||||
<name>profiles</name>
|
<name>profiles</name>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
|
@ -266,7 +299,7 @@
|
||||||
</fields>
|
</fields>
|
||||||
<codeSegments>
|
<codeSegments>
|
||||||
<codeSegment>
|
<codeSegment>
|
||||||
<version>1.0.0/1.2.0</version>
|
<version>1.0.0/1.3.0</version>
|
||||||
<code>
|
<code>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
public Boolean getInteractiveMode()
|
public Boolean getInteractiveMode()
|
||||||
|
@ -816,6 +849,7 @@
|
||||||
<class java.clone="deep">
|
<class java.clone="deep">
|
||||||
<name>RepositoryBase</name>
|
<name>RepositoryBase</name>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
|
<superClass>IdentifiableBase</superClass>
|
||||||
<description>
|
<description>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
Repository contains the information needed
|
Repository contains the information needed
|
||||||
|
@ -823,18 +857,6 @@
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<fields>
|
<fields>
|
||||||
<field>
|
|
||||||
<name>id</name>
|
|
||||||
<version>1.0.0+</version>
|
|
||||||
<required>true</required>
|
|
||||||
<identifier>true</identifier>
|
|
||||||
<description>
|
|
||||||
<![CDATA[
|
|
||||||
A unique identifier for a repository.
|
|
||||||
]]>
|
|
||||||
</description>
|
|
||||||
<type>String</type>
|
|
||||||
</field>
|
|
||||||
<field>
|
<field>
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<version>1.0.0+</version>
|
<version>1.0.0+</version>
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
@ -83,10 +82,6 @@ public class DefaultMavenExecutionRequestPopulator implements MavenExecutionRequ
|
||||||
|
|
||||||
populateDefaultPluginGroups(request);
|
populateDefaultPluginGroups(request);
|
||||||
|
|
||||||
injectDefaultRepositories(request);
|
|
||||||
|
|
||||||
injectDefaultPluginRepositories(request);
|
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,32 +94,6 @@ public class DefaultMavenExecutionRequestPopulator implements MavenExecutionRequ
|
||||||
request.addPluginGroup("org.codehaus.mojo");
|
request.addPluginGroup("org.codehaus.mojo");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectDefaultRepositories(MavenExecutionRequest request)
|
|
||||||
throws MavenExecutionRequestPopulationException {
|
|
||||||
Set<String> definedRepositories = repositorySystem.getRepoIds(request.getRemoteRepositories());
|
|
||||||
|
|
||||||
if (!definedRepositories.contains(MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID)) {
|
|
||||||
try {
|
|
||||||
request.addRemoteRepository(repositorySystem.createDefaultRemoteRepository(request));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new MavenExecutionRequestPopulationException("Cannot create default remote repository.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void injectDefaultPluginRepositories(MavenExecutionRequest request)
|
|
||||||
throws MavenExecutionRequestPopulationException {
|
|
||||||
Set<String> definedRepositories = repositorySystem.getRepoIds(request.getPluginArtifactRepositories());
|
|
||||||
|
|
||||||
if (!definedRepositories.contains(MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID)) {
|
|
||||||
try {
|
|
||||||
request.addPluginArtifactRepository(repositorySystem.createDefaultRemoteRepository(request));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new MavenExecutionRequestPopulationException("Cannot create default remote repository.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void localRepository(MavenExecutionRequest request) throws MavenExecutionRequestPopulationException {
|
private void localRepository(MavenExecutionRequest request) throws MavenExecutionRequestPopulationException {
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Local Repository
|
// Local Repository
|
||||||
|
|
|
@ -43,6 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
class DefaultMavenProjectBuilderTest extends AbstractMavenProjectTestCase {
|
class DefaultMavenProjectBuilderTest extends AbstractMavenProjectTestCase {
|
||||||
|
@ -133,10 +134,10 @@ class DefaultMavenProjectBuilderTest extends AbstractMavenProjectTestCase {
|
||||||
assertNotNull(project.getArtifactId());
|
assertNotNull(project.getArtifactId());
|
||||||
|
|
||||||
assertNotNull(project.getRemoteArtifactRepositories());
|
assertNotNull(project.getRemoteArtifactRepositories());
|
||||||
assertFalse(project.getRemoteArtifactRepositories().isEmpty());
|
assertTrue(project.getRemoteArtifactRepositories().isEmpty());
|
||||||
|
|
||||||
assertNotNull(project.getPluginArtifactRepositories());
|
assertNotNull(project.getPluginArtifactRepositories());
|
||||||
assertFalse(project.getPluginArtifactRepositories().isEmpty());
|
assertTrue(project.getPluginArtifactRepositories().isEmpty());
|
||||||
|
|
||||||
assertNull(project.getParent());
|
assertNull(project.getParent());
|
||||||
assertNull(project.getParentArtifact());
|
assertNull(project.getParentArtifact());
|
||||||
|
|
|
@ -575,7 +575,7 @@ class PomConstructionTest {
|
||||||
@Test
|
@Test
|
||||||
void testMultipleRepositories() throws Exception {
|
void testMultipleRepositories() throws Exception {
|
||||||
PomTestWrapper pom = buildPom("multiple-repos/sub");
|
PomTestWrapper pom = buildPom("multiple-repos/sub");
|
||||||
assertEquals(3, ((List<?>) pom.getValue("repositories")).size());
|
assertEquals(2, ((List<?>) pom.getValue("repositories")).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** MNG-3965 */
|
/** MNG-3965 */
|
||||||
|
@ -1371,12 +1371,10 @@ class PomConstructionTest {
|
||||||
assertEquals("org.apache.maven.its", pom.getValue("dependencies[1]/exclusions[1]/groupId"));
|
assertEquals("org.apache.maven.its", pom.getValue("dependencies[1]/exclusions[1]/groupId"));
|
||||||
assertEquals("excluded-dep", pom.getValue("dependencies[1]/exclusions[1]/artifactId"));
|
assertEquals("excluded-dep", pom.getValue("dependencies[1]/exclusions[1]/artifactId"));
|
||||||
|
|
||||||
assertEquals(2, ((List<?>) pom.getValue("repositories")).size());
|
assertEquals(1, ((List<?>) pom.getValue("repositories")).size());
|
||||||
assertEquals("project-remote-repo", pom.getValue("repositories[1]/id"));
|
assertEquals("project-remote-repo", pom.getValue("repositories[1]/id"));
|
||||||
assertEquals("https://project.url/remote", pom.getValue("repositories[1]/url"));
|
assertEquals("https://project.url/remote", pom.getValue("repositories[1]/url"));
|
||||||
assertEquals("repo", pom.getValue("repositories[1]/name"));
|
assertEquals("repo", pom.getValue("repositories[1]/name"));
|
||||||
assertEquals(MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID, pom.getValue("repositories[2]/id"));
|
|
||||||
assertEquals(MavenRepositorySystem.DEFAULT_REMOTE_REPO_URL, pom.getValue("repositories[2]/url"));
|
|
||||||
|
|
||||||
assertEquals("test", pom.getValue("build/defaultGoal"));
|
assertEquals("test", pom.getValue("build/defaultGoal"));
|
||||||
assertEquals("coreit", pom.getValue("build/finalName"));
|
assertEquals("coreit", pom.getValue("build/finalName"));
|
||||||
|
|
|
@ -233,6 +233,22 @@ public class SettingsXmlConfigurationProcessor implements ConfigurationProcessor
|
||||||
request.addMirror(mirror);
|
request.addMirror(mirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Repository remoteRepository : settings.getRepositories()) {
|
||||||
|
try {
|
||||||
|
request.addRemoteRepository(MavenRepositorySystem.buildArtifactRepository(remoteRepository));
|
||||||
|
} catch (InvalidRepositoryException e) {
|
||||||
|
// do nothing for now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Repository pluginRepository : settings.getPluginRepositories()) {
|
||||||
|
try {
|
||||||
|
request.addPluginArtifactRepository(MavenRepositorySystem.buildArtifactRepository(pluginRepository));
|
||||||
|
} catch (InvalidRepositoryException e) {
|
||||||
|
// do nothing for now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
request.setActiveProfiles(settings.getActiveProfiles());
|
request.setActiveProfiles(settings.getActiveProfiles());
|
||||||
|
|
||||||
for (Profile rawProfile : settings.getProfiles()) {
|
for (Profile rawProfile : settings.getProfiles()) {
|
||||||
|
|
|
@ -28,33 +28,6 @@ under the License.
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>central</id>
|
|
||||||
<name>Maven Central Repository</name>
|
|
||||||
<url>https://repo.maven.apache.org/maven2</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>central</id>
|
|
||||||
<name>Maven Central Repository</name>
|
|
||||||
<url>https://repo.maven.apache.org/maven2</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
<releases>
|
|
||||||
<updatePolicy>never</updatePolicy>
|
|
||||||
</releases>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<directory>${project.basedir}/target</directory>
|
<directory>${project.basedir}/target</directory>
|
||||||
<outputDirectory>${project.build.directory}/classes</outputDirectory>
|
<outputDirectory>${project.build.directory}/classes</outputDirectory>
|
||||||
|
|
|
@ -32,6 +32,8 @@ import java.util.Map;
|
||||||
import org.apache.maven.api.settings.InputSource;
|
import org.apache.maven.api.settings.InputSource;
|
||||||
import org.apache.maven.building.FileSource;
|
import org.apache.maven.building.FileSource;
|
||||||
import org.apache.maven.building.Source;
|
import org.apache.maven.building.Source;
|
||||||
|
import org.apache.maven.settings.Repository;
|
||||||
|
import org.apache.maven.settings.RepositoryPolicy;
|
||||||
import org.apache.maven.settings.Server;
|
import org.apache.maven.settings.Server;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.settings.Settings;
|
||||||
import org.apache.maven.settings.TrackableBase;
|
import org.apache.maven.settings.TrackableBase;
|
||||||
|
@ -104,6 +106,26 @@ public class DefaultSettingsBuilder implements SettingsBuilder {
|
||||||
settingsMerger.merge(projectSettings, globalSettings, TrackableBase.GLOBAL_LEVEL);
|
settingsMerger.merge(projectSettings, globalSettings, TrackableBase.GLOBAL_LEVEL);
|
||||||
settingsMerger.merge(userSettings, projectSettings, TrackableBase.PROJECT_LEVEL);
|
settingsMerger.merge(userSettings, projectSettings, TrackableBase.PROJECT_LEVEL);
|
||||||
|
|
||||||
|
// If no repository is defined in the user/global settings,
|
||||||
|
// it means that we have "old" settings (as those are new in 4.0)
|
||||||
|
// so add central to the computed settings for backward compatibility.
|
||||||
|
if (userSettings.getRepositories().isEmpty()
|
||||||
|
&& userSettings.getPluginRepositories().isEmpty()) {
|
||||||
|
Repository central = new Repository();
|
||||||
|
central.setId("central");
|
||||||
|
central.setName("Central Repository");
|
||||||
|
central.setUrl("https://repo.maven.apache.org/maven2");
|
||||||
|
RepositoryPolicy disabledPolicy = new RepositoryPolicy();
|
||||||
|
disabledPolicy.setEnabled(false);
|
||||||
|
central.setSnapshots(disabledPolicy);
|
||||||
|
userSettings.getRepositories().add(central);
|
||||||
|
central = central.clone();
|
||||||
|
RepositoryPolicy updateNeverPolicy = new RepositoryPolicy();
|
||||||
|
disabledPolicy.setUpdatePolicy("never");
|
||||||
|
central.setReleases(updateNeverPolicy);
|
||||||
|
userSettings.getPluginRepositories().add(central);
|
||||||
|
}
|
||||||
|
|
||||||
problems.setSource("");
|
problems.setSource("");
|
||||||
|
|
||||||
userSettings = interpolate(userSettings, request, problems);
|
userSettings = interpolate(userSettings, request, problems);
|
||||||
|
|
|
@ -88,6 +88,8 @@ public class MavenSettingsMerger {
|
||||||
shallowMergeById(dominant.getServers(), recessive.getServers(), recessiveSourceLevel);
|
shallowMergeById(dominant.getServers(), recessive.getServers(), recessiveSourceLevel);
|
||||||
shallowMergeById(dominant.getProxies(), recessive.getProxies(), recessiveSourceLevel);
|
shallowMergeById(dominant.getProxies(), recessive.getProxies(), recessiveSourceLevel);
|
||||||
shallowMergeById(dominant.getProfiles(), recessive.getProfiles(), recessiveSourceLevel);
|
shallowMergeById(dominant.getProfiles(), recessive.getProfiles(), recessiveSourceLevel);
|
||||||
|
shallowMergeById(dominant.getRepositories(), recessive.getRepositories(), recessiveSourceLevel);
|
||||||
|
shallowMergeById(dominant.getPluginRepositories(), recessive.getPluginRepositories(), recessiveSourceLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,7 +67,7 @@ class DefaultSettingsValidatorTest {
|
||||||
validator.validate(model, problems);
|
validator.validate(model, problems);
|
||||||
assertEquals(0, problems.messages.size());
|
assertEquals(0, problems.messages.size());
|
||||||
|
|
||||||
Repository repo = new Repository();
|
Repository repo = new Repository(org.apache.maven.api.settings.Repository.newInstance(false));
|
||||||
prof.addRepository(repo);
|
prof.addRepository(repo);
|
||||||
problems = new SimpleProblemCollector();
|
problems = new SimpleProblemCollector();
|
||||||
validator.validate(model, problems);
|
validator.validate(model, problems);
|
||||||
|
|
|
@ -94,7 +94,7 @@ under the License.
|
||||||
</goals>
|
</goals>
|
||||||
<phase>generate-sources</phase>
|
<phase>generate-sources</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
<templates>
|
<templates>
|
||||||
<template>model-v3.vm</template>
|
<template>model-v3.vm</template>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
Loading…
Reference in New Issue