mirror of
https://gitee.com/dcren/initializr.git
synced 2026-01-09 09:55:11 +08:00
Tolerate incomplete models
This commit improves the resolution of plugins to ignore a non fatal resolution of the model. See gh-1227
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jcl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.building.DefaultModelBuilder;
|
||||
import org.apache.maven.model.building.DefaultModelBuilderFactory;
|
||||
@@ -68,6 +70,8 @@ import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
|
||||
@SuppressWarnings("removal")
|
||||
class DefaultMavenVersionResolver implements MavenVersionResolver, DependencyManagementVersionResolver {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DefaultMavenVersionResolver.class);
|
||||
|
||||
private static final RemoteRepository mavenCentral = new RemoteRepository.Builder("central", "default",
|
||||
"https://repo1.maven.org/maven2")
|
||||
.build();
|
||||
@@ -163,6 +167,12 @@ class DefaultMavenVersionResolver implements MavenVersionResolver, DependencyMan
|
||||
return modelBuilder.build(modelBuildingRequest).getEffectiveModel();
|
||||
}
|
||||
catch (ModelBuildingException ex) {
|
||||
Model model = ex.getModel();
|
||||
if (model != null) {
|
||||
logger.warn("Model for '" + groupId + ":" + artifactId + ":" + version + "' is incomplete: "
|
||||
+ ex.getProblems());
|
||||
return model;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"Model for '" + groupId + ":" + artifactId + ":" + version + "' could not be built", ex);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,13 @@ class DefaultMavenVersionResolverTests {
|
||||
assertThat(versions).containsEntry("org.springframework.boot:spring-boot-maven-plugin", "2.2.0.M3");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvePluginsUsingMilestoneThatHasResolutionProblem() {
|
||||
Map<String, String> versions = this.resolver.resolvePlugins("org.springframework.boot",
|
||||
"spring-boot-dependencies", "3.0.0-M1");
|
||||
assertThat(versions).containsEntry("org.springframework.boot:spring-boot-maven-plugin", "3.0.0-M1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvePluginsUsingSnapshots() {
|
||||
Map<String, String> versions = this.resolver.resolvePlugins("org.springframework.boot",
|
||||
|
||||
Reference in New Issue
Block a user