diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 54bae28dd1..0b4be403c9 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -20,6 +20,7 @@ ${basedir}/.. + spring-boot-sample-ant spring-boot-sample-activemq spring-boot-sample-actuator spring-boot-sample-actuator-log4j diff --git a/spring-boot-samples/spring-boot-sample-actuator/build.xml b/spring-boot-samples/spring-boot-sample-actuator/build.xml deleted file mode 100644 index 96ee6f3ce2..0000000000 --- a/spring-boot-samples/spring-boot-sample-actuator/build.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - Sample ANT build script for a Spring Boot executable JAR project. Uses ivy for dependency management so run with - '$ ant -lib ivy-2.2.jar' (substitute the location of your actual ivy jar). Run with '$ java -jar target/*.jar'. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-ant/build.xml b/spring-boot-samples/spring-boot-sample-ant/build.xml new file mode 100644 index 0000000000..61193b938b --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ant/build.xml @@ -0,0 +1,50 @@ + + + + Sample ANT build script for a Spring Boot executable JAR project. Uses ivy for + dependency management and spring-boot-antlib for additional tasks. Run with + '$ ant -lib ivy-2.2.jar spring-boot-antlib.jar' (substitute the location of your + actual jars). Run with '$ java -jar target/*.jar'. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-boot-samples/spring-boot-sample-actuator/ivy.xml b/spring-boot-samples/spring-boot-sample-ant/ivy.xml similarity index 51% rename from spring-boot-samples/spring-boot-sample-actuator/ivy.xml rename to spring-boot-samples/spring-boot-sample-ant/ivy.xml index 0e3da0eefc..140d3274e5 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/ivy.xml +++ b/spring-boot-samples/spring-boot-sample-ant/ivy.xml @@ -1,13 +1,10 @@ - + - - - - + diff --git a/spring-boot-samples/spring-boot-sample-actuator/ivysettings.xml b/spring-boot-samples/spring-boot-sample-ant/ivysettings.xml similarity index 69% rename from spring-boot-samples/spring-boot-sample-actuator/ivysettings.xml rename to spring-boot-samples/spring-boot-sample-ant/ivysettings.xml index 72631b8ba8..4127a506e8 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/ivysettings.xml +++ b/spring-boot-samples/spring-boot-sample-ant/ivysettings.xml @@ -1,11 +1,11 @@ - + - - + + diff --git a/spring-boot-samples/spring-boot-sample-ant/pom.xml b/spring-boot-samples/spring-boot-sample-ant/pom.xml new file mode 100644 index 0000000000..11552f4798 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ant/pom.xml @@ -0,0 +1,105 @@ + + + + 4.0.0 + + org.springframework.boot + spring-boot-samples + 1.3.0.BUILD-SNAPSHOT + + spring-boot-sample-ant + Spring Boot Ant Sample + Spring Boot Ant Sample + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + 1.9.3 + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-loader-tools + test + + + org.springframework.boot + spring-boot-antlib + ${spring-boot.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + none + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + antbuild + package + + + + + + + + run + + + + + + org.apache.ant + ant + ${ant.version} + + + org.apache.ivy + ivy + 2.4.0 + + + org.springframework.boot + spring-boot-antlib + ${spring-boot.version} + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + diff --git a/spring-boot-samples/spring-boot-sample-ant/src/main/java/sample/ant/SampleAntApplication.java b/spring-boot-samples/spring-boot-sample-ant/src/main/java/sample/ant/SampleAntApplication.java new file mode 100644 index 0000000000..7a382f8df4 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ant/src/main/java/sample/ant/SampleAntApplication.java @@ -0,0 +1,35 @@ +/* + * 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 sample.ant; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SampleAntApplication implements CommandLineRunner { + + @Override + public void run(String... args) { + System.out.println("Spring Boot Ant Example"); + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(SampleAntApplication.class, args); + } + +} diff --git a/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java b/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java new file mode 100644 index 0000000000..5b03436d77 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java @@ -0,0 +1,58 @@ +/* + * 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 sample.ant; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; + +import java.io.File; +import java.io.FileFilter; +import java.io.InputStreamReader; +import java.util.concurrent.TimeUnit; + +import org.junit.Test; +import org.springframework.boot.loader.tools.JavaExecutable; +import org.springframework.util.FileCopyUtils; + +/** + * Integration Tests for {@code SampleAntApplication}. + * + * @author Dave Syer + * @author Phillip Webb + */ +public class SampleAntApplicationIT { + + @Test + public void runJar() throws Exception { + File target = new File("target"); + File[] jarFiles = target.listFiles(new FileFilter() { + + @Override + public boolean accept(File file) { + return file.getName().endsWith(".jar"); + } + + }); + assertThat("Number of jars", jarFiles.length, equalTo(1)); + Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start(); + process.waitFor(5, TimeUnit.MINUTES); + assertThat(process.exitValue(), equalTo(0)); + String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream())); + assertThat(output, containsString("Spring Boot Ant Example")); + } + +} diff --git a/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties b/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties new file mode 100644 index 0000000000..4dfe84cedc --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties @@ -0,0 +1 @@ +name: Phil \ No newline at end of file