Port the build to Gradle

Closes gh-19609
Closes gh-19608
This commit is contained in:
Andy Wilkinson
2020-01-10 13:48:43 +00:00
parent abe95fa8a7
commit ce99db1902
974 changed files with 17108 additions and 26596 deletions

View File

@@ -96,12 +96,14 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
for (String arg : args) {
if (arg.startsWith("--classpath=")) {
arg = arg + ":" + this.buildOutput.getTestClassesLocation().getAbsolutePath();
arg = arg + ":" + this.buildOutput.getTestResourcesLocation().getAbsolutePath();
classpathUpdated = true;
}
updatedArgs.add(arg);
}
if (!classpathUpdated) {
updatedArgs.add("--classpath=.:" + this.buildOutput.getTestClassesLocation().getAbsolutePath());
updatedArgs.add("--classpath=.:" + this.buildOutput.getTestClassesLocation().getAbsolutePath() + ":"
+ this.buildOutput.getTestResourcesLocation().getAbsolutePath());
}
Future<RunCommand> future = submitCommand(new RunCommand(), StringUtils.toStringArray(updatedArgs));
this.commands.add(future.get(this.timeout, TimeUnit.MILLISECONDS));
@@ -134,6 +136,8 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
"org.springframework.boot.cli.CliTesterSpringApplication");
this.serverPortFile = new File(this.temp, "server.port");
System.setProperty("portfile", this.serverPortFile.getAbsolutePath());
String userHome = System.getProperty("user.home");
System.setProperty("user.home", "src/test/resources/cli-tester");
try {
command.run(sources);
return command;
@@ -142,6 +146,7 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
System.clearProperty("server.port");
System.clearProperty("spring.application.class.name");
System.clearProperty("portfile");
System.setProperty("user.home", userHome);
Thread.currentThread().setContextClassLoader(loader);
}
});

View File

@@ -57,15 +57,12 @@ class GrabCommandIntegrationTests {
@Test
void grab() throws Exception {
System.setProperty("grape.root", this.cli.getTemp().getAbsolutePath());
System.setProperty("groovy.grape.report.downloads", "true");
// Use --autoconfigure=false to limit the amount of downloaded dependencies
String output = this.cli.grab("grab.groovy", "--autoconfigure=false");
assertThat(new File(this.cli.getTemp(), "repository/joda-time/joda-time")).isDirectory();
// Should be resolved from local repository cache
assertThat(output.contains("Downloading: file:")).isTrue();
assertThat(output).contains("Downloading: ");
}
@Test

View File

@@ -42,7 +42,7 @@ class RunCommandIntegrationTests {
CliTester cli;
RunCommandIntegrationTests(CapturedOutput output) {
this.cli = new CliTester("src/it/resources/run-command/", output);
this.cli = new CliTester("src/test/resources/run-command/", output);
}
private Properties systemProperties = new Properties();

View File

@@ -19,7 +19,6 @@ package org.springframework.boot.cli.compiler.dependencies;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.empty;
/**
* Tests for {@link SpringBootDependenciesDependencyManagement}
@@ -45,7 +44,7 @@ class SpringBootDependenciesDependencyManagementTests {
@Test
void getDependencies() {
assertThat(this.dependencyManagement.getDependencies()).isNotEqualTo(empty());
assertThat(this.dependencyManagement.getDependencies()).isNotEmpty();
}
}

View File

@@ -47,9 +47,12 @@ class AetherGrapeEngineTests {
private final GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
private final RepositoryConfiguration springMilestones = new RepositoryConfiguration("spring-milestones",
private final RepositoryConfiguration springMilestone = new RepositoryConfiguration("spring-milestone",
URI.create("https://repo.spring.io/milestone"), false);
private final RepositoryConfiguration springSnaphot = new RepositoryConfiguration("spring-snapshot",
URI.create("https://repo.spring.io/snapshot"), true);
private AetherGrapeEngine createGrapeEngine(RepositoryConfiguration... additionalRepositories) {
List<RepositoryConfiguration> repositoryConfigurations = new ArrayList<>();
repositoryConfigurations
@@ -64,7 +67,7 @@ class AetherGrapeEngineTests {
@Test
void dependencyResolution() {
Map<String, Object> args = new HashMap<>();
createGrapeEngine(this.springMilestones).grab(args,
createGrapeEngine(this.springMilestone, this.springSnaphot).grab(args,
createDependency("org.springframework", "spring-jdbc", null));
assertThat(this.groovyClassLoader.getURLs()).hasSize(5);
}
@@ -104,7 +107,7 @@ class AetherGrapeEngineTests {
Map<String, Object> args = new HashMap<>();
args.put("excludes", Arrays.asList(createExclusion("org.springframework", "spring-core")));
createGrapeEngine(this.springMilestones).grab(args,
createGrapeEngine(this.springMilestone, this.springSnaphot).grab(args,
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE"),
createDependency("org.springframework", "spring-beans", "3.2.4.RELEASE"));
@@ -126,7 +129,7 @@ class AetherGrapeEngineTests {
GroovyClassLoader customClassLoader = new GroovyClassLoader();
args.put("classLoader", customClassLoader);
createGrapeEngine(this.springMilestones).grab(args,
createGrapeEngine(this.springMilestone, this.springSnaphot).grab(args,
createDependency("org.springframework", "spring-jdbc", null));
assertThat(this.groovyClassLoader.getURLs()).isEmpty();

View File

@@ -2,7 +2,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>build/local-m2-repository</localRepository>
<mirrors>
<mirror>
<id>central-mirror</id>
@@ -10,7 +10,6 @@
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>central-mirror</id>
@@ -18,7 +17,6 @@
<password>password</password>
</server>
</servers>
<proxies>
<proxy>
<active>true</active>
@@ -29,5 +27,4 @@
<password>password</password>
</proxy>
</proxies>
</settings>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<localRepository>build/local-m2-repository</localRepository>
<profiles>
<profile>
<id>cli-test-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>local.central</id>
<url>file:build/test-repository</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshot</id>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/milestone</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>

View File

@@ -0,0 +1,10 @@
package org.test
@Component
class Example implements CommandLineRunner {
void run(String... args) {
print "Ssshh"
}
}