Commit 15a70153 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.0.x'

parents e39e125a 5ce0e07c
......@@ -30,6 +30,7 @@ import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ResolvableDependencies;
import org.gradle.util.GradleVersion;
import org.springframework.boot.gradle.dsl.SpringBootExtension;
......@@ -42,6 +43,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootWar;
* @author Phillip Webb
* @author Dave Syer
* @author Andy Wilkinson
* @author Danny Hyun
*/
public class SpringBootPlugin implements Plugin<Project> {
......@@ -120,11 +122,16 @@ public class SpringBootPlugin implements Plugin<Project> {
private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
project.getConfigurations().all((configuration) -> configuration.getIncoming()
.afterResolve((resolvableDependencies) -> unresolvedDependenciesAnalyzer
.analyze(configuration.getResolvedConfiguration()
.getLenientConfiguration()
.getUnresolvedModuleDependencies())));
project.getConfigurations().all((configuration) -> {
ResolvableDependencies incoming = configuration.getIncoming();
incoming.afterResolve((resolvableDependencies) -> {
if (incoming.equals(resolvableDependencies)) {
unresolvedDependenciesAnalyzer.analyze(configuration
.getResolvedConfiguration().getLenientConfiguration()
.getUnresolvedModuleDependencies());
}
});
});
project.getGradle().buildFinished(
(buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
}
......
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -16,6 +16,9 @@
package org.springframework.boot.gradle.plugin;
import java.io.File;
import java.io.IOException;
import org.gradle.testkit.runner.BuildResult;
import org.junit.Rule;
import org.junit.Test;
......@@ -51,4 +54,22 @@ public class SpringBootPluginIntegrationTests {
this.gradleBuild.gradleVersion("4.0").build();
}
@Test
public void unresolvedDependenciesAreAnalyzedWhenDependencyResolutionFails()
throws IOException {
createMinimalMainSource();
BuildResult result = this.gradleBuild.buildAndFail("compileJava");
assertThat(result.getOutput()).contains(
"During the build, one or more dependencies that were declared without a"
+ " version failed to resolve:")
.contains(" org.springframework.boot:spring-boot-starter:");
}
private void createMinimalMainSource() throws IOException {
File examplePackage = new File(this.gradleBuild.getProjectDir(),
"src/main/java/com/example");
examplePackage.mkdirs();
new File(examplePackage, "Application.java").createNewFile();
}
}
buildscript {
dependencies {
classpath files(pluginClasspath.split(','))
}
}
apply plugin: 'org.springframework.boot'
apply plugin: 'java'
repositories {
flatDir { dirs 'libs' }
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter'
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment