Reorganize integration tests
Make spring-boot-integration-tests a top level project and move the existing gradle tests and security tests to be sub-modules.
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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.util.jar.JarFile;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for installing artifacts
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class ClassifierTests {
|
||||
|
||||
private ProjectConnection project;
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@Test
|
||||
public void classifierInBootTask() throws Exception {
|
||||
this.project = new ProjectCreator().createProject("classifier");
|
||||
this.project.newBuild().forTasks("build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
checkFilesExist("classifier");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classifierInBootExtension() throws Exception {
|
||||
this.project = new ProjectCreator().createProject("classifier-extension");
|
||||
this.project.newBuild().forTasks("build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info")
|
||||
.run();
|
||||
}
|
||||
|
||||
private void checkFilesExist(String name) throws Exception {
|
||||
JarFile jar = new JarFile("target/" + name + "/build/libs/" + name + ".jar");
|
||||
assertNotNull(jar.getManifest());
|
||||
jar.close();
|
||||
jar = new JarFile("target/" + name + "/build/libs/" + name + "-exec.jar");
|
||||
assertNotNull(jar.getManifest());
|
||||
jar.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.IOException;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for custom version management
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class CustomVersionManagementTests {
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
private static ProjectConnection project;
|
||||
|
||||
@BeforeClass
|
||||
public static void createProject() throws IOException {
|
||||
project = new ProjectCreator().createProject("custom-version-management");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exclusionsAreStillInPlace() {
|
||||
project.newBuild().forTasks("checkExclusions")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customSpringVersionIsUsed() {
|
||||
project.newBuild().forTasks("checkSpringVersion")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* 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.File;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for flat directory repos
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class FlatdirTests {
|
||||
|
||||
private ProjectConnection project;
|
||||
|
||||
private File libs = new File("target/flatdir/lib");
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
if (this.libs.exists()) {
|
||||
FileSystemUtils.deleteRecursively(this.libs);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flatdir() throws Exception {
|
||||
this.project = new ProjectCreator().createProject("flatdir");
|
||||
if (!this.libs.exists()) {
|
||||
this.libs.mkdirs();
|
||||
}
|
||||
FileCopyUtils.copy(new File("src/test/resources/foo.jar"), new File(this.libs,
|
||||
"foo-1.0.0.jar"));
|
||||
this.project.newBuild().forTasks("build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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 org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for installing artifacts
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class InstallTests {
|
||||
|
||||
private ProjectConnection project;
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@Test
|
||||
public void cleanInstall() throws Exception {
|
||||
project = new ProjectCreator().createProject("installer");
|
||||
project.newBuild().forTasks("install")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanInstallVersionManagement() throws Exception {
|
||||
project = new ProjectCreator().createProject("installer-io");
|
||||
project.newBuild().forTasks("install")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanInstallApp() throws Exception {
|
||||
project = new ProjectCreator().createProject("install-app");
|
||||
// "install" from the application plugin was renamed "installApp" in Gradle
|
||||
// 1.0
|
||||
project.newBuild().forTasks("installApp")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info")
|
||||
.run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.IOException;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for installing artifacts
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class MainClassTests {
|
||||
|
||||
private static ProjectConnection project;
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@BeforeClass
|
||||
public static void createProject() throws IOException {
|
||||
project = new ProjectCreator().createProject("main-in-run");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildFromRunTask() {
|
||||
project.newBuild().forTasks("build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--info").run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.File;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for Gradle repackaging with a multi-project build.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class MultiProjectRepackagingTests {
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@Test
|
||||
public void repackageWithTransitiveFileDependency() throws Exception {
|
||||
ProjectConnection project = new ProjectCreator()
|
||||
.createProject("multi-project-transitive-file-dependency");
|
||||
project.newBuild().forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
|
||||
File buildLibs = new File(
|
||||
"target/multi-project-transitive-file-dependency/main/build/libs");
|
||||
JarFile jarFile = new JarFile(new File(buildLibs, "main.jar"));
|
||||
assertThat(jarFile.getEntry("lib/commons-logging-1.1.3.jar"), notNullValue());
|
||||
assertThat(jarFile.getEntry("lib/foo.jar"), notNullValue());
|
||||
jarFile.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackageWithCommonFileDependency() throws Exception {
|
||||
ProjectConnection project = new ProjectCreator()
|
||||
.createProject("multi-project-common-file-dependency");
|
||||
project.newBuild().forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
|
||||
File buildLibs = new File(
|
||||
"target/multi-project-common-file-dependency/build/libs");
|
||||
JarFile jarFile = new JarFile(new File(buildLibs,
|
||||
"multi-project-common-file-dependency.jar"));
|
||||
assertThat(jarFile.getEntry("lib/foo.jar"), notNullValue());
|
||||
jarFile.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackageWithRuntimeProjectDependency() throws Exception {
|
||||
ProjectConnection project = new ProjectCreator()
|
||||
.createProject("multi-project-runtime-project-dependency");
|
||||
project.newBuild().forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
|
||||
File buildLibs = new File(
|
||||
"target/multi-project-runtime-project-dependency/projectA/build/libs");
|
||||
JarFile jarFile = new JarFile(new File(buildLibs, "projectA.jar"));
|
||||
assertThat(jarFile.getEntry("lib/projectB.jar"), notNullValue());
|
||||
jarFile.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.File;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for flat directory repos
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class NoJarTests {
|
||||
|
||||
private ProjectConnection project;
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@Test
|
||||
public void nojar() throws Exception {
|
||||
this.project = new ProjectCreator().createProject("nojar");
|
||||
this.project.newBuild().forTasks("build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
assertFalse(new File("target/nojar/build/libs").exists());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gradle.tooling.GradleConnector;
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.gradle.tooling.internal.consumer.DefaultGradleConnector;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ProjectCreator {
|
||||
|
||||
private String gradleVersion;
|
||||
|
||||
public ProjectCreator() {
|
||||
this("1.12");
|
||||
}
|
||||
|
||||
public ProjectCreator(String gradleVersion) {
|
||||
this.gradleVersion = gradleVersion;
|
||||
}
|
||||
|
||||
public ProjectConnection createProject(String name) throws IOException {
|
||||
File projectDirectory = new File("target/" + name);
|
||||
projectDirectory.mkdirs();
|
||||
|
||||
File gradleScript = new File(projectDirectory, "build.gradle");
|
||||
|
||||
if (new File("src/test/resources", name).isDirectory()) {
|
||||
FileSystemUtils.copyRecursively(new File("src/test/resources", name),
|
||||
projectDirectory);
|
||||
}
|
||||
else {
|
||||
FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
|
||||
gradleScript);
|
||||
}
|
||||
|
||||
GradleConnector gradleConnector = GradleConnector.newConnector();
|
||||
gradleConnector.useGradleVersion(this.gradleVersion);
|
||||
|
||||
((DefaultGradleConnector) gradleConnector).embedded(true);
|
||||
return gradleConnector.forProjectDirectory(projectDirectory).connect();
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* 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.File;
|
||||
import java.io.IOException;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
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.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for gradle repackaging.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class RepackagingTests {
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
private static ProjectConnection project;
|
||||
|
||||
@BeforeClass
|
||||
public static void createProject() throws IOException {
|
||||
project = new ProjectCreator().createProject("repackage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackagingEnabled() {
|
||||
project.newBuild().forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
assertTrue(new File(buildLibs, "repackage.jar").exists());
|
||||
assertTrue(new File(buildLibs, "repackage.jar.original").exists());
|
||||
assertFalse(new File(buildLibs, "repackage-sources.jar.original").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackagingDisabled() {
|
||||
project.newBuild().forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false")
|
||||
.run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
assertTrue(new File(buildLibs, "repackage.jar").exists());
|
||||
assertFalse(new File(buildLibs, "repackage.jar.original").exists());
|
||||
assertFalse(new File(buildLibs, "repackage-sources.jar.original").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackagingDisabledWithCustomRepackagedJar() {
|
||||
project.newBuild().forTasks("clean", "build", "customRepackagedJar")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false")
|
||||
.run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
assertTrue(new File(buildLibs, "repackage.jar").exists());
|
||||
assertFalse(new File(buildLibs, "repackage.jar.original").exists());
|
||||
assertFalse(new File(buildLibs, "repackage-sources.jar.original").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar.original").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackagingDisabledWithCustomRepackagedJarUsingStringJarTaskReference() {
|
||||
project.newBuild()
|
||||
.forTasks("clean", "build", "customRepackagedJarWithStringReference")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false")
|
||||
.run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
assertTrue(new File(buildLibs, "repackage.jar").exists());
|
||||
assertFalse(new File(buildLibs, "repackage.jar.original").exists());
|
||||
assertFalse(new File(buildLibs, "repackage-sources.jar.original").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar.original").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackagingEnabledWithCustomRepackagedJar() {
|
||||
project.newBuild().forTasks("clean", "build", "customRepackagedJar")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
assertTrue(new File(buildLibs, "repackage.jar").exists());
|
||||
assertTrue(new File(buildLibs, "repackage.jar.original").exists());
|
||||
assertFalse(new File(buildLibs, "repackage-sources.jar.original").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar.original").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackagingEnableWithCustomRepackagedJarUsingStringJarTaskReference() {
|
||||
project.newBuild()
|
||||
.forTasks("clean", "build", "customRepackagedJarWithStringReference")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
assertTrue(new File(buildLibs, "repackage.jar").exists());
|
||||
assertTrue(new File(buildLibs, "repackage.jar.original").exists());
|
||||
assertFalse(new File(buildLibs, "repackage-sources.jar.original").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar").exists());
|
||||
assertTrue(new File(buildLibs, "custom.jar.original").exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repackageWithFileDependency() throws Exception {
|
||||
FileCopyUtils.copy(new File("src/test/resources/foo.jar"), new File(
|
||||
"target/repackage/foo.jar"));
|
||||
project.newBuild().forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
|
||||
File buildLibs = new File("target/repackage/build/libs");
|
||||
JarFile jarFile = new JarFile(new File(buildLibs, "repackage.jar"));
|
||||
assertThat(jarFile.getEntry("lib/foo.jar"), notNullValue());
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springLoadedCanBeUsedWithGradle16() throws IOException {
|
||||
ProjectConnection project = new ProjectCreator("1.6")
|
||||
.createProject("spring-loaded-old-gradle");
|
||||
project.newBuild()
|
||||
.forTasks("bootRun")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION,
|
||||
"-PspringLoadedVersion=" + SPRING_LOADED_VERSION, "--stacktrace")
|
||||
.run();
|
||||
|
||||
List<String> output = getOutput();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
/*
|
||||
* 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.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for war packaging with Gradle to ensure that only the Servlet container and its
|
||||
* dependencies are packaged in WEB-INF/lib-provided
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class WarPackagingTests {
|
||||
|
||||
private static final String WEB_INF_LIB_PROVIDED_PREFIX = "WEB-INF/lib-provided/";
|
||||
|
||||
private static final String WEB_INF_LIB_PREFIX = "WEB-INF/lib/";
|
||||
|
||||
private static final Set<String> TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED = new HashSet<String>(
|
||||
Arrays.asList("spring-boot-starter-tomcat-", "tomcat-embed-core-",
|
||||
"tomcat-embed-el-", "tomcat-embed-logging-juli-",
|
||||
"tomcat-embed-websocket-"));
|
||||
|
||||
private static final Set<String> JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED = new HashSet<String>(
|
||||
Arrays.asList("spring-boot-starter-jetty-", "jetty-util-", "jetty-xml-",
|
||||
"javax.servlet-", "jetty-continuation-", "jetty-io-", "jetty-http-",
|
||||
"jetty-server-", "jetty-security-", "jetty-servlet-",
|
||||
"jetty-webapp-", "javax.servlet.jsp-",
|
||||
"org.apache.jasper.glassfish-", "javax.servlet.jsp.jstl-",
|
||||
"org.apache.taglibs.standard.glassfish-", "javax.el-", "com.sun.el-",
|
||||
"org.eclipse.jdt.core-", "jetty-jsp-"));
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
private static ProjectConnection project;
|
||||
|
||||
@BeforeClass
|
||||
public static void createProject() throws IOException {
|
||||
project = new ProjectCreator().createProject("war-packaging");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onlyTomcatIsPackackedInWebInfLibProvided() throws IOException {
|
||||
checkWebInfEntriesForServletContainer("tomcat",
|
||||
TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onlyJettyIsPackackedInWebInfLibProvided() throws IOException {
|
||||
checkWebInfEntriesForServletContainer("jetty",
|
||||
JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
|
||||
}
|
||||
|
||||
private void checkWebInfEntriesForServletContainer(String servletContainer,
|
||||
Set<String> expectedLibProvidedEntries) throws IOException {
|
||||
project.newBuild()
|
||||
.forTasks("clean", "build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION,
|
||||
"-PservletContainer=" + servletContainer).run();
|
||||
|
||||
JarFile war = new JarFile("target/war-packaging/build/libs/war-packaging.war");
|
||||
|
||||
checkWebInfLibProvidedEntries(war, expectedLibProvidedEntries);
|
||||
|
||||
checkWebInfLibEntries(war, expectedLibProvidedEntries);
|
||||
}
|
||||
|
||||
private void checkWebInfLibProvidedEntries(JarFile war, Set<String> expectedEntries)
|
||||
throws IOException {
|
||||
Set<String> entries = getWebInfLibProvidedEntries(war);
|
||||
|
||||
assertEquals(
|
||||
"Expected " + expectedEntries.size() + " but found " + entries.size()
|
||||
+ ": " + entries, expectedEntries.size(), entries.size());
|
||||
|
||||
List<String> unexpectedLibProvidedEntries = new ArrayList<String>();
|
||||
for (String entry : entries) {
|
||||
if (!isExpectedInWebInfLibProvided(entry, expectedEntries)) {
|
||||
unexpectedLibProvidedEntries.add(entry);
|
||||
}
|
||||
}
|
||||
assertTrue("Found unexpected entries in WEB-INF/lib-provided: "
|
||||
+ unexpectedLibProvidedEntries, unexpectedLibProvidedEntries.isEmpty());
|
||||
}
|
||||
|
||||
private void checkWebInfLibEntries(JarFile war, Set<String> entriesOnlyInLibProvided)
|
||||
throws IOException {
|
||||
Set<String> entries = getWebInfLibEntries(war);
|
||||
|
||||
List<String> unexpectedLibEntries = new ArrayList<String>();
|
||||
for (String entry : entries) {
|
||||
if (!isExpectedInWebInfLib(entry, entriesOnlyInLibProvided)) {
|
||||
unexpectedLibEntries.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue("Found unexpected entries in WEB-INF/lib: " + unexpectedLibEntries,
|
||||
unexpectedLibEntries.isEmpty());
|
||||
}
|
||||
|
||||
private Set<String> getWebInfLibProvidedEntries(JarFile war) throws IOException {
|
||||
Set<String> webInfLibProvidedEntries = new HashSet<String>();
|
||||
Enumeration<JarEntry> entries = war.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
String name = entries.nextElement().getName();
|
||||
if (isWebInfLibProvidedEntry(name)) {
|
||||
webInfLibProvidedEntries.add(name);
|
||||
}
|
||||
}
|
||||
return webInfLibProvidedEntries;
|
||||
}
|
||||
|
||||
private Set<String> getWebInfLibEntries(JarFile war) throws IOException {
|
||||
Set<String> webInfLibEntries = new HashSet<String>();
|
||||
Enumeration<JarEntry> entries = war.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
String name = entries.nextElement().getName();
|
||||
if (isWebInfLibEntry(name)) {
|
||||
webInfLibEntries.add(name);
|
||||
}
|
||||
}
|
||||
return webInfLibEntries;
|
||||
}
|
||||
|
||||
private boolean isWebInfLibProvidedEntry(String name) {
|
||||
return name.startsWith(WEB_INF_LIB_PROVIDED_PREFIX)
|
||||
&& !name.equals(WEB_INF_LIB_PROVIDED_PREFIX);
|
||||
}
|
||||
|
||||
private boolean isWebInfLibEntry(String name) {
|
||||
return name.startsWith(WEB_INF_LIB_PREFIX) && !name.equals(WEB_INF_LIB_PREFIX);
|
||||
}
|
||||
|
||||
private boolean isExpectedInWebInfLibProvided(String name, Set<String> expectedEntries) {
|
||||
for (String expected : expectedEntries) {
|
||||
if (name.startsWith(WEB_INF_LIB_PROVIDED_PREFIX + expected)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isExpectedInWebInfLib(String name, Set<String> unexpectedEntries) {
|
||||
for (String unexpected : unexpectedEntries) {
|
||||
if (name.startsWith(WEB_INF_LIB_PREFIX + unexpected)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* 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.starter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.gradle.tooling.BuildException;
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
import org.springframework.boot.gradle.ProjectCreator;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests for the various starter projects to check that they don't pull in unwanted
|
||||
* transitive dependencies when used with Gradle
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class StarterDependenciesIntegrationTests {
|
||||
|
||||
private static final String STARTER_NAME_PREFIX = "spring-boot-starter";
|
||||
|
||||
private static final List<String> EXCLUDED_STARTERS = Arrays
|
||||
.asList("spring-boot-starter-parent");
|
||||
|
||||
private static ProjectConnection project;
|
||||
|
||||
private static String bootVersion;
|
||||
|
||||
private static String springVersion;
|
||||
|
||||
private final String[] buildArguments;
|
||||
|
||||
@Parameters
|
||||
public static List<String[]> getStarters() {
|
||||
List<String[]> starters = new ArrayList<String[]>();
|
||||
for (File file : new File("../spring-boot-starters").listFiles()) {
|
||||
if (file.isDirectory() && new File(file, "pom.xml").exists()) {
|
||||
String name = file.getName();
|
||||
if (name.startsWith(STARTER_NAME_PREFIX)
|
||||
&& !EXCLUDED_STARTERS.contains(file.getName())) {
|
||||
starters.add(new String[] { file.getName() });
|
||||
}
|
||||
}
|
||||
}
|
||||
return starters;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void createProject() throws IOException {
|
||||
project = new ProjectCreator().createProject("starter-dependencies");
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void determineVersions() throws Exception {
|
||||
springVersion = ManagedDependencies.get().find("spring-core").getVersion();
|
||||
bootVersion = ManagedDependencies.get().find("spring-boot").getVersion();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void closeProject() {
|
||||
project.close();
|
||||
}
|
||||
|
||||
public StarterDependenciesIntegrationTests(String starter) {
|
||||
this.buildArguments = new String[] { "-Pstarter=" + starter,
|
||||
"-PbootVersion=" + bootVersion, "-PspringVersion=" + springVersion };
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commonsLoggingIsNotATransitiveDependency() throws IOException {
|
||||
runBuildForTask("checkCommonsLogging");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oldSpringModulesAreNotTransitiveDependencies() throws IOException {
|
||||
runBuildForTask("checkSpring");
|
||||
}
|
||||
|
||||
private void runBuildForTask(String task) {
|
||||
try {
|
||||
project.newBuild().forTasks(task).withArguments(this.buildArguments).run();
|
||||
}
|
||||
catch (BuildException ex) {
|
||||
Throwable root = ex;
|
||||
while (root.getCause() != null) {
|
||||
root = root.getCause();
|
||||
}
|
||||
fail(root.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
jar {
|
||||
baseName = 'classifier-extension'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
classifier = 'exec'
|
||||
mainClass = 'demo.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework:spring-core"
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
jar {
|
||||
baseName = 'classifier'
|
||||
}
|
||||
|
||||
bootRepackage {
|
||||
classifier = 'exec'
|
||||
mainClass = 'demo.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework:spring-core"
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
exclusions
|
||||
springVersion
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
dependencies {
|
||||
exclusions "org.springframework.boot:spring-boot-starter"
|
||||
springVersion "org.springframework:spring-core"
|
||||
versionManagement files('../../src/test/resources/custom-versions.properties')
|
||||
}
|
||||
|
||||
task checkExclusions {
|
||||
doFirst {
|
||||
def commonsLogging = getResolvedDependencies(configurations.exclusions)
|
||||
.find { it.selected.id.group == 'commons-logging' }
|
||||
if (commonsLogging) {
|
||||
throw new GradleException("commong-logging is a transitive dependency")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task checkSpringVersion {
|
||||
doFirst {
|
||||
def springVersions = getResolvedDependencies(configurations.springVersion)
|
||||
.findAll{it.selected.id.group == 'org.springframework'}
|
||||
.collect {it.selected.id.version}
|
||||
if (springVersions.size() != 1 || !springVersions.contains("4.0.3.RELEASE")) {
|
||||
throw new GradleException("Spring version was not 4.0.3.RELEASE")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getResolvedDependencies(def configuration) {
|
||||
def allDependencies = configuration.incoming
|
||||
.resolutionResult.allDependencies
|
||||
.split { it instanceof UnresolvedDependencyResult }
|
||||
|
||||
def unresolved = allDependencies.first()
|
||||
def resolved = allDependencies.last()
|
||||
if (unresolved) {
|
||||
throw new GradleException("Resolution failed: ${unresolved}")
|
||||
}
|
||||
resolved
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
org.springframework\:spring-core=4.0.3.RELEASE
|
||||
org.springframework.boot\:spring-boot-starter=1.1.0.RELEASE
|
||||
@@ -1,29 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'flatdir'
|
||||
version = '0.0.0'
|
||||
|
||||
run {
|
||||
main = 'Foo'
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName = 'flatdir'
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir( dirs:'lib' )
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile ':foo:1.0.0'
|
||||
}
|
||||
Binary file not shown.
@@ -1,32 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'installer'
|
||||
version = '0.0.0'
|
||||
|
||||
run {
|
||||
main = 'org.springframework.boot.SpringApplication'
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName = 'install-app'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework.boot:spring-boot-starter"
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'installer'
|
||||
version = '0.0.0'
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.project {
|
||||
parent {
|
||||
groupId 'org.springframework.boot'
|
||||
artifactId 'spring-boot-starter-parent'
|
||||
version "${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName = 'installer'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
versionManagement 'io.spring.platform:platform-versions:1.0.0.RELEASE@properties'
|
||||
compile "org.springframework.boot:spring-boot-starter"
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'installer'
|
||||
version = '0.0.0'
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.project {
|
||||
parent {
|
||||
groupId 'org.springframework.boot'
|
||||
artifactId 'spring-boot-starter-parent'
|
||||
version "${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName = 'installer'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework.boot:spring-boot-starter"
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'installer'
|
||||
version = '0.0.0'
|
||||
|
||||
run {
|
||||
main = 'org.springframework.boot.SpringApplication'
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName = 'installer'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework.boot:spring-boot-starter"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
|
||||
dependencies {
|
||||
compile rootProject.files {'lib/foo.jar'}
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
springBoot {
|
||||
mainClass = 'foo.bar.Baz'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':one')
|
||||
compile project(':two')
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
|
||||
include 'one'
|
||||
include 'two'
|
||||
@@ -1,22 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
project(':projectA') {
|
||||
apply plugin: 'spring-boot'
|
||||
dependencies {
|
||||
runtime project(':projectB')
|
||||
}
|
||||
bootRepackage {
|
||||
mainClass 'com.foo.Bar'
|
||||
}
|
||||
}
|
||||
|
||||
project(':projectB') {
|
||||
apply plugin: 'java'
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
include 'projectA', 'projectB'
|
||||
@@ -1,40 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
project('main') {
|
||||
apply plugin: 'spring-boot'
|
||||
apply plugin: 'java'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':common')
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = 'foo.bar.Baz'
|
||||
}
|
||||
}
|
||||
|
||||
project('common') {
|
||||
apply plugin: 'java'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "commons-logging:commons-logging:1.1.3"
|
||||
compile files { "lib/foo.jar" }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
|
||||
include 'main'
|
||||
include 'common'
|
||||
@@ -1,30 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'nojar'
|
||||
version = '0.0.0'
|
||||
|
||||
jar {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
bootRepackage {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.springframework.boot:spring-boot-starter'
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
apply plugin: 'java'
|
||||
|
||||
dependencies {
|
||||
compile 'org.springframework.boot:spring-boot-starter-freemarker'
|
||||
compile 'org.springframework.boot:spring-boot-starter-web'
|
||||
compile files("foo.jar")
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = 'foo.bar.Baz'
|
||||
}
|
||||
|
||||
bootRepackage.enabled = Boolean.valueOf(project.repackage)
|
||||
|
||||
task customJar(type: Jar) {
|
||||
archiveName = 'custom.jar'
|
||||
from sourceSets.main.output
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
task customRepackagedJar(type: BootRepackage, dependsOn: customJar) {
|
||||
withJarTask = customJar
|
||||
}
|
||||
|
||||
task customRepackagedJarWithStringReference(type: BootRepackage, dependsOn: customJar) {
|
||||
withJarTask = 'customJar'
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
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'
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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 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();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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")
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName = 'spring-loaded-old-gradle'
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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 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();
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
springBootStarter
|
||||
}
|
||||
|
||||
dependencies {
|
||||
springBootStarter "org.springframework.boot:${project.starter}:${project.bootVersion}"
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
task checkCommonsLogging {
|
||||
doFirst {
|
||||
def commonsLogging = resolvedDependencies
|
||||
.find { it.selected.id.group == 'commons-logging' }
|
||||
if (commonsLogging) {
|
||||
throw new GradleException("${project.starter} pulls in commons-logging")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task checkSpring {
|
||||
doFirst {
|
||||
def wrongSpring = resolvedDependencies
|
||||
.findAll{it.selected.id.group == 'org.springframework'}
|
||||
.findAll{it.selected.id.version != project.springVersion}
|
||||
.collect {it.selected.id}
|
||||
if (wrongSpring) {
|
||||
throw new GradleException("${project.starter} pulled in ${wrongSpring as Set}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getResolvedDependencies() {
|
||||
def allDependencies = configurations.springBootStarter.incoming
|
||||
.resolutionResult.allDependencies
|
||||
.split { it instanceof UnresolvedDependencyResult }
|
||||
|
||||
def unresolved = allDependencies.first()
|
||||
def resolved = allDependencies.last()
|
||||
if (unresolved) {
|
||||
throw new GradleException("Resolution of ${project.starter} failed: ${unresolved}")
|
||||
}
|
||||
resolved
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'spring-boot'
|
||||
apply plugin: 'war'
|
||||
|
||||
dependencies {
|
||||
compile 'org.springframework.boot:spring-boot-starter-freemarker'
|
||||
providedRuntime "org.springframework.boot:spring-boot-starter-$servletContainer"
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = 'foo.bar.Baz'
|
||||
}
|
||||
Reference in New Issue
Block a user