Skip to content

Commit 251f280

Browse files
mrumpfdsyer
mrumpf
authored andcommitted
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 spring-projectsgh-4367, fixes spring-projectsgh-3816
1 parent 8188060 commit 251f280

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

README.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ tests there (e.g. in Eclipse go to `Preferences->Java->Installed JREs` and edit
111111
JRE definition so that all processes are launched with those arguments). This property
112112
is automatically set if you use the maven wrapper.
113113

114+
NOTE: Make sure that your Git config property "core.autocrlf" setting is set to true
115+
under Windows to avoid build and test failures due to missing CRLF EOL characters.
116+
114117
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests,
115118
and in particular please fill out the
116119
https://support.springsource.com/spring_committer_signup[Contributor's Agreement]

spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/ProjectCreator.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package org.springframework.boot.gradle;
1818

19+
import java.io.BufferedWriter;
1920
import java.io.File;
21+
import java.io.FileWriter;
2022
import java.io.IOException;
2123

2224
import org.gradle.tooling.GradleConnector;
@@ -46,7 +48,8 @@ public ProjectConnection createProject(String name) throws IOException {
4648
projectDirectory.mkdirs();
4749

4850
File gradleScript = new File(projectDirectory, "build.gradle");
49-
51+
writeGradleProperties(projectDirectory);
52+
5053
if (new File("src/test/resources", name).isDirectory()) {
5154
FileSystemUtils.copyRecursively(new File("src/test/resources", name),
5255
projectDirectory);
@@ -62,4 +65,21 @@ public ProjectConnection createProject(String name) throws IOException {
6265
((DefaultGradleConnector) gradleConnector).embedded(true);
6366
return gradleConnector.forProjectDirectory(projectDirectory).connect();
6467
}
68+
69+
private void writeGradleProperties(File projectDirectory) throws IOException {
70+
File gradleProperties = new File(projectDirectory, "gradle.properties");
71+
BufferedWriter writer = new BufferedWriter(new FileWriter(gradleProperties));
72+
writeProperty(writer, "http.proxyHost");
73+
writeProperty(writer, "https.proxyHost");
74+
writeProperty(writer, "http.proxyPort");
75+
writeProperty(writer, "https.proxyPort");
76+
writer.close();
77+
}
78+
79+
private void writeProperty(BufferedWriter writer, String name) throws IOException {
80+
String value = System.getProperty(name);
81+
if (value != null) {
82+
writer.write("systemProp." + name + "=" + value + "\n");
83+
}
84+
}
6585
}

spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/starter/StarterDependenciesIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static void closeProject() {
9191

9292
public StarterDependenciesIntegrationTests(String starter) {
9393
this.buildArguments = new String[] { "-Pstarter=" + starter,
94-
"-PbootVersion=" + bootVersion, "-PspringVersion=" + springVersion };
94+
"-PbootVersion=" + bootVersion, "-PspringVersion=" + springVersion, "--stacktrace" };
9595
}
9696

9797
@Test

spring-boot-samples/spring-boot-sample-ant/ivysettings.xml

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
<artifact pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
88
<ivy pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].pom" />
99
</filesystem>
10-
<ibiblio name="ibiblio" m2compatible="true" />
11-
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/release" />
12-
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/milestone" />
13-
<ibiblio name="spring-snapshots" m2compatible="true" root="http://repo.spring.io/snapshot" />
1410
</chain>
1511
</resolvers>
1612
</ivysettings>

spring-boot-tools/spring-boot-antlib/pom.xml

+15-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,21 @@
3636
<version>${ant.version}</version>
3737
<scope>provided</scope>
3838
</dependency>
39-
</dependencies>
39+
<!-- The antunit tests require joda-time -->
40+
<dependency>
41+
<groupId>joda-time</groupId>
42+
<artifactId>joda-time</artifactId>
43+
<version>${joda-time.version}</version>
44+
<scope>compile</scope>
45+
</dependency>
46+
<!-- This is an optional depencency in the joda-time 2.8.1 pom.xml but Ivy tries to resolve it -->
47+
<dependency>
48+
<groupId>org.joda</groupId>
49+
<artifactId>joda-convert</artifactId>
50+
<version>1.2</version>
51+
<scope>compile</scope>
52+
</dependency>
53+
</dependencies>
4054
<build>
4155
<plugins>
4256
<plugin>

spring-boot-tools/spring-boot-antlib/src/it/sample/ivysettings.xml

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
<chain name="chain">
55
<!-- NOTE: You should declare only repositories that you need here -->
66
<filesystem name="local" local="true" m2compatible="true">
7-
<artifact pattern="${user.home}/.m2/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
8-
<ivy pattern="${user.home}/.m2/[organisation]/[module]/[revision]/[module]-[revision].pom" />
7+
<artifact pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
8+
<ivy pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].pom" />
99
</filesystem>
10-
<ibiblio name="ibiblio" m2compatible="true" />
11-
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/release" />
12-
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/milestone" />
13-
<ibiblio name="spring-snapshots" m2compatible="true" root="http://repo.spring.io/snapshot" />
1410
</chain>
1511
</resolvers>
1612
</ivysettings>

0 commit comments

Comments
 (0)