Port the build to Gradle
Closes gh-19609 Closes gh-19608
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.assertj;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AssertProvider;
|
||||
import org.assertj.core.api.StringAssert;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* AssertJ {@link AssertProvider} for {@link Node} assertions.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class NodeAssert extends AbstractAssert<NodeAssert, Node> implements AssertProvider<NodeAssert> {
|
||||
|
||||
private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();
|
||||
|
||||
private final XPathFactory xpathFactory = XPathFactory.newInstance();
|
||||
|
||||
private final XPath xpath = this.xpathFactory.newXPath();
|
||||
|
||||
public NodeAssert(File xmlFile) {
|
||||
this(read(xmlFile));
|
||||
}
|
||||
|
||||
public NodeAssert(Node actual) {
|
||||
super(actual, NodeAssert.class);
|
||||
}
|
||||
|
||||
private static Document read(File xmlFile) {
|
||||
try {
|
||||
return FACTORY.newDocumentBuilder().parse(xmlFile);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public NodeAssert nodeAtPath(String xpath) {
|
||||
try {
|
||||
return new NodeAssert((Node) this.xpath.evaluate(xpath, this.actual, XPathConstants.NODE));
|
||||
}
|
||||
catch (XPathExpressionException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public StringAssert textAtPath(String xpath) {
|
||||
try {
|
||||
return new StringAssert(
|
||||
(String) this.xpath.evaluate(xpath + "/text()", this.actual, XPathConstants.STRING));
|
||||
}
|
||||
catch (XPathExpressionException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeAssert assertThat() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.bom;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.GradleRunner;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import org.springframework.boot.build.DeployedPlugin;
|
||||
import org.springframework.boot.build.assertj.NodeAssert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link BomPlugin}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class BomPluginIntegrationTests {
|
||||
|
||||
private File projectDir;
|
||||
|
||||
private File buildFile;
|
||||
|
||||
@BeforeEach
|
||||
public void setup(@TempDir File projectDir) throws IOException {
|
||||
this.projectDir = projectDir;
|
||||
this.buildFile = new File(this.projectDir, "build.gradle");
|
||||
}
|
||||
|
||||
@Test
|
||||
void libraryModulesAreIncludedInDependencyManagementOfGeneratedPom() throws IOException {
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
|
||||
out.println("plugins {");
|
||||
out.println(" id 'org.springframework.boot.bom'");
|
||||
out.println("}");
|
||||
out.println("bom {");
|
||||
out.println(" library('ActiveMQ', '5.15.10') {");
|
||||
out.println(" group('org.apache.activemq') {");
|
||||
out.println(" modules = [");
|
||||
out.println(" 'activemq-amqp',");
|
||||
out.println(" 'activemq-blueprint'");
|
||||
out.println(" ]");
|
||||
out.println(" }");
|
||||
out.println(" }");
|
||||
out.println("}");
|
||||
}
|
||||
generatePom((pom) -> {
|
||||
assertThat(pom).textAtPath("//properties/activemq.version").isEqualTo("5.15.10");
|
||||
NodeAssert dependency = pom.nodeAtPath("//dependencyManagement/dependencies/dependency[1]");
|
||||
assertThat(dependency).textAtPath("groupId").isEqualTo("org.apache.activemq");
|
||||
assertThat(dependency).textAtPath("artifactId").isEqualTo("activemq-amqp");
|
||||
assertThat(dependency).textAtPath("version").isEqualTo("${activemq.version}");
|
||||
assertThat(dependency).textAtPath("scope").isNullOrEmpty();
|
||||
assertThat(dependency).textAtPath("type").isNullOrEmpty();
|
||||
dependency = pom.nodeAtPath("//dependencyManagement/dependencies/dependency[2]");
|
||||
assertThat(dependency).textAtPath("groupId").isEqualTo("org.apache.activemq");
|
||||
assertThat(dependency).textAtPath("artifactId").isEqualTo("activemq-blueprint");
|
||||
assertThat(dependency).textAtPath("version").isEqualTo("${activemq.version}");
|
||||
assertThat(dependency).textAtPath("scope").isNullOrEmpty();
|
||||
assertThat(dependency).textAtPath("type").isNullOrEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void libraryPluginsAreIncludedInPluginManagementOfGeneratedPom() throws IOException {
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
|
||||
out.println("plugins {");
|
||||
out.println(" id 'org.springframework.boot.bom'");
|
||||
out.println("}");
|
||||
out.println("bom {");
|
||||
out.println(" library('Flyway', '6.0.8') {");
|
||||
out.println(" group('org.flywaydb') {");
|
||||
out.println(" plugins = [");
|
||||
out.println(" 'flyway-maven-plugin'");
|
||||
out.println(" ]");
|
||||
out.println(" }");
|
||||
out.println(" }");
|
||||
out.println("}");
|
||||
}
|
||||
generatePom((pom) -> {
|
||||
assertThat(pom).textAtPath("//properties/flyway.version").isEqualTo("6.0.8");
|
||||
NodeAssert plugin = pom.nodeAtPath("//pluginManagement/plugins/plugin");
|
||||
assertThat(plugin).textAtPath("groupId").isEqualTo("org.flywaydb");
|
||||
assertThat(plugin).textAtPath("artifactId").isEqualTo("flyway-maven-plugin");
|
||||
assertThat(plugin).textAtPath("version").isEqualTo("${flyway.version}");
|
||||
assertThat(plugin).textAtPath("scope").isNullOrEmpty();
|
||||
assertThat(plugin).textAtPath("type").isNullOrEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void libraryImportsAreIncludedInDependencyManagementOfGeneratedPom() throws Exception {
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
|
||||
out.println("plugins {");
|
||||
out.println(" id 'org.springframework.boot.bom'");
|
||||
out.println("}");
|
||||
out.println("bom {");
|
||||
out.println(" library('Jackson Bom', '2.10.0') {");
|
||||
out.println(" group('com.fasterxml.jackson') {");
|
||||
out.println(" imports = [");
|
||||
out.println(" 'jackson-bom'");
|
||||
out.println(" ]");
|
||||
out.println(" }");
|
||||
out.println(" }");
|
||||
out.println("}");
|
||||
}
|
||||
generatePom((pom) -> {
|
||||
assertThat(pom).textAtPath("//properties/jackson-bom.version").isEqualTo("2.10.0");
|
||||
NodeAssert dependency = pom.nodeAtPath("//dependencyManagement/dependencies/dependency");
|
||||
assertThat(dependency).textAtPath("groupId").isEqualTo("com.fasterxml.jackson");
|
||||
assertThat(dependency).textAtPath("artifactId").isEqualTo("jackson-bom");
|
||||
assertThat(dependency).textAtPath("version").isEqualTo("${jackson-bom.version}");
|
||||
assertThat(dependency).textAtPath("scope").isEqualTo("import");
|
||||
assertThat(dependency).textAtPath("type").isEqualTo("pom");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void moduleExclusionsAreIncludedInDependencyManagementOfGeneratedPom() throws IOException {
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
|
||||
out.println("plugins {");
|
||||
out.println(" id 'org.springframework.boot.bom'");
|
||||
out.println("}");
|
||||
out.println("bom {");
|
||||
out.println(" library('MySQL', '8.0.18') {");
|
||||
out.println(" group('mysql') {");
|
||||
out.println(" modules = [");
|
||||
out.println(" 'mysql-connector-java' {");
|
||||
out.println(" exclude group: 'com.google.protobuf', module: 'protobuf-java'");
|
||||
out.println(" }");
|
||||
out.println(" ]");
|
||||
out.println(" }");
|
||||
out.println(" }");
|
||||
out.println("}");
|
||||
}
|
||||
generatePom((pom) -> {
|
||||
assertThat(pom).textAtPath("//properties/mysql.version").isEqualTo("8.0.18");
|
||||
NodeAssert dependency = pom.nodeAtPath("//dependencyManagement/dependencies/dependency");
|
||||
assertThat(dependency).textAtPath("groupId").isEqualTo("mysql");
|
||||
assertThat(dependency).textAtPath("artifactId").isEqualTo("mysql-connector-java");
|
||||
assertThat(dependency).textAtPath("version").isEqualTo("${mysql.version}");
|
||||
assertThat(dependency).textAtPath("scope").isNullOrEmpty();
|
||||
assertThat(dependency).textAtPath("type").isNullOrEmpty();
|
||||
NodeAssert exclusion = dependency.nodeAtPath("exclusions/exclusion");
|
||||
assertThat(exclusion).textAtPath("groupId").isEqualTo("com.google.protobuf");
|
||||
assertThat(exclusion).textAtPath("artifactId").isEqualTo("protobuf-java");
|
||||
});
|
||||
}
|
||||
|
||||
private BuildResult runGradle(String... args) {
|
||||
return GradleRunner.create().withDebug(true).withProjectDir(this.projectDir).withArguments(args)
|
||||
.withPluginClasspath().build();
|
||||
}
|
||||
|
||||
private void generatePom(Consumer<NodeAssert> consumer) {
|
||||
runGradle(DeployedPlugin.GENERATE_POM_TASK_NAME, "-s");
|
||||
File generatedPomXml = new File(this.projectDir, "build/publications/maven/pom-default.xml");
|
||||
try (Reader reader = new FileReader(generatedPomXml)) {
|
||||
System.out.println(FileCopyUtils.copyToString(reader));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
||||
}
|
||||
assertThat(generatedPomXml).isFile();
|
||||
consumer.accept(new NodeAssert(generatedPomXml));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.bom.bomr.version;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ArtifactVersionDependencyVersion}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ArtifactVersionDependencyVersionTests {
|
||||
|
||||
@Test
|
||||
void parseWhenVersionIsNotAMavenVersionShouldReturnNull() {
|
||||
assertThat(version("1.2.3.1")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenVersionIsAMavenVersionShouldReturnAVersion() {
|
||||
assertThat(version("1.2.3")).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenInputIsOlderMajorShouldReturnTrue() {
|
||||
assertThat(version("2.1.2").isNewerThan(version("1.9.0"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenInputIsOlderMinorShouldReturnTrue() {
|
||||
assertThat(version("2.1.2").isNewerThan(version("2.0.2"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenInputIsOlderPatchShouldReturnTrue() {
|
||||
assertThat(version("2.1.2").isNewerThan(version("2.1.1"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenInputIsNewerMajorShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isNewerThan(version("3.2.1"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenMinorIsOlderShouldReturnTrue() {
|
||||
assertThat(version("1.10.2").isSameMajorAndNewerThan(version("1.9.0"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenMajorIsOlderShouldReturnFalse() {
|
||||
assertThat(version("2.0.2").isSameMajorAndNewerThan(version("1.9.0"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenPatchIsNewerShouldReturnTrue() {
|
||||
assertThat(version("2.1.2").isSameMajorAndNewerThan(version("2.1.1"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenMinorIsNewerShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isSameMajorAndNewerThan(version("2.2.1"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenMajorIsNewerShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isSameMajorAndNewerThan(version("3.0.1"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenPatchIsOlderShouldReturnTrue() {
|
||||
assertThat(version("1.10.2").isSameMinorAndNewerThan(version("1.10.1"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenMinorIsOlderShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isSameMinorAndNewerThan(version("2.0.1"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenVersionsAreTheSameShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isSameMinorAndNewerThan(version("2.1.2"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenPatchIsNewerShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isSameMinorAndNewerThan(version("2.1.3"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenMinorIsNewerShouldReturnFalse() {
|
||||
assertThat(version("2.1.2").isSameMinorAndNewerThan(version("2.0.1"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenMajorIsNewerShouldReturnFalse() {
|
||||
assertThat(version("3.1.2").isSameMinorAndNewerThan(version("2.0.1"))).isFalse();
|
||||
}
|
||||
|
||||
private ArtifactVersionDependencyVersion version(String version) {
|
||||
return ArtifactVersionDependencyVersion.parse(version);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.bom.bomr.version;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link DependencyVersion}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class DependencyVersionTests {
|
||||
|
||||
@Test
|
||||
void parseWhenValidMavenVersionShouldReturnArtifactVersionDependencyVersion() {
|
||||
assertThat(DependencyVersion.parse("1.2.3.Final")).isInstanceOf(ArtifactVersionDependencyVersion.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenReleaseTrainShouldReturnReleaseTrainDependencyVersion() {
|
||||
assertThat(DependencyVersion.parse("Ingalls-SR5")).isInstanceOf(ReleaseTrainDependencyVersion.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenMavenLikeVersionWithNumericQualifieShouldReturnNumericQualifierDependencyVersion() {
|
||||
assertThat(DependencyVersion.parse("1.2.3.4")).isInstanceOf(NumericQualifierDependencyVersion.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenVersionWithLeadingZeroesShouldReturnLeadingZeroesDependencyVersion() {
|
||||
assertThat(DependencyVersion.parse("1.4.01")).isInstanceOf(LeadingZeroesDependencyVersion.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenVersionWithCombinedPatchAndQualifierShouldReturnCombinedPatchAndQualifierDependencyVersion() {
|
||||
assertThat(DependencyVersion.parse("4.0.0M4")).isInstanceOf(CombinedPatchAndQualifierDependencyVersion.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.bom.bomr.version;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link NumericQualifierDependencyVersion}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class NumericQualifierDependencyVersionTests {
|
||||
|
||||
@Test
|
||||
void isNewerThanOnVersionWithNumericQualifierWhenInputHasNoQualifierShouldReturnTrue() {
|
||||
assertThat(version("2.9.9.20190806").isNewerThan(DependencyVersion.parse("2.9.9"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanOnVersionWithNumericQualifierWhenInputHasOlderQualifierShouldReturnTrue() {
|
||||
assertThat(version("2.9.9.20190806").isNewerThan(version("2.9.9.20190805"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanOnVersionWithNumericQualifierWhenInputHasNewerQualifierShouldReturnFalse() {
|
||||
assertThat(version("2.9.9.20190806").isNewerThan(version("2.9.9.20190807"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanOnVersionWithNumericQualifierWhenInputHasSameQualifierShouldReturnFalse() {
|
||||
assertThat(version("2.9.9.20190806").isNewerThan(version("2.9.9.20190806"))).isFalse();
|
||||
}
|
||||
|
||||
private NumericQualifierDependencyVersion version(String version) {
|
||||
return NumericQualifierDependencyVersion.parse(version);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.bom.bomr.version;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ReleaseTrainDependencyVersion}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ReleaseTrainDependencyVersionTests {
|
||||
|
||||
@Test
|
||||
void parsingOfANonReleaseTrainVersionReturnsNull() {
|
||||
assertThat(version("5.1.4.RELEASE")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsingOfAReleaseTrainVersionReturnsVersion() {
|
||||
assertThat(version("Lovelace-SR3")).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenReleaseTrainIsNewerShouldReturnTrue() {
|
||||
assertThat(version("Lovelace-RELEASE").isNewerThan(version("Kay-SR5"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenVersionIsNewerShouldReturnTrue() {
|
||||
assertThat(version("Kay-SR10").isNewerThan(version("Kay-SR5"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenVersionIsOlderShouldReturnFalse() {
|
||||
assertThat(version("Kay-RELEASE").isNewerThan(version("Kay-SR5"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNewerThanWhenReleaseTrainIsOlderShouldReturnFalse() {
|
||||
assertThat(version("Ingalls-RELEASE").isNewerThan(version("Kay-SR5"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerWhenWhenReleaseTrainIsNewerShouldReturnTrue() {
|
||||
assertThat(version("Lovelace-RELEASE").isSameMajorAndNewerThan(version("Kay-SR5"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenReleaseTrainIsOlderShouldReturnFalse() {
|
||||
assertThat(version("Ingalls-RELEASE").isSameMajorAndNewerThan(version("Kay-SR5"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMajorAndNewerThanWhenVersionIsNewerShouldReturnTrue() {
|
||||
assertThat(version("Kay-SR6").isSameMajorAndNewerThan(version("Kay-SR5"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenReleaseTrainIsNewerShouldReturnFalse() {
|
||||
assertThat(version("Lovelace-RELEASE").isSameMinorAndNewerThan(version("Kay-SR5"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenReleaseTrainIsTheSameAndVersionIsNewerShouldReturnTrue() {
|
||||
assertThat(version("Kay-SR6").isSameMinorAndNewerThan(version("Kay-SR5"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenReleaseTrainAndVersionAreTheSameShouldReturnFalse() {
|
||||
assertThat(version("Kay-SR6").isSameMinorAndNewerThan(version("Kay-SR6"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSameMinorAndNewerThanWhenReleaseTrainIsTheSameAndVersionIsOlderShouldReturnFalse() {
|
||||
assertThat(version("Kay-SR6").isSameMinorAndNewerThan(version("Kay-SR7"))).isFalse();
|
||||
}
|
||||
|
||||
private static ReleaseTrainDependencyVersion version(String input) {
|
||||
return ReleaseTrainDependencyVersion.parse(input);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.context.properties;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompoundConfigurationTableEntry}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class CompoundConfigurationTableEntryTests {
|
||||
|
||||
private static String NEWLINE = System.lineSeparator();
|
||||
|
||||
@Test
|
||||
void simpleProperty() {
|
||||
ConfigurationProperty firstProp = new ConfigurationProperty("spring.test.first", "java.lang.String");
|
||||
ConfigurationProperty secondProp = new ConfigurationProperty("spring.test.second", "java.lang.String");
|
||||
ConfigurationProperty thirdProp = new ConfigurationProperty("spring.test.third", "java.lang.String");
|
||||
CompoundConfigurationTableEntry entry = new CompoundConfigurationTableEntry("spring.test",
|
||||
"This is a description.");
|
||||
entry.addConfigurationKeys(firstProp, secondProp, thirdProp);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|`+spring.test.first+` +" + NEWLINE + "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +"
|
||||
+ NEWLINE + NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.context.properties;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConfigurationTable}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class ConfigurationTableTests {
|
||||
|
||||
private static String NEWLINE = System.lineSeparator();
|
||||
|
||||
@Test
|
||||
void simpleTable() {
|
||||
ConfigurationTable table = new ConfigurationTable("test");
|
||||
ConfigurationProperty first = new ConfigurationProperty("spring.test.prop", "java.lang.String", "something",
|
||||
"This is a description.", false);
|
||||
ConfigurationProperty second = new ConfigurationProperty("spring.test.other", "java.lang.String", "other value",
|
||||
"This is another description.", false);
|
||||
table.addEntry(new SingleConfigurationTableEntry(first));
|
||||
table.addEntry(new SingleConfigurationTableEntry(second));
|
||||
assertThat(table.toAsciidocTable()).isEqualTo("[cols=\"1,1,2\", options=\"header\"]" + NEWLINE + "|==="
|
||||
+ NEWLINE + "|Key|Default Value|Description" + NEWLINE + NEWLINE + "|`+spring.test.other+`" + NEWLINE
|
||||
+ "|`+other value+`" + NEWLINE + "|+++This is another description.+++" + NEWLINE + NEWLINE
|
||||
+ "|`+spring.test.prop+`" + NEWLINE + "|`+something+`" + NEWLINE + "|+++This is a description.+++"
|
||||
+ NEWLINE + NEWLINE + "|===" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.context.properties;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SingleConfigurationTableEntry}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class SingleConfigurationTableEntryTests {
|
||||
|
||||
private static String NEWLINE = System.lineSeparator();
|
||||
|
||||
@Test
|
||||
void simpleProperty() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String", "something",
|
||||
"This is a description.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+something+`" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noDefaultValue() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String", null,
|
||||
"This is a description.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultValueWithPipes() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String",
|
||||
"first|second", "This is a description.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first\\|second+`" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultValueWithBackslash() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String",
|
||||
"first\\second", "This is a description.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first\\\\second+`" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void descriptionWithPipe() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop", "java.lang.String", null,
|
||||
"This is a description with a | pipe.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE
|
||||
+ "|+++This is a description with a \\| pipe.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapProperty() {
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop",
|
||||
"java.util.Map<java.lang.String,java.lang.String>", null, "This is a description.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|`+spring.test.prop.*+`" + NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void listProperty() {
|
||||
String[] defaultValue = new String[] { "first", "second", "third" };
|
||||
ConfigurationProperty property = new ConfigurationProperty("spring.test.prop",
|
||||
"java.util.List<java.lang.String>", defaultValue, "This is a description.", false);
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first," + NEWLINE + "second,"
|
||||
+ NEWLINE + "third+`" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* https://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.build.log4j2;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.logging.log4j.core.config.plugins.processor.PluginCache;
|
||||
import org.apache.logging.log4j.core.config.plugins.processor.PluginEntry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ReproducibleLog4j2PluginsDatAction}
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ReproduciblePluginsDatActionTests {
|
||||
|
||||
@Test
|
||||
void postProcessingOrdersCategoriesAndPlugins() throws IOException {
|
||||
Path datFile = Files.createTempFile("Log4j2Plugins", "dat");
|
||||
try {
|
||||
write(datFile);
|
||||
PluginCache cache = new PluginCache();
|
||||
cache.loadCacheFiles(new Vector<>(Arrays.asList(datFile.toUri().toURL())).elements());
|
||||
assertThat(cache.getAllCategories().keySet()).containsExactly("one", "two");
|
||||
assertThat(cache.getCategory("one").keySet()).containsExactly("alpha", "bravo", "charlie");
|
||||
assertThat(cache.getCategory("two").keySet()).containsExactly("delta", "echo", "foxtrot");
|
||||
}
|
||||
finally {
|
||||
Files.delete(datFile);
|
||||
}
|
||||
}
|
||||
|
||||
private void write(Path datFile) throws IOException {
|
||||
PluginCache cache = new PluginCache();
|
||||
createCategory(cache, "two", Arrays.asList("delta", "foxtrot", "echo"));
|
||||
createCategory(cache, "one", Arrays.asList("bravo", "alpha", "charlie"));
|
||||
try (OutputStream output = new FileOutputStream(datFile.toFile())) {
|
||||
cache.writeCache(output);
|
||||
new ReproducibleLog4j2PluginsDatAction().postProcess(datFile.toFile());
|
||||
}
|
||||
}
|
||||
|
||||
private void createCategory(PluginCache cache, String categoryName, List<String> entryNames) {
|
||||
Map<String, PluginEntry> category = cache.getCategory(categoryName);
|
||||
for (String entryName : entryNames) {
|
||||
PluginEntry entry = new PluginEntry();
|
||||
entry.setKey(entryName);
|
||||
entry.setClassName("com.example.Plugin");
|
||||
entry.setName("name");
|
||||
entry.setCategory(categoryName);
|
||||
category.put(entryName, entry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* https://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.build.mavenplugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.build.mavenplugin.PluginXmlParser.Plugin;
|
||||
|
||||
/**
|
||||
* Tests for {@link PluginXmlParser}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class PluginXmlParserTests {
|
||||
|
||||
private final PluginXmlParser parser = new PluginXmlParser();
|
||||
|
||||
@Test
|
||||
void dunno() {
|
||||
Plugin plugin = this.parser.parse(new File("src/test/resources/plugin.xml"));
|
||||
System.out.println(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2012-2020 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
|
||||
*
|
||||
* https://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.build.optional;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.GradleRunner;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link OptionalDependenciesPlugin}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class OptionalDependenciesPluginIntegrationTests {
|
||||
|
||||
private File projectDir;
|
||||
|
||||
private File buildFile;
|
||||
|
||||
@BeforeEach
|
||||
public void setup(@TempDir File projectDir) throws IOException {
|
||||
this.projectDir = projectDir;
|
||||
this.buildFile = new File(this.projectDir, "build.gradle");
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalConfigurationIsCreated() throws IOException {
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
|
||||
out.println("plugins { id 'org.springframework.boot.optional-dependencies' }");
|
||||
out.println("task printConfigurations {");
|
||||
out.println(" doLast {");
|
||||
out.println(" configurations.all { println it.name }");
|
||||
out.println(" }");
|
||||
out.println("}");
|
||||
}
|
||||
BuildResult buildResult = runGradle("printConfigurations");
|
||||
assertThat(buildResult.getOutput()).contains("optional");
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalDependenciesAreAddedToMainSourceSetsCompileClasspath() throws IOException {
|
||||
optionalDependenciesAreAddedToSourceSetClasspath("main", "compileClasspath");
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalDependenciesAreAddedToMainSourceSetsRuntimeClasspath() throws IOException {
|
||||
optionalDependenciesAreAddedToSourceSetClasspath("main", "runtimeClasspath");
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalDependenciesAreAddedToTestSourceSetsCompileClasspath() throws IOException {
|
||||
optionalDependenciesAreAddedToSourceSetClasspath("test", "compileClasspath");
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalDependenciesAreAddedToTestSourceSetsRuntimeClasspath() throws IOException {
|
||||
optionalDependenciesAreAddedToSourceSetClasspath("test", "runtimeClasspath");
|
||||
}
|
||||
|
||||
public void optionalDependenciesAreAddedToSourceSetClasspath(String sourceSet, String classpath)
|
||||
throws IOException {
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
|
||||
out.println("plugins {");
|
||||
out.println(" id 'org.springframework.boot.optional-dependencies'");
|
||||
out.println(" id 'java'");
|
||||
out.println("}");
|
||||
out.println("repositories {");
|
||||
out.println(" mavenCentral()");
|
||||
out.println("}");
|
||||
out.println("dependencies {");
|
||||
out.println(" optional 'org.springframework:spring-jcl:5.1.2.RELEASE'");
|
||||
out.println("}");
|
||||
out.println("task printClasspath {");
|
||||
out.println(" doLast {");
|
||||
out.println(" println sourceSets." + sourceSet + "." + classpath + ".files");
|
||||
out.println(" }");
|
||||
out.println("}");
|
||||
}
|
||||
BuildResult buildResult = runGradle("printClasspath");
|
||||
assertThat(buildResult.getOutput()).contains("spring-jcl");
|
||||
}
|
||||
|
||||
private BuildResult runGradle(String... args) {
|
||||
return GradleRunner.create().withProjectDir(this.projectDir).withArguments(args).withPluginClasspath().build();
|
||||
}
|
||||
|
||||
}
|
||||
911
buildSrc/src/test/resources/plugin.xml
Normal file
911
buildSrc/src/test/resources/plugin.xml
Normal file
@@ -0,0 +1,911 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- Generated by maven-plugin-tools 3.6 -->
|
||||
|
||||
<plugin>
|
||||
<name>Spring Boot Maven Plugin</name>
|
||||
<description></description>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.2.0.GRADLE-SNAPSHOT</version>
|
||||
<goalPrefix>spring-boot</goalPrefix>
|
||||
<isolatedRealm>false</isolatedRealm>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<mojos>
|
||||
<mojo>
|
||||
<goal>build-info</goal>
|
||||
<description>Generate a {@code build-info.properties} file based the content of the current
|
||||
{@link MavenProject}.</description>
|
||||
<requiresDirectInvocation>false</requiresDirectInvocation>
|
||||
<requiresProject>true</requiresProject>
|
||||
<requiresReports>false</requiresReports>
|
||||
<aggregator>false</aggregator>
|
||||
<requiresOnline>false</requiresOnline>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<phase>generate-resources</phase>
|
||||
<implementation>org.springframework.boot.maven.BuildInfoMojo</implementation>
|
||||
<language>java</language>
|
||||
<instantiationStrategy>per-lookup</instantiationStrategy>
|
||||
<executionStrategy>once-per-session</executionStrategy>
|
||||
<since>1.4.0</since>
|
||||
<threadSafe>true</threadSafe>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>additionalProperties</name>
|
||||
<type>java.util.Map</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Additional properties to store in the build-info.properties. Each entry is prefixed
|
||||
by {@code build.} in the generated build-info.properties.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>outputFile</name>
|
||||
<type>java.io.File</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The location of the generated build-info.properties.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>project</name>
|
||||
<type>org.apache.maven.project.MavenProject</type>
|
||||
<required>true</required>
|
||||
<editable>false</editable>
|
||||
<description>The Maven project.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>session</name>
|
||||
<type>org.apache.maven.execution.MavenSession</type>
|
||||
<required>true</required>
|
||||
<editable>false</editable>
|
||||
<description>The Maven session.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>time</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>2.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The value used for the {@code build.time} property in a form suitable for
|
||||
{@link Instant#parse(CharSequence)}. Defaults to {@code session.request.startTime}.
|
||||
To disable the {@code build.time} property entirely, use {@code 'off'}.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<configuration>
|
||||
<outputFile implementation="java.io.File" default-value="${project.build.outputDirectory}/META-INF/build-info.properties"/>
|
||||
<project implementation="org.apache.maven.project.MavenProject" default-value="${project}"/>
|
||||
<session implementation="org.apache.maven.execution.MavenSession" default-value="${session}"/>
|
||||
</configuration>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.sonatype.plexus.build.incremental.BuildContext</role>
|
||||
<field-name>buildContext</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</mojo>
|
||||
<mojo>
|
||||
<goal>help</goal>
|
||||
<description>Display help information on spring-boot-maven-plugin.<br>
|
||||
Call <code>mvn spring-boot:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details.</description>
|
||||
<requiresDirectInvocation>false</requiresDirectInvocation>
|
||||
<requiresProject>false</requiresProject>
|
||||
<requiresReports>false</requiresReports>
|
||||
<aggregator>false</aggregator>
|
||||
<requiresOnline>false</requiresOnline>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<implementation>org.springframework.boot.maven.HelpMojo</implementation>
|
||||
<language>java</language>
|
||||
<instantiationStrategy>per-lookup</instantiationStrategy>
|
||||
<executionStrategy>once-per-session</executionStrategy>
|
||||
<threadSafe>true</threadSafe>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>detail</name>
|
||||
<type>boolean</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>If <code>true</code>, display all settable properties for each goal.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>goal</name>
|
||||
<type>java.lang.String</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The name of the goal for which to show help. If unspecified, all goals will be displayed.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>indentSize</name>
|
||||
<type>int</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The number of spaces per indentation level, should be positive.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>lineLength</name>
|
||||
<type>int</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The maximum length of a display line, should be positive.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<configuration>
|
||||
<detail implementation="boolean" default-value="false">${detail}</detail>
|
||||
<goal implementation="java.lang.String">${goal}</goal>
|
||||
<indentSize implementation="int" default-value="2">${indentSize}</indentSize>
|
||||
<lineLength implementation="int" default-value="80">${lineLength}</lineLength>
|
||||
</configuration>
|
||||
</mojo>
|
||||
<mojo>
|
||||
<goal>repackage</goal>
|
||||
<description>Repackages existing JAR and WAR archives so that they can be executed from the command
|
||||
line using {@literal java -jar}. With <code>layout=NONE</code> can also be used simply
|
||||
to package a JAR with nested dependencies (and no main class, so not executable).</description>
|
||||
<requiresDependencyResolution>compile+runtime</requiresDependencyResolution>
|
||||
<requiresDirectInvocation>false</requiresDirectInvocation>
|
||||
<requiresProject>true</requiresProject>
|
||||
<requiresReports>false</requiresReports>
|
||||
<aggregator>false</aggregator>
|
||||
<requiresOnline>false</requiresOnline>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<phase>package</phase>
|
||||
<implementation>org.springframework.boot.maven.RepackageMojo</implementation>
|
||||
<language>java</language>
|
||||
<instantiationStrategy>per-lookup</instantiationStrategy>
|
||||
<executionStrategy>once-per-session</executionStrategy>
|
||||
<since>1.0.0</since>
|
||||
<requiresDependencyCollection>compile+runtime</requiresDependencyCollection>
|
||||
<threadSafe>true</threadSafe>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>attach</name>
|
||||
<type>boolean</type>
|
||||
<since>1.4.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Attach the repackaged archive to be installed and deployed.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>classifier</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Classifier to add to the repackaged archive. If not given, the main artifact will
|
||||
be replaced by the repackaged archive. If given, the classifier will also be used
|
||||
to determine the source archive to repackage: if an artifact with that classifier
|
||||
already exists, it will be used as source and replaced. If no such artifact exists,
|
||||
the main artifact will be used as source and the repackaged archive will be
|
||||
attached as a supplemental artifact with that classifier. Attaching the artifact
|
||||
allows to deploy it alongside to the original one, see <a href=
|
||||
"https://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html"
|
||||
>the Maven documentation for more details</a>.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>embeddedLaunchScript</name>
|
||||
<type>java.io.File</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The embedded launch script to prepend to the front of the jar if it is fully
|
||||
executable. If not specified the 'Spring Boot' default script will be used.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>embeddedLaunchScriptProperties</name>
|
||||
<type>java.util.Properties</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Properties that should be expanded in the embedded launch script.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludeDevtools</name>
|
||||
<type>boolean</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Exclude Spring Boot devtools from the repackaged archive.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludeGroupIds</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Comma separated list of groupId names to exclude (exact match).</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludes</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Collection of artifact definitions to exclude. The {@link Exclude} element defines
|
||||
a {@code groupId} and {@code artifactId} mandatory properties and an optional
|
||||
{@code classifier} property.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>executable</name>
|
||||
<type>boolean</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Make a fully executable jar for *nix machines by prepending a launch script to the
|
||||
jar.
|
||||
<p>
|
||||
Currently, some tools do not accept this format so you may not always be able to
|
||||
use this technique. For example, {@code jar -xf} may silently fail to extract a jar
|
||||
or war that has been made fully-executable. It is recommended that you only enable
|
||||
this option if you intend to execute it directly, rather than running it with
|
||||
{@code java -jar} or deploying it to a servlet container.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>finalName</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>false</editable>
|
||||
<description>Name of the generated archive.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>includeSystemScope</name>
|
||||
<type>boolean</type>
|
||||
<since>1.4.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Include system scoped dependencies.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>includes</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Collection of artifact definitions to include. The {@link Include} element defines
|
||||
a {@code groupId} and {@code artifactId} mandatory properties and an optional
|
||||
{@code classifier} property.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>layout</name>
|
||||
<type>org.springframework.boot.maven.RepackageMojo$LayoutType</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The type of archive (which corresponds to how the dependencies are laid out inside
|
||||
it). Possible values are JAR, WAR, ZIP, DIR, NONE. Defaults to a guess based on the
|
||||
archive type.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>layoutFactory</name>
|
||||
<type>org.springframework.boot.loader.tools.LayoutFactory</type>
|
||||
<since>1.5.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The layout factory that will be used to create the executable archive if no
|
||||
explicit layout is set. Alternative layouts implementations can be provided by 3rd
|
||||
parties.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>mainClass</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The name of the main class. If not specified the first compiled class found that
|
||||
contains a 'main' method will be used.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>outputDirectory</name>
|
||||
<type>java.io.File</type>
|
||||
<since>1.0.0</since>
|
||||
<required>true</required>
|
||||
<editable>true</editable>
|
||||
<description>Directory containing the generated archive.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>project</name>
|
||||
<type>org.apache.maven.project.MavenProject</type>
|
||||
<since>1.0.0</since>
|
||||
<required>true</required>
|
||||
<editable>false</editable>
|
||||
<description>The Maven project.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>requiresUnpack</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>A list of the libraries that must be unpacked from fat jars in order to run.
|
||||
Specify each library as a {@code <dependency>} with a {@code <groupId>} and a
|
||||
{@code <artifactId>} and they will be unpacked at runtime.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>skip</name>
|
||||
<type>boolean</type>
|
||||
<since>1.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Skip the execution.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<configuration>
|
||||
<attach implementation="boolean" default-value="true"/>
|
||||
<excludeDevtools implementation="boolean" default-value="true">${spring-boot.repackage.excludeDevtools}</excludeDevtools>
|
||||
<excludeGroupIds implementation="java.lang.String" default-value="">${spring-boot.excludeGroupIds}</excludeGroupIds>
|
||||
<excludes implementation="java.util.List">${spring-boot.excludes}</excludes>
|
||||
<executable implementation="boolean" default-value="false"/>
|
||||
<finalName implementation="java.lang.String" default-value="${project.build.finalName}"/>
|
||||
<includeSystemScope implementation="boolean" default-value="false"/>
|
||||
<includes implementation="java.util.List">${spring-boot.includes}</includes>
|
||||
<layout implementation="org.springframework.boot.maven.RepackageMojo$LayoutType">${spring-boot.repackage.layout}</layout>
|
||||
<outputDirectory implementation="java.io.File" default-value="${project.build.directory}"/>
|
||||
<project implementation="org.apache.maven.project.MavenProject" default-value="${project}"/>
|
||||
<skip implementation="boolean" default-value="false">${spring-boot.repackage.skip}</skip>
|
||||
</configuration>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.MavenProjectHelper</role>
|
||||
<field-name>projectHelper</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</mojo>
|
||||
<mojo>
|
||||
<goal>run</goal>
|
||||
<description>Run an executable archive application.</description>
|
||||
<requiresDependencyResolution>test</requiresDependencyResolution>
|
||||
<requiresDirectInvocation>false</requiresDirectInvocation>
|
||||
<requiresProject>true</requiresProject>
|
||||
<requiresReports>false</requiresReports>
|
||||
<aggregator>false</aggregator>
|
||||
<requiresOnline>false</requiresOnline>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<phase>validate</phase>
|
||||
<executePhase>test-compile</executePhase>
|
||||
<implementation>org.springframework.boot.maven.RunMojo</implementation>
|
||||
<language>java</language>
|
||||
<instantiationStrategy>per-lookup</instantiationStrategy>
|
||||
<executionStrategy>once-per-session</executionStrategy>
|
||||
<since>1.0.0</since>
|
||||
<threadSafe>false</threadSafe>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>addResources</name>
|
||||
<type>boolean</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Add maven resources to the classpath directly, this allows live in-place editing of
|
||||
resources. Duplicate resources are removed from {@code target/classes} to prevent
|
||||
them to appear twice if {@code ClassLoader.getResources()} is called. Please
|
||||
consider adding {@code spring-boot-devtools} to your project instead as it provides
|
||||
this feature and many more.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>agent</name>
|
||||
<type>java.io.File[]</type>
|
||||
<since>1.0.0</since>
|
||||
<deprecated>since 2.2.0 in favor of {@code agents}</deprecated>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Path to agent jar. NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>agents</name>
|
||||
<type>java.io.File[]</type>
|
||||
<since>2.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Path to agent jars. NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>arguments</name>
|
||||
<type>java.lang.String[]</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Arguments that should be passed to the application. On command line use commas to
|
||||
separate multiple arguments.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>classesDirectory</name>
|
||||
<type>java.io.File</type>
|
||||
<since>1.0.0</since>
|
||||
<required>true</required>
|
||||
<editable>true</editable>
|
||||
<description>Directory containing the classes and resource files that should be packaged into
|
||||
the archive.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>environmentVariables</name>
|
||||
<type>java.util.Map</type>
|
||||
<since>2.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>List of Environment variables that should be associated with the forked process
|
||||
used to run the application. NOTE: a forked process is required to use this
|
||||
feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludeGroupIds</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Comma separated list of groupId names to exclude (exact match).</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludes</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Collection of artifact definitions to exclude. The {@link Exclude} element defines
|
||||
a {@code groupId} and {@code artifactId} mandatory properties and an optional
|
||||
{@code classifier} property.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>folders</name>
|
||||
<type>java.lang.String[]</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Additional folders besides the classes directory that should be added to the
|
||||
classpath.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>fork</name>
|
||||
<type>boolean</type>
|
||||
<since>1.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to indicate if the run processes should be forked. Disabling forking will
|
||||
disable some features such as an agent, custom JVM arguments, devtools or
|
||||
specifying the working directory to use.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>includes</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Collection of artifact definitions to include. The {@link Include} element defines
|
||||
a {@code groupId} and {@code artifactId} mandatory properties and an optional
|
||||
{@code classifier} property.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jvmArguments</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>JVM arguments that should be associated with the forked process used to run the
|
||||
application. On command line, make sure to wrap multiple values between quotes.
|
||||
NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>mainClass</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The name of the main class. If not specified the first compiled class found that
|
||||
contains a 'main' method will be used.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>noverify</name>
|
||||
<type>boolean</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to say that the agent requires -noverify.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>optimizedLaunch</name>
|
||||
<type>boolean</type>
|
||||
<since>2.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Whether the JVM's launch should be optimized.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>profiles</name>
|
||||
<type>java.lang.String[]</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The spring profiles to activate. Convenience shortcut of specifying the
|
||||
'spring.profiles.active' argument. On command line use commas to separate multiple
|
||||
profiles.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>project</name>
|
||||
<type>org.apache.maven.project.MavenProject</type>
|
||||
<since>1.0.0</since>
|
||||
<required>true</required>
|
||||
<editable>false</editable>
|
||||
<description>The Maven project.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>skip</name>
|
||||
<type>boolean</type>
|
||||
<since>1.3.2</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Skip the execution.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>systemPropertyVariables</name>
|
||||
<type>java.util.Map</type>
|
||||
<since>2.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>List of JVM system properties to pass to the process. NOTE: a forked process is
|
||||
required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>useTestClasspath</name>
|
||||
<type>java.lang.Boolean</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to include the test classpath when running.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>workingDirectory</name>
|
||||
<type>java.io.File</type>
|
||||
<since>1.5.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Current working directory to use for the application. If not specified, basedir
|
||||
will be used. NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<configuration>
|
||||
<addResources implementation="boolean" default-value="false">${spring-boot.run.addResources}</addResources>
|
||||
<agent implementation="java.io.File[]">${spring-boot.run.agent}</agent>
|
||||
<agents implementation="java.io.File[]">${spring-boot.run.agents}</agents>
|
||||
<arguments implementation="java.lang.String[]">${spring-boot.run.arguments}</arguments>
|
||||
<classesDirectory implementation="java.io.File" default-value="${project.build.outputDirectory}"/>
|
||||
<excludeGroupIds implementation="java.lang.String" default-value="">${spring-boot.excludeGroupIds}</excludeGroupIds>
|
||||
<excludes implementation="java.util.List">${spring-boot.excludes}</excludes>
|
||||
<folders implementation="java.lang.String[]">${spring-boot.run.folders}</folders>
|
||||
<fork implementation="boolean" default-value="true">${spring-boot.run.fork}</fork>
|
||||
<includes implementation="java.util.List">${spring-boot.includes}</includes>
|
||||
<jvmArguments implementation="java.lang.String">${spring-boot.run.jvmArguments}</jvmArguments>
|
||||
<mainClass implementation="java.lang.String">${spring-boot.run.main-class}</mainClass>
|
||||
<noverify implementation="boolean">${spring-boot.run.noverify}</noverify>
|
||||
<optimizedLaunch implementation="boolean" default-value="true">${spring-boot.run.optimizedLaunch}</optimizedLaunch>
|
||||
<profiles implementation="java.lang.String[]">${spring-boot.run.profiles}</profiles>
|
||||
<project implementation="org.apache.maven.project.MavenProject" default-value="${project}"/>
|
||||
<skip implementation="boolean" default-value="false">${spring-boot.run.skip}</skip>
|
||||
<useTestClasspath implementation="java.lang.Boolean" default-value="false">${spring-boot.run.useTestClasspath}</useTestClasspath>
|
||||
<workingDirectory implementation="java.io.File">${spring-boot.run.workingDirectory}</workingDirectory>
|
||||
</configuration>
|
||||
</mojo>
|
||||
<mojo>
|
||||
<goal>start</goal>
|
||||
<description>Start a spring application. Contrary to the {@code run} goal, this does not block and
|
||||
allows other goal to operate on the application. This goal is typically used in
|
||||
integration test scenario where the application is started before a test suite and
|
||||
stopped after.</description>
|
||||
<requiresDependencyResolution>test</requiresDependencyResolution>
|
||||
<requiresDirectInvocation>false</requiresDirectInvocation>
|
||||
<requiresProject>true</requiresProject>
|
||||
<requiresReports>false</requiresReports>
|
||||
<aggregator>false</aggregator>
|
||||
<requiresOnline>false</requiresOnline>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<phase>pre-integration-test</phase>
|
||||
<implementation>org.springframework.boot.maven.StartMojo</implementation>
|
||||
<language>java</language>
|
||||
<instantiationStrategy>per-lookup</instantiationStrategy>
|
||||
<executionStrategy>once-per-session</executionStrategy>
|
||||
<since>1.3.0</since>
|
||||
<threadSafe>false</threadSafe>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>addResources</name>
|
||||
<type>boolean</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Add maven resources to the classpath directly, this allows live in-place editing of
|
||||
resources. Duplicate resources are removed from {@code target/classes} to prevent
|
||||
them to appear twice if {@code ClassLoader.getResources()} is called. Please
|
||||
consider adding {@code spring-boot-devtools} to your project instead as it provides
|
||||
this feature and many more.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>agent</name>
|
||||
<type>java.io.File[]</type>
|
||||
<since>1.0.0</since>
|
||||
<deprecated>since 2.2.0 in favor of {@code agents}</deprecated>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Path to agent jar. NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>agents</name>
|
||||
<type>java.io.File[]</type>
|
||||
<since>2.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Path to agent jars. NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>arguments</name>
|
||||
<type>java.lang.String[]</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Arguments that should be passed to the application. On command line use commas to
|
||||
separate multiple arguments.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>classesDirectory</name>
|
||||
<type>java.io.File</type>
|
||||
<since>1.0.0</since>
|
||||
<required>true</required>
|
||||
<editable>true</editable>
|
||||
<description>Directory containing the classes and resource files that should be packaged into
|
||||
the archive.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>environmentVariables</name>
|
||||
<type>java.util.Map</type>
|
||||
<since>2.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>List of Environment variables that should be associated with the forked process
|
||||
used to run the application. NOTE: a forked process is required to use this
|
||||
feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludeGroupIds</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Comma separated list of groupId names to exclude (exact match).</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>excludes</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Collection of artifact definitions to exclude. The {@link Exclude} element defines
|
||||
a {@code groupId} and {@code artifactId} mandatory properties and an optional
|
||||
{@code classifier} property.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>folders</name>
|
||||
<type>java.lang.String[]</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Additional folders besides the classes directory that should be added to the
|
||||
classpath.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>fork</name>
|
||||
<type>boolean</type>
|
||||
<since>1.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to indicate if the run processes should be forked. Disabling forking will
|
||||
disable some features such as an agent, custom JVM arguments, devtools or
|
||||
specifying the working directory to use.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>includes</name>
|
||||
<type>java.util.List</type>
|
||||
<since>1.2.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Collection of artifact definitions to include. The {@link Include} element defines
|
||||
a {@code groupId} and {@code artifactId} mandatory properties and an optional
|
||||
{@code classifier} property.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jmxName</name>
|
||||
<type>java.lang.String</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The JMX name of the automatically deployed MBean managing the lifecycle of the
|
||||
spring application.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jmxPort</name>
|
||||
<type>int</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The port to use to expose the platform MBeanServer if the application is forked.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jvmArguments</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>JVM arguments that should be associated with the forked process used to run the
|
||||
application. On command line, make sure to wrap multiple values between quotes.
|
||||
NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>mainClass</name>
|
||||
<type>java.lang.String</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The name of the main class. If not specified the first compiled class found that
|
||||
contains a 'main' method will be used.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxAttempts</name>
|
||||
<type>int</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The maximum number of attempts to check if the spring application is ready.
|
||||
Combined with the "wait" argument, this gives a global timeout value (30 sec by
|
||||
default)</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>noverify</name>
|
||||
<type>boolean</type>
|
||||
<since>1.0.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to say that the agent requires -noverify.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>profiles</name>
|
||||
<type>java.lang.String[]</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The spring profiles to activate. Convenience shortcut of specifying the
|
||||
'spring.profiles.active' argument. On command line use commas to separate multiple
|
||||
profiles.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>project</name>
|
||||
<type>org.apache.maven.project.MavenProject</type>
|
||||
<since>1.0.0</since>
|
||||
<required>true</required>
|
||||
<editable>false</editable>
|
||||
<description>The Maven project.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>skip</name>
|
||||
<type>boolean</type>
|
||||
<since>1.3.2</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Skip the execution.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>systemPropertyVariables</name>
|
||||
<type>java.util.Map</type>
|
||||
<since>2.1.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>List of JVM system properties to pass to the process. NOTE: a forked process is
|
||||
required to use this feature.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>useTestClasspath</name>
|
||||
<type>java.lang.Boolean</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to include the test classpath when running.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>wait</name>
|
||||
<type>long</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The number of milli-seconds to wait between each attempt to check if the spring
|
||||
application is ready.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>workingDirectory</name>
|
||||
<type>java.io.File</type>
|
||||
<since>1.5.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Current working directory to use for the application. If not specified, basedir
|
||||
will be used. NOTE: a forked process is required to use this feature.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<configuration>
|
||||
<addResources implementation="boolean" default-value="false">${spring-boot.run.addResources}</addResources>
|
||||
<agent implementation="java.io.File[]">${spring-boot.run.agent}</agent>
|
||||
<agents implementation="java.io.File[]">${spring-boot.run.agents}</agents>
|
||||
<arguments implementation="java.lang.String[]">${spring-boot.run.arguments}</arguments>
|
||||
<classesDirectory implementation="java.io.File" default-value="${project.build.outputDirectory}"/>
|
||||
<excludeGroupIds implementation="java.lang.String" default-value="">${spring-boot.excludeGroupIds}</excludeGroupIds>
|
||||
<excludes implementation="java.util.List">${spring-boot.excludes}</excludes>
|
||||
<folders implementation="java.lang.String[]">${spring-boot.run.folders}</folders>
|
||||
<fork implementation="boolean" default-value="true">${spring-boot.run.fork}</fork>
|
||||
<includes implementation="java.util.List">${spring-boot.includes}</includes>
|
||||
<jvmArguments implementation="java.lang.String">${spring-boot.run.jvmArguments}</jvmArguments>
|
||||
<mainClass implementation="java.lang.String">${spring-boot.run.main-class}</mainClass>
|
||||
<noverify implementation="boolean">${spring-boot.run.noverify}</noverify>
|
||||
<profiles implementation="java.lang.String[]">${spring-boot.run.profiles}</profiles>
|
||||
<project implementation="org.apache.maven.project.MavenProject" default-value="${project}"/>
|
||||
<skip implementation="boolean" default-value="false">${spring-boot.run.skip}</skip>
|
||||
<useTestClasspath implementation="java.lang.Boolean" default-value="false">${spring-boot.run.useTestClasspath}</useTestClasspath>
|
||||
<workingDirectory implementation="java.io.File">${spring-boot.run.workingDirectory}</workingDirectory>
|
||||
</configuration>
|
||||
</mojo>
|
||||
<mojo>
|
||||
<goal>stop</goal>
|
||||
<description>Stop a spring application that has been started by the "start" goal. Typically invoked
|
||||
once a test suite has completed.</description>
|
||||
<requiresDirectInvocation>false</requiresDirectInvocation>
|
||||
<requiresProject>true</requiresProject>
|
||||
<requiresReports>false</requiresReports>
|
||||
<aggregator>false</aggregator>
|
||||
<requiresOnline>false</requiresOnline>
|
||||
<inheritedByDefault>true</inheritedByDefault>
|
||||
<phase>post-integration-test</phase>
|
||||
<implementation>org.springframework.boot.maven.StopMojo</implementation>
|
||||
<language>java</language>
|
||||
<instantiationStrategy>per-lookup</instantiationStrategy>
|
||||
<executionStrategy>once-per-session</executionStrategy>
|
||||
<since>1.3.0</since>
|
||||
<threadSafe>false</threadSafe>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>fork</name>
|
||||
<type>java.lang.Boolean</type>
|
||||
<since>1.3.0</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Flag to indicate if process to stop was forked. By default, the value is inherited
|
||||
from the {@link MavenProject}. If it is set, it must match the value used to
|
||||
{@link StartMojo start} the process.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jmxName</name>
|
||||
<type>java.lang.String</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The JMX name of the automatically deployed MBean managing the lifecycle of the
|
||||
application.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jmxPort</name>
|
||||
<type>int</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>The port to use to lookup the platform MBeanServer if the application has been
|
||||
forked.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>project</name>
|
||||
<type>org.apache.maven.project.MavenProject</type>
|
||||
<since>1.4.1</since>
|
||||
<required>true</required>
|
||||
<editable>false</editable>
|
||||
<description>The Maven project.</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>skip</name>
|
||||
<type>boolean</type>
|
||||
<since>1.3.2</since>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
<description>Skip the execution.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<configuration>
|
||||
<fork implementation="java.lang.Boolean">${spring-boot.stop.fork}</fork>
|
||||
<project implementation="org.apache.maven.project.MavenProject" default-value="${project}"/>
|
||||
<skip implementation="boolean" default-value="false">${spring-boot.stop.skip}</skip>
|
||||
</configuration>
|
||||
</mojo>
|
||||
</mojos>
|
||||
<dependencies/>
|
||||
</plugin>
|
||||
Reference in New Issue
Block a user