From 4f29bc9c14b59c626d962e166594e97f9060f9d4 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 20 Feb 2017 08:56:51 +0000 Subject: [PATCH] Make mvn verify work without install of spring-boot-dependencies Previously, the custom layout sample could only be built successfully if spring-boot-dependencies had be installed locally, making its effective pom available in the local Maven cache. This commit updates the sample's tests to look at its own pom to determine the version of Spring Boot that should be used in the Gradle tests. Closes gh-8330 --- .../spring-boot-sample-custom-layout/pom.xml | 26 ------------------- .../layout/{GradeIT.java => GradleIT.java} | 13 +++++----- 2 files changed, 7 insertions(+), 32 deletions(-) rename spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/{GradeIT.java => GradleIT.java} (87%) diff --git a/spring-boot-samples/spring-boot-sample-custom-layout/pom.xml b/spring-boot-samples/spring-boot-sample-custom-layout/pom.xml index 17e45a2463..7b9cbfbe00 100644 --- a/spring-boot-samples/spring-boot-sample-custom-layout/pom.xml +++ b/spring-boot-samples/spring-boot-sample-custom-layout/pom.xml @@ -65,32 +65,6 @@ org.apache.maven.plugins maven-failsafe-plugin - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-effective-pom - generate-test-resources - - copy - - - - - org.springframework.boot - spring-boot-dependencies - ${project.version} - effective-pom - true - ${project.build.directory} - dependencies-pom.xml - - - - - - diff --git a/spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/GradeIT.java b/spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/GradleIT.java similarity index 87% rename from spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/GradeIT.java rename to spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/GradleIT.java index 5a132fa00e..b488064a21 100644 --- a/spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/GradeIT.java +++ b/spring-boot-samples/spring-boot-sample-custom-layout/src/test/java/sample/layout/GradleIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -31,7 +31,7 @@ import org.xml.sax.InputSource; import org.springframework.util.FileCopyUtils; -public class GradeIT { +public class GradleIT { @Test public void sampleDefault() throws Exception { @@ -60,7 +60,8 @@ public class GradeIT { ((DefaultGradleConnector) gradleConnector).embedded(true); ProjectConnection project = gradleConnector.forProjectDirectory(projectDirectory) .connect(); - project.newBuild().forTasks("clean", "build") + project.newBuild().forTasks("clean", "build").setStandardOutput(System.out) + .setStandardError(System.err) .withArguments("-PbootVersion=" + getBootVersion()).run(); Verify.verify( new File("target/gradleit/" + name + "/build/libs/" + name + ".jar"), @@ -69,7 +70,8 @@ public class GradeIT { public static String getBootVersion() { return evaluateExpression( - "/*[local-name()='project']/*[local-name()='version']" + "/text()"); + "/*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']" + + "/text()"); } private static String evaluateExpression(String expression) { @@ -77,8 +79,7 @@ public class GradeIT { XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xpath = xPathFactory.newXPath(); XPathExpression expr = xpath.compile(expression); - String version = expr.evaluate( - new InputSource(new FileReader("target/dependencies-pom.xml"))); + String version = expr.evaluate(new InputSource(new FileReader("pom.xml"))); return version; } catch (Exception ex) {