From 251f2805a83cde1bf23e2d29b30ee6a6ee611e3f Mon Sep 17 00:00:00 2001 From: mrumpf Date: Tue, 1 Sep 2015 12:58:42 +0200 Subject: [PATCH] Add or avoid proxy configurations for integration tests The Maven POM does all the dependency resolutions for the spring-boot-antlib project. Delegating this task to Ivy, which is buried deep in the Antrun/Antunit part of the build, makes any kind of proxy configuration much more complex. The ivysettings.xml already has the local M2 repository configured, but because the folder "repository" is missing, the artifacts, already downloaded by Maven cannot be resolved from this location. The Spring and Maven Central repositories should be removed from the ivysettings.xml files in order to force all resolves to be done through the local M2 repository. The POM of joda-time version 2.8.1 has an optional dependency to joda-convert 1.2, which lets the Ivy resolve process fail, because this version of the joda-convert library was not resolved by any of the Maven POMs. It seems as if Ivy does not respect the optional scope, defined in the joda-time POM. Pass proxy settings to the forked process to make the Gradle distribution download work Create a gradle.properties file for each Gradle integration test and writes the forking process' proxy settings as systemProp.http(s).Host/Port to the properties file. This configures the external process with the right proxy settings to let it download the Gradle distribution via the HTTP proxy server. Added a hint for Windows users to get the core.autocrlf setting right When the core.autocrlf setting under Windows is set to false for example All files are not converted regarding their EOL characters to the Windows format with CRLF at a line's end. There is a checkstyle validation that checks that all files have the system's line endings and in some test-cases the value from the system property "line.ending" is used to check test output. So without the conversion, those checks are going to fail, resulting in build errors. Fixes gh-4367, fixes gh-3816 --- README.adoc | 3 +++ .../boot/gradle/ProjectCreator.java | 22 ++++++++++++++++++- .../StarterDependenciesIntegrationTests.java | 2 +- .../spring-boot-sample-ant/ivysettings.xml | 4 ---- spring-boot-tools/spring-boot-antlib/pom.xml | 16 +++++++++++++- .../src/it/sample/ivysettings.xml | 8 ++----- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/README.adoc b/README.adoc index 89f6272f2ab..10cea207a3c 100755 --- a/README.adoc +++ b/README.adoc @@ -111,6 +111,9 @@ tests there (e.g. in Eclipse go to `Preferences->Java->Installed JREs` and edit JRE definition so that all processes are launched with those arguments). This property is automatically set if you use the maven wrapper. +NOTE: Make sure that your Git config property "core.autocrlf" setting is set to true +under Windows to avoid build and test failures due to missing CRLF EOL characters. + _Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular please fill out the https://support.springsource.com/spring_committer_signup[Contributor's Agreement] diff --git a/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/ProjectCreator.java b/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/ProjectCreator.java index cb1a6be6925..f3b15d9bbf8 100644 --- a/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/ProjectCreator.java +++ b/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/ProjectCreator.java @@ -16,7 +16,9 @@ package org.springframework.boot.gradle; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; import java.io.IOException; import org.gradle.tooling.GradleConnector; @@ -46,7 +48,8 @@ public class ProjectCreator { projectDirectory.mkdirs(); File gradleScript = new File(projectDirectory, "build.gradle"); - + writeGradleProperties(projectDirectory); + if (new File("src/test/resources", name).isDirectory()) { FileSystemUtils.copyRecursively(new File("src/test/resources", name), projectDirectory); @@ -62,4 +65,21 @@ public class ProjectCreator { ((DefaultGradleConnector) gradleConnector).embedded(true); return gradleConnector.forProjectDirectory(projectDirectory).connect(); } + + private void writeGradleProperties(File projectDirectory) throws IOException { + File gradleProperties = new File(projectDirectory, "gradle.properties"); + BufferedWriter writer = new BufferedWriter(new FileWriter(gradleProperties)); + writeProperty(writer, "http.proxyHost"); + writeProperty(writer, "https.proxyHost"); + writeProperty(writer, "http.proxyPort"); + writeProperty(writer, "https.proxyPort"); + writer.close(); + } + + private void writeProperty(BufferedWriter writer, String name) throws IOException { + String value = System.getProperty(name); + if (value != null) { + writer.write("systemProp." + name + "=" + value + "\n"); + } + } } diff --git a/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/starter/StarterDependenciesIntegrationTests.java b/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/starter/StarterDependenciesIntegrationTests.java index e14f698b2e0..ca405e3c24e 100644 --- a/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/starter/StarterDependenciesIntegrationTests.java +++ b/spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/starter/StarterDependenciesIntegrationTests.java @@ -91,7 +91,7 @@ public class StarterDependenciesIntegrationTests { public StarterDependenciesIntegrationTests(String starter) { this.buildArguments = new String[] { "-Pstarter=" + starter, - "-PbootVersion=" + bootVersion, "-PspringVersion=" + springVersion }; + "-PbootVersion=" + bootVersion, "-PspringVersion=" + springVersion, "--stacktrace" }; } @Test diff --git a/spring-boot-samples/spring-boot-sample-ant/ivysettings.xml b/spring-boot-samples/spring-boot-sample-ant/ivysettings.xml index 4127a506e8c..48db163feb7 100644 --- a/spring-boot-samples/spring-boot-sample-ant/ivysettings.xml +++ b/spring-boot-samples/spring-boot-sample-ant/ivysettings.xml @@ -7,10 +7,6 @@ - - - - diff --git a/spring-boot-tools/spring-boot-antlib/pom.xml b/spring-boot-tools/spring-boot-antlib/pom.xml index a3500a2ab50..638b7948b28 100644 --- a/spring-boot-tools/spring-boot-antlib/pom.xml +++ b/spring-boot-tools/spring-boot-antlib/pom.xml @@ -36,7 +36,21 @@ ${ant.version} provided - + + + joda-time + joda-time + ${joda-time.version} + compile + + + + org.joda + joda-convert + 1.2 + compile + + diff --git a/spring-boot-tools/spring-boot-antlib/src/it/sample/ivysettings.xml b/spring-boot-tools/spring-boot-antlib/src/it/sample/ivysettings.xml index 72631b8ba83..4c352fed989 100644 --- a/spring-boot-tools/spring-boot-antlib/src/it/sample/ivysettings.xml +++ b/spring-boot-tools/spring-boot-antlib/src/it/sample/ivysettings.xml @@ -4,13 +4,9 @@ - - + + - - - -