diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java index a0037e7c6d4..0490ba145a5 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java @@ -26,7 +26,7 @@ import org.springframework.boot.dependency.tools.ManagedDependencies; /** * Context used when resolving dependencies. - * + * * @author Andy Wilkinson * @since 1.1.0 */ @@ -43,6 +43,8 @@ public class DependencyResolutionContext { public DependencyResolutionContext( ArtifactCoordinatesResolver artifactCoordinatesResolver) { this.artifactCoordinatesResolver = artifactCoordinatesResolver; + this.managedDependencies = new ManagedDependenciesFactory() + .getManagedDependencies(); } public void setManagedDependencies(ManagedDependencies managedDependencies) { @@ -50,7 +52,7 @@ public class DependencyResolutionContext { managedDependencies); this.managedDependencies = new ArrayList( new ManagedDependenciesFactory(managedDependencies) - .getManagedDependencies()); + .getManagedDependencies()); } public ArtifactCoordinatesResolver getArtifactCoordinatesResolver() { diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java index 7dbceb958fa..971ddcb5da4 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java @@ -25,8 +25,9 @@ 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 { 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); diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java index bd502a5ba9b..93e4407a630 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java @@ -45,7 +45,7 @@ public class AetherGrapeEngineTests { private final AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create( this.groovyClassLoader, Arrays.asList(new RepositoryConfiguration("central", URI.create("http://repo1.maven.org/maven2"), false)), - new DependencyResolutionContext()); + new DependencyResolutionContext()); @Test public void dependencyResolution() { @@ -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 { 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 { 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 diff --git a/spring-boot-cli/src/test/resources/repro-samples/data-jpa.groovy b/spring-boot-cli/src/test/resources/repro-samples/data-jpa.groovy new file mode 100644 index 00000000000..8470df88264 --- /dev/null +++ b/spring-boot-cli/src/test/resources/repro-samples/data-jpa.groovy @@ -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" + } +} \ No newline at end of file