Browse Source

Initialize DependencyResolutionContext with default dependency mgmt

In the absence of a @GrabMetadata annotation,
DependencyResolutionContext provided no dependency management. This
was leading to incorrect dependency versions being pulled in. This
commit intializes the context with default dependency management that
will be replaced should @GrabMetadata be encountered.

Fixes #1021
pull/1031/head
Andy Wilkinson 12 years ago
parent
commit
156dadaebe
  1. 2
      spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java
  2. 7
      spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java
  3. 6
      spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java
  4. 12
      spring-boot-cli/src/test/resources/repro-samples/data-jpa.groovy

2
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java

@ -43,6 +43,8 @@ public class DependencyResolutionContext { @@ -43,6 +43,8 @@ public class DependencyResolutionContext {
public DependencyResolutionContext(
ArtifactCoordinatesResolver artifactCoordinatesResolver) {
this.artifactCoordinatesResolver = artifactCoordinatesResolver;
this.managedDependencies = new ManagedDependenciesFactory()
.getManagedDependencies();
}
public void setManagedDependencies(ManagedDependencies managedDependencies) {

7
spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java

@ -27,6 +27,7 @@ import static org.junit.Assert.assertThat; @@ -27,6 +27,7 @@ import static org.junit.Assert.assertThat;
* Integration tests to exercise and reproduce specific issues.
*
* @author Phillip Webb
* @author Andy Wilkinson
*/
public class ReproIntegrationTests {
@ -58,6 +59,12 @@ public class ReproIntegrationTests { @@ -58,6 +59,12 @@ public class ReproIntegrationTests {
containsString("{\"message\":\"Hello World\"}"));
}
@Test
public void dataJpaDependencies() throws Exception {
this.cli.run("data-jpa.groovy");
assertThat(this.cli.getOutput(), containsString("Hello World"));
}
@Test
public void jarFileExtensionNeeded() throws Exception {
this.thrown.expect(IllegalStateException.class);

6
spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java

@ -54,7 +54,7 @@ public class AetherGrapeEngineTests { @@ -54,7 +54,7 @@ public class AetherGrapeEngineTests {
this.grapeEngine.grab(args,
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"));
assertEquals(6, this.groovyClassLoader.getURLs().length);
assertEquals(5, this.groovyClassLoader.getURLs().length);
}
@Test
@ -76,7 +76,7 @@ public class AetherGrapeEngineTests { @@ -76,7 +76,7 @@ public class AetherGrapeEngineTests {
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"),
createDependency("org.springframework", "spring-beans", "3.2.4.RELEASE"));
assertEquals(4, this.groovyClassLoader.getURLs().length);
assertEquals(3, this.groovyClassLoader.getURLs().length);
}
@Test
@ -101,7 +101,7 @@ public class AetherGrapeEngineTests { @@ -101,7 +101,7 @@ public class AetherGrapeEngineTests {
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"));
assertEquals(0, this.groovyClassLoader.getURLs().length);
assertEquals(6, customClassLoader.getURLs().length);
assertEquals(5, customClassLoader.getURLs().length);
}
@Test

12
spring-boot-cli/src/test/resources/repro-samples/data-jpa.groovy

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
@Grab('spring-boot-starter-data-jpa')
@Grab('h2')
class Sample implements CommandLineRunner {
// No Data JPA-based logic. We just want to check that the dependencies are
// resolved correctly and that the app runs
@Override
void run(String... args) {
println "Hello World"
}
}
Loading…
Cancel
Save