mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
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
This commit is contained in:
parent
9260608195
commit
4f29bc9c14
@ -65,32 +65,6 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-effective-pom</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>effective-pom</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
<destFileName>dependencies-pom.xml</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
@ -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) {
|
Loading…
Reference in New Issue
Block a user