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
This commit is contained in:
mrumpf 2015-09-01 12:58:42 +02:00 committed by Dave Syer
parent 8188060edf
commit 251f2805a8
6 changed files with 42 additions and 13 deletions

View File

@ -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]

View File

@ -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");
}
}
}

View File

@ -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

View File

@ -7,10 +7,6 @@
<artifact pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
<ivy pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].pom" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/release" />
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/milestone" />
<ibiblio name="spring-snapshots" m2compatible="true" root="http://repo.spring.io/snapshot" />
</chain>
</resolvers>
</ivysettings>

View File

@ -36,7 +36,21 @@
<version>${ant.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- The antunit tests require joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
<scope>compile</scope>
</dependency>
<!-- This is an optional depencency in the joda-time 2.8.1 pom.xml but Ivy tries to resolve it -->
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@ -4,13 +4,9 @@
<chain name="chain">
<!-- NOTE: You should declare only repositories that you need here -->
<filesystem name="local" local="true" m2compatible="true">
<artifact pattern="${user.home}/.m2/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
<ivy pattern="${user.home}/.m2/[organisation]/[module]/[revision]/[module]-[revision].pom" />
<artifact pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
<ivy pattern="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision].pom" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/release" />
<ibiblio name="spring-milestones" m2compatible="true" root="http://repo.spring.io/milestone" />
<ibiblio name="spring-snapshots" m2compatible="true" root="http://repo.spring.io/snapshot" />
</chain>
</resolvers>
</ivysettings>