Merge branch '1.1.x'

pull/1442/merge
Andy Wilkinson 10 years ago
commit 2ed24ddcd5

@ -24,7 +24,6 @@ import org.gradle.tooling.ProjectConnection;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.boot.dependency.tools.ManagedDependencies;
import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
@ -48,10 +47,8 @@ public class MultiProjectRepackagingTests {
@Test
public void repackageWithTransitiveFileDependency() throws Exception {
FileCopyUtils.copy(new File("src/test/resources/foo.jar"), new File(
"target/multi-project-repackage/foo.jar"));
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
File buildLibs = new File("target/multi-project-repackage/main/build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, "main.jar"));
assertThat(jarFile.getEntry("lib/commons-logging-1.1.3.jar"), notNullValue());

@ -46,6 +46,8 @@ public class ProjectCreator {
}
GradleConnector gradleConnector = GradleConnector.newConnector();
gradleConnector.useGradleVersion("1.12");
((DefaultGradleConnector) gradleConnector).embedded(true);
return gradleConnector.forProjectDirectory(projectDirectory).connect();
}

@ -0,0 +1,98 @@
/*
* Copyright 2012-2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.gradle;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.gradle.tooling.ProjectConnection;
import org.junit.Test;
import org.springframework.boot.dependency.tools.ManagedDependencies;
import static org.junit.Assert.fail;
/**
* Integration tests for the Gradle plugin's Spring Loaded support
*
* @author Andy Wilkinson
*/
public class SpringLoadedTests {
private static final String BOOT_VERSION = ManagedDependencies.get()
.find("spring-boot").getVersion();
private static final String SPRING_LOADED_VERSION = ManagedDependencies.get()
.find("springloaded").getVersion();
@Test
public void defaultJvmArgsArePreservedWhenLoadedAgentIsConfigured()
throws IOException {
ProjectConnection project = new ProjectCreator()
.createProject("spring-loaded-jvm-args");
project.newBuild()
.forTasks("bootRun")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PspringLoadedVersion=" + SPRING_LOADED_VERSION, "--stacktrace")
.run();
List<String> output = getOutput();
assertOutputContains("-DSOME_ARG=someValue", output);
assertOutputContains("-Xverify:none", output);
assertOutputMatches(
"-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar", output);
}
private List<String> getOutput() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(new File(
"target/spring-loaded-jvm-args/build/output.txt")));
try {
List<String> lines = new ArrayList<String>();
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
return lines;
}
finally {
reader.close();
}
}
private void assertOutputContains(String requiredOutput, List<String> actualOutput) {
for (String line : actualOutput) {
if (line.equals(requiredOutput)) {
return;
}
}
fail("Required output '" + requiredOutput + "' not found in " + actualOutput);
}
private void assertOutputMatches(String requiredPattern, List<String> actualOutput) {
for (String line : actualOutput) {
if (line.matches(requiredPattern)) {
return;
}
}
fail("Required pattern '" + requiredPattern + "' not matched in " + actualOutput);
}
}

@ -0,0 +1,30 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
classpath("org.springframework:springloaded:${project.springLoadedVersion}")
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter")
}
applicationDefaultJvmArgs = [
"-DSOME_ARG=someValue"
]
jar {
baseName = 'spring-loaded-jvm-args'
}

@ -0,0 +1,25 @@
package test;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
public class Application {
public static void main(String[] args) throws Exception {
PrintWriter writer = new PrintWriter(new FileWriter(new File("build/output.txt")));
for (String argument: ManagementFactory.getRuntimeMXBean().getInputArguments()) {
writer.println(argument);
}
writer.close();
}
}

@ -108,6 +108,11 @@ public class AgentTasksEnhancer implements Action<Project> {
if (this.noverify != null && this.noverify) {
exec.jvmArgs("-noverify");
}
Iterable<?> defaultJvmArgs = exec.getConventionMapping().getConventionValue(
null, "jvmArgs", false);
if (defaultJvmArgs != null) {
exec.jvmArgs(defaultJvmArgs);
}
}
}

Loading…
Cancel
Save