diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/invoker.properties b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/invoker.properties new file mode 100644 index 0000000000..793d89fcd3 --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify \ No newline at end of file diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/pom.xml new file mode 100644 index 0000000000..cca2983c7c --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + org.springframework.boot.maven.it + start-stop-skip + 0.0.1.BUILD-SNAPSHOT + + UTF-8 + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + true + + + + + diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/src/main/java/org/test/SampleApplication.java b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/src/main/java/org/test/SampleApplication.java new file mode 100644 index 0000000000..ac4faed771 --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/src/main/java/org/test/SampleApplication.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012-2016 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.test; + +/** + * This sample should not run at all + */ +public class SampleApplication { + + public static void main(String[] args) throws Exception { + System.out.println("Ooops, I haz been run"); + } + +} diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/verify.groovy b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/verify.groovy new file mode 100644 index 0000000000..0d3ec538c9 --- /dev/null +++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/start-stop-skip/verify.groovy @@ -0,0 +1,5 @@ +import static org.junit.Assert.assertFalse + +def file = new File(basedir, "build.log") +assertFalse 'Application should not have run', file.text.contains("Ooops, I haz been run") +assertFalse 'Should not attempt to stop the app', file.text.contains('Stopping application') diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 637dde5230..bc4721cce4 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -151,6 +151,13 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { @Parameter(property = "useTestClasspath", defaultValue = "false") private Boolean useTestClasspath; + /** + * Skip the execution. + * @since 1.3.2 + */ + @Parameter(defaultValue = "false") + private boolean skip; + /** * Specify if the application process should be forked. * @return {@code true} if the application process should be forked @@ -170,6 +177,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { + if (this.skip) { + getLog().debug("skipping run as per configuration."); + return; + } final String startClassName = getStartClass(); run(startClassName); } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java index 550f351436..5e04ad9687 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StopMojo.java @@ -62,8 +62,19 @@ public class StopMojo extends AbstractMojo { @Parameter private int jmxPort = 9001; + /** + * Skip the execution. + * @since 1.3.2 + */ + @Parameter(defaultValue = "false") + private boolean skip; + @Override public void execute() throws MojoExecutionException, MojoFailureException { + if (this.skip) { + getLog().debug("skipping stop as per configuration."); + return; + } getLog().info("Stopping application..."); try { if (Boolean.TRUE.equals(this.fork)) {