diff --git a/spring-bootstrap-groovy/README.md b/spring-bootstrap-groovy/README.md deleted file mode 100644 index 881e5149c50..00000000000 --- a/spring-bootstrap-groovy/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Spring Bootstrap Groovy - -Spring Bootstrap Groovy gives you the quickest possible getting -started experience with Spring apps, whether you are writing a web -app, a batch job or a standalone java app. - -## Building and Testing - -To avoid problems with classpaths and existing JVM-based build tools, -Spring Bootstrap Groovy uses an exec plugin call to launch `groovyc`. -You need to have a `sh` on your path along with `groovyc` (2.1.x), -`find` and `xargs`. These tools are standard on a Mac or Linux -distribution, and available using Cygwin on Windows. Once it is -built, the zip file is portable. - -Here are the steps to build and test: - - $ mvn install - -The `spring` executable is then available at -`spring-bootstrap-groovy/target/spring-`. There is also a jar -file with the Groovy Bootstrap components. The `spring` executable -includes jars from `SPRING_HOME` in the classpath so you can run it -while you are developing like this - - $ export SPRING_HOME=/target - $ /src/main/scripts/spring App.groovy diff --git a/spring-bootstrap-groovy/pom.xml b/spring-bootstrap-groovy/pom.xml deleted file mode 100644 index 44e5e6b3a1a..00000000000 --- a/spring-bootstrap-groovy/pom.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - 4.0.0 - - org.springframework.bootstrap - spring-bootstrap-parent - 0.0.1-SNAPSHOT - - spring-bootstrap-groovy - jar - - - org.springframework.bootstrap - spring-bootstrap - ${project.version} - - - org.springframework - spring-web - ${dependency.springframework.version} - - - org.codehaus.groovy - groovy - 2.1.1 - provided - - - org.apache.ivy - ivy - 2.2.0 - provided - - - - - grapes - - - - maven-clean-plugin - 2.5 - - - - ${user.home}/.groovy/grapes - - org.springframework*/** - - false - - - - - - - - - - - - src/main/groovy - true - ../generated-sources/groovy - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - compile-plugin - compile - - exec - - - sh - - -c - find target/generated-sources/groovy -name *.groovy | - xargs groovyc -d target/classes - - - - - - - maven-assembly-plugin - false - - - src/main/assembly/descriptor.xml - - - - - make-distribution - install - - single - - - - - - maven-compiler-plugin - - groovy-eclipse-compiler - - - - org.codehaus.groovy - groovy-eclipse-compiler - 2.7.0-01 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*Tests.java - - - **/Abstract*.java - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - [3.0,) - - testCompile - compile - - - - - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 - - - @@ - - false - - - - - - diff --git a/spring-bootstrap-groovy/src/main/assembly/descriptor.xml b/spring-bootstrap-groovy/src/main/assembly/descriptor.xml deleted file mode 100644 index 22010960c67..00000000000 --- a/spring-bootstrap-groovy/src/main/assembly/descriptor.xml +++ /dev/null @@ -1,30 +0,0 @@ - - dist - - zip - dir - - spring-${project.version} - true - - - src/main/scripts - bin - true - - - src/main/resources - bin - true - true - - - - - - org.springframework.bootstrap:spring-bootstrap-groovy:jar:* - - lib - - - diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BatchGrapes.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BatchGrapes.groovy deleted file mode 100644 index 9e3fa7b2f04..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BatchGrapes.groovy +++ /dev/null @@ -1,52 +0,0 @@ -package org.springframework.bootstrap.grapes - -@GrabResolver(name='spring-milestone', root='http://repo.springframework.org/milestone') -@GrabResolver(name='spring-snapshot', root='http://repo.springframework.org/snapshot') -@GrabConfig(systemClassLoader=true) -@Grab("org.springframework.bootstrap:spring-bootstrap:@@version@@") -@Grab("org.springframework.batch:spring-batch-core:2.2.0.M1") -@Grab("org.springframework:spring-context:@@dependency.springframework.version@@") -class BatchGrapes { -} - -import org.springframework.bootstrap.context.annotation.ConditionalOnMissingBean -import org.springframework.bootstrap.CommandLineRunner -import org.springframework.batch.core.Job -import org.springframework.batch.core.converter.DefaultJobParametersConverter -import org.springframework.batch.core.converter.JobParametersConverter -import org.springframework.batch.core.launch.JobLauncher -import org.springframework.context.annotation.Configuration -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.context.annotation.Bean -import org.springframework.util.StringUtils -import groovy.util.logging.Log - -@Configuration -@ConditionalOnMissingBean(CommandLineRunner) -@Log -class BatchCommand { - - @Autowired(required=false) - private JobParametersConverter converter = new DefaultJobParametersConverter() - - @Autowired - private JobLauncher jobLauncher - - @Autowired - private Job job - - @Bean - CommandLineRunner batchCommandLineRunner() { - return new CommandLineRunner() { - void run(String... args) { - log.info("Running default command line with: ${args}") - launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "=")) - } - } - } - - protected void launchJobFromProperties(Properties properties) { - jobLauncher.run(job, converter.getJobParameters(properties)) - } - -} diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BatchInitializationGrapes.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BatchInitializationGrapes.groovy deleted file mode 100644 index 92072181c27..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BatchInitializationGrapes.groovy +++ /dev/null @@ -1,40 +0,0 @@ -package org.springframework.bootstrap.grapes - -@GrabResolver(name='spring-milestone', root='http://repo.springframework.org/milestone') -@GrabConfig(systemClassLoader=true) -@Grab("org.springframework:spring-jdbc:4.0.0.BOOTSTRAP-SNAPSHOT") -@Grab("org.springframework.batch:spring-batch-core:2.2.0.M1") -import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils -import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator -import javax.annotation.PostConstruct -import javax.sql.DataSource -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.context.annotation.Configuration -import org.springframework.core.env.Environment -import org.springframework.core.io.ResourceLoader - -@Configuration // TODO: make this conditional -class BatchInitializationGrapes { - - @Autowired - private DataSource dataSource - - @Autowired - private Environment environment - - @Autowired - private ResourceLoader resourceLoader - - @PostConstruct - protected void initialize() { - String platform = org.springframework.batch.support.DatabaseType.fromMetaData(dataSource).toString().toLowerCase() - if (platform=="hsql") { - platform = "hsqldb" - } - ResourceDatabasePopulator populator = new ResourceDatabasePopulator() - populator.addScript(resourceLoader.getResource("org/springframework/batch/core/schema-${platform}.sql")) - populator.setContinueOnError(true) - DatabasePopulatorUtils.execute(populator, dataSource) - } - -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BootstrapGrapes.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BootstrapGrapes.groovy deleted file mode 100644 index 1d08c92b142..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/BootstrapGrapes.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.springframework.bootstrap.grapes - -// Spring stuff needs to be on the system classloader apparently (when using @Configuration) -@GrabResolver(name='spring-snapshot', root='http://repo.springframework.org/snapshot') -@GrabConfig(systemClassLoader=true) -@Grab("org.springframework:spring-context:@@dependency.springframework.version@@") -@Grab("org.springframework.bootstrap:spring-bootstrap:@@version@@") -@GrabExclude("commons-logging:commons-logging") -@Grab("org.slf4j:jcl-over-slf4j:1.6.1") -@Grab("org.slf4j:slf4j-jdk14:1.6.1") -class BootstrapGrapes { -} - -import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration -import org.springframework.context.annotation.Configuration - -@Configuration -// @EnableAutoConfiguration -class BootstrapAutoConfiguration { -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/Dependencies.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/Dependencies.groovy deleted file mode 100644 index f3ed1319b23..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/Dependencies.groovy +++ /dev/null @@ -1,92 +0,0 @@ -package org.springframework.bootstrap.grapes - -import org.springframework.core.type.StandardAnnotationMetadata -import org.springframework.util.ClassUtils -import org.springframework.core.type.classreading.SimpleMetadataReaderFactory -import groovy.util.logging.Log - -@GrabResolver(name='spring-snapshot', root='http://repo.springframework.org/snapshot') -@GrabConfig(systemClassLoader=true) -@Grab("org.springframework:spring-core:4.0.0.BOOTSTRAP-SNAPSHOT") -@GrabExclude("commons-logging:commons-logging") -@Grab("org.slf4j:jcl-over-slf4j:1.6.1") -@Grab("org.slf4j:slf4j-jdk14:1.6.1") -@Log -class Dependencies { - - static List defaults() { - return ["org.springframework.bootstrap.grapes.BootstrapGrapes"] - } - - static List dependencies(Collection configs) { - - def result = [] - if (isWeb(configs)) { - log.info("Adding web dependencies.") - result.addAll(web()) - } - - if (isBatch(configs)) { - log.info("Adding batch dependencies.") - result.addAll(batch()) - result << "org.springframework.bootstrap.grapes.BatchCommand" - result << "org.springframework.bootstrap.grapes.BatchInitializationGrapes" - } - - if (isHadoop(configs)) { - log.info("Adding info dependencies.") - result.addAll(hadoop()) - result << "org.springframework.bootstrap.grapes.HadoopContext" - } - - return result - - } - - static String[] web() { - def result = [] - result << "org.springframework.bootstrap.grapes.WebGrapes" - if (!isEmbeddedServerAvailable()) { result << "org.springframework.bootstrap.grapes.TomcatGrapes" } - return result - } - - static String[] batch() { - def result = [] - result << "org.springframework.bootstrap.grapes.BatchGrapes" - return result - } - - static String[] hadoop() { - def result = [] - result << "org.springframework.bootstrap.grapes.HadoopGrapes" - return result - } - - static boolean isWeb(Collection configs) { - SimpleMetadataReaderFactory factory = new SimpleMetadataReaderFactory() - return configs.any { config -> - def meta = factory.getMetadataReader(config).getAnnotationMetadata() - meta.hasAnnotation("org.springframework.stereotype.Controller") || meta.hasAnnotation("org.springframework.web.servlet.config.annotation.EnableWebMvc") - } - } - - static boolean isHadoop(Collection configs) { - SimpleMetadataReaderFactory factory = new SimpleMetadataReaderFactory() - return configs.any { config -> - config.contains("Hadoop") - } - } - - static boolean isBatch(Collection configs) { - SimpleMetadataReaderFactory factory = new SimpleMetadataReaderFactory() - return configs.any { config -> - def meta = factory.getMetadataReader(config).getAnnotationMetadata() - meta.hasAnnotation("org.springframework.batch.core.configuration.annotation.EnableBatchProcessing") - } - } - - static boolean isEmbeddedServerAvailable() { - return ClassUtils.isPresent("org.apache.catalina.startup.Tomcat") || ClassUtils.isPresent("org.mortbay.jetty.Server") - } - -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/HadoopGrapes.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/HadoopGrapes.groovy deleted file mode 100644 index dc239778c59..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/HadoopGrapes.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package org.springframework.bootstrap.grapes - -@GrabConfig(systemClassLoader=true) -@Grab("org.springframework.data:spring-data-hadoop:1.0.0.RELEASE") -@Grab("org.springframework.bootstrap:spring-bootstrap:@@version@@") -@Grab("org.springframework:spring-context:4.0.0.BOOTSTRAP-SNAPSHOT") -@Grab("org.apache.hadoop:hadoop-examples:1.0.4") -@GrabExclude("org.mortbay.jetty:sevlet-api-2.5") -@GrabExclude("org.mortbay.jetty:jetty") -@GrabExclude("org.mortbay.jetty:jetty-util") -@GrabExclude("org.mortbay.jetty:jsp-2.1") -@GrabExclude("org.mortbay.jetty:jsp-api-2.1") -@GrabExclude("tomcat:jasper-runtime") -@GrabExclude("tomcat:jasper-compiler") -class HadoopGrapes { -} - -import org.springframework.bootstrap.context.annotation.ConditionalOnMissingBean -import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.ImportResource - -@Configuration -@ConditionalOnMissingBean(org.apache.hadoop.conf.Configuration) -@ImportResource("hadoop-context.xml") -class HadoopContext { -} diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/TomcatGrapes.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/TomcatGrapes.groovy deleted file mode 100644 index 697f548bf23..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/TomcatGrapes.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package org.springframework.bootstrap.grapes - -@GrabConfig(systemClassLoader=true) -// Grab some Tomcat dependencies -@Grab("org.apache.tomcat.embed:tomcat-embed-core:7.0.32") -// JULI logging has sensible defaults in JAVA_HOME, so no need for user to create it -@Grab("org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.32") -class TomcatGrapes { -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/WebGrapes.groovy b/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/WebGrapes.groovy deleted file mode 100644 index 53b80a3e0b1..00000000000 --- a/spring-bootstrap-groovy/src/main/groovy/org/springframework/bootstrap/grapes/WebGrapes.groovy +++ /dev/null @@ -1,5 +0,0 @@ -package org.springframework.bootstrap.grapes - -@Grab("org.springframework:spring-webmvc:4.0.0.BOOTSTRAP-SNAPSHOT") -class WebGrapes { -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/main/resources/hadoop-context.xml b/spring-bootstrap-groovy/src/main/resources/hadoop-context.xml deleted file mode 100644 index 2c5b7bf6b8a..00000000000 --- a/spring-bootstrap-groovy/src/main/resources/hadoop-context.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - fs.default.name=${hd.fs:hdfs://localhost:9000} - - - - - \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/main/scripts/customizer.groovy b/spring-bootstrap-groovy/src/main/scripts/customizer.groovy deleted file mode 100644 index b1b8e909af3..00000000000 --- a/spring-bootstrap-groovy/src/main/scripts/customizer.groovy +++ /dev/null @@ -1,100 +0,0 @@ -import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer -import org.codehaus.groovy.ast.ClassHelper -import groovy.util.logging.Log - -def bootstrap = 'org.springframework.bootstrap.grapes.BootstrapGrapes' as Class - -void addImport(module, path) { - def name = path.lastIndexOf('.').with {it != -1 ? path[it+1.. - - def module = source.getAST() - - if (classNode.name.contains("Hadoop")) { - def hadoop = dependencySource.hadoop() as Class[] - ['org.springframework.data.hadoop.mapreduce.JobRunner', - 'org.springframework.data.hadoop.mapreduce.JobFactoryBean' - ].each { path -> addImport(module, path) } - module.addImport("HadoopConfiguration", ClassHelper.make("org.apache.hadoop.conf.Configuration"), []) - } - - classNode.annotations.each { - - def name = it.classNode.name - if (name=='Controller' || name=='EnableWebMvc') { - def web = dependencySource.web() as Class[] - ['org.springframework.web.bind.annotation.RequestBody', - 'org.springframework.web.bind.annotation.RequestParam', - 'org.springframework.web.bind.annotation.PathVariable', - 'org.springframework.web.bind.annotation.RequestHeader', - 'org.springframework.web.bind.annotation.RequestMethod', - 'org.springframework.web.bind.annotation.RequestBody', - 'org.springframework.web.bind.annotation.ResponseBody', - 'org.springframework.web.bind.annotation.ResponseStatus', - 'org.springframework.web.bind.annotation.RequestMapping', - 'org.springframework.web.bind.annotation.ExceptionHandler', - 'org.springframework.web.bind.annotation.ModelAttribute', - 'org.springframework.web.bind.annotation.CookieValue', - 'org.springframework.web.servlet.config.annotation.EnableWebMvc', - 'org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry', - 'org.springframework.web.servlet.config.annotation.ViewControllerRegistry', - 'org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter'].each { path -> addImport(module, path) } - } - - if (name=='EnableBatchProcessing') { - def batch = dependencySource.batch() as Class[] - ['org.springframework.batch.repeat.RepeatStatus', - 'org.springframework.batch.core.scope.context.ChunkContext', - 'org.springframework.batch.core.step.tasklet.Tasklet', - 'org.springframework.batch.core.configuration.annotation.StepScope', - 'org.springframework.batch.core.configuration.annotation.JobBuilderFactory', - 'org.springframework.batch.core.configuration.annotation.StepBuilderFactory', - 'org.springframework.batch.core.configuration.annotation.EnableBatchProcessing', - 'org.springframework.batch.core.Step', - 'org.springframework.batch.core.StepExecution', - 'org.springframework.batch.core.StepContribution', - 'org.springframework.batch.core.Job', - 'org.springframework.batch.core.JobExecution', - 'org.springframework.batch.core.JobParameter', - 'org.springframework.batch.core.JobParameters', - 'org.springframework.batch.core.launch.JobLauncher', - 'org.springframework.batch.core.converter.DefaultJobParametersConverter'].each { path -> addImport(module, path) } - } - - } - - } - -} diff --git a/spring-bootstrap-groovy/src/main/scripts/groovy.conf b/spring-bootstrap-groovy/src/main/scripts/groovy.conf deleted file mode 100644 index 0bbd3e79443..00000000000 --- a/spring-bootstrap-groovy/src/main/scripts/groovy.conf +++ /dev/null @@ -1,33 +0,0 @@ -############################################################################## -## ## -## Groovy Classloading Configuration ## -## ## -############################################################################## - -## -## $Revision$ $Date$ -## -## Note: do not add classes from java.lang here. No rt.jar and on some -## platforms no tools.jar -## -## See http://groovy.codehaus.org/api/org/codehaus/groovy/tools/LoaderConfiguration.html -## for the file format - - # load required libraries - load !{groovy.home}/lib/a*.jar - load !{groovy.home}/lib/b*.jar - load !{groovy.home}/lib/c*.jar - load !{groovy.home}/lib/g*.jar - load !{groovy.home}/lib/h*.jar - load !{groovy.home}/lib/i*.jar - load !{groovy.home}/lib/j*.jar - load !{groovy.home}/lib/q*.jar - load !{groovy.home}/lib/t*.jar - load !{groovy.home}/lib/x*.jar - - # load user specific libraries - load !{user.home}/.groovy/lib/*.jar - - # tools.jar for ant tasks - load ${tools.jar} - diff --git a/spring-bootstrap-groovy/src/main/scripts/spring b/spring-bootstrap-groovy/src/main/scripts/spring deleted file mode 100755 index 05ab21c6b82..00000000000 --- a/spring-bootstrap-groovy/src/main/scripts/spring +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/bash - -# OS specific support (must be 'true' or 'false'). -cygwin=false; -darwin=false; -case "`uname`" in - CYGWIN*) - cygwin=true - ;; - - Darwin*) - darwin=true - ;; -esac - -if [ "$SPRING_HOME" == "" ]; then - SPRING_HOME=`cd "$(dirname $0)"/.. && pwd` -fi -SPRING_BIN=$(dirname $0) - -export GROOVY_CONF="${SPRING_BIN}"/groovy.conf -SPRING_HANDLER=auto - -TARGETDIR=target/classes -if [ -f build.gradle ]; then - TARGETDIR=build/classes/main -fi -mkdir -p "${TARGETDIR%/}" - -function find_classfile { - classname="$( echo ${1%%.groovy} | sed -e 's,.*/,,')" - package="$( grep ^package ${1} | sed -e 's,package\s,,g' -e 's,;,,g' -e 's,\.,/,g')" - if [ "${package}" != "" ]; then package="${package}/"; fi - for f in $( find "${TARGETDIR}" -name "${classname}.class" ); do - if [ "${f}" == "${TARGETDIR}/${package}${classname}.class" ]; then - echo $f; return 0 - fi - done -} - -function is_compile_needed { - config=$1 - STATOPTS="-c %X" - if $darwin; then STATOPTS="-f %Dm"; fi - # Compile .groovy files if necessary - if [ ! -f ${config} ]; then - echo "File ${config} does not exist. Did you point at the wrong file?" - exit 3 - else - classfile=$( find_classfile ${config} ) - if [ ! -f "${classfile}" -o $(stat "${STATOPTS}" ${config}) -gt $(stat "${STATOPTS}" ${classfile} 2>/dev/null || echo 0) ]; then - return 0 - fi - fi - return 1 -} - -function is_option { - echo "$1" | grep -q "^--.*" -} - -function is_groovy { - [ "${1%%.groovy}" != "${1}" ] -} - -function convert_config_to_class { - classfile=$( find_classfile ${config} ) - if [ -z "${classfile}" ]; then - echo "No class found for ${config}. Compiler failed or class not defined?" - exit 1 - fi - config="${classfile#${TARGETDIR}/}" - while [ "${config%/*}" != "${config}" ]; do - config="${config%/*}"."${config##*/}" - done -} - -config=$1; shift -configs=() -compilables=() -while [ "$config" != "" ]; do - if is_groovy "$config"; then - if is_compile_needed "${config}"; then - compilables[${#compilables[@]}]="${config}" - fi - configs[${#configs[@]}]="${config}" - elif is_option "${config}"; then - case "${config%=*}" in - "--handler") SPRING_HANDLER="${config#*=}";; - esac - else - args[${#args[@]}]="${config}" - fi - config=$1; shift -done - -CLASSPATH="${SPRING_BIN}":"${TARGETDIR}" - -for f in "${SPRING_HOME}"/lib/*.jar; do - CLASSPATH="${CLASSPATH}":$f -done - -for f in "${SPRING_HOME}"/*.jar; do - CLASSPATH="${CLASSPATH}":$f -done - -if $cygwin; then - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` -fi - -if [ "${#compilables[@]}" -gt 0 ]; then - groovyc -cp "${CLASSPATH}" --configscript "$SPRING_BIN"/customizer.groovy -d "${TARGETDIR}" "${compilables[@]}" -fi - -config_classes=("org.springframework.bootstrap.grapes.BootstrapAutoConfiguration.class") -for config in "${configs[@]}"; do - convert_config_to_class - config_classes[${#config_classes[@]}]="${config}" -done - -if [ "${#config_classes[@]}" == "0" ]; then - echo "No files to run." - exit 2 -fi - -exec groovy -cp "${CLASSPATH}" -Dspring.home="${SPRING_HOME}" --configscript "$SPRING_BIN"/customizer.groovy "$SPRING_BIN"/spring-"${SPRING_HANDLER}".groovy "${config_classes[@]}" "${args[@]}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-bootstrap-groovy/src/main/scripts/spring-auto.groovy b/spring-bootstrap-groovy/src/main/scripts/spring-auto.groovy deleted file mode 100644 index 4db111fa794..00000000000 --- a/spring-bootstrap-groovy/src/main/scripts/spring-auto.groovy +++ /dev/null @@ -1,24 +0,0 @@ -// Get the args and turn them into classes -def configs = [] -def parameters = [] -args.each { arg -> - if (arg.endsWith(".class")) { - configs << arg.replaceAll(".class", "") - } else { - parameters << arg - } -} - -// Dynamically grab some dependencies -def dependencySource = "org.springframework.bootstrap.grapes.Dependencies" as Class // TODO: maybe strategise this -def dependencies = [*dependencySource.defaults(), *dependencySource.dependencies(configs)] -configs = dependencies + configs - -// Do this before any Spring auto stuff is used in case it enhances the classpath -configs = configs as Class[] -parameters = parameters as String[] - -// Now run the application -def applicationClass = "org.springframework.bootstrap.SpringApplication" as Class - -applicationClass.run(configs, parameters) diff --git a/spring-bootstrap-groovy/src/main/scripts/spring-vanilla.groovy b/spring-bootstrap-groovy/src/main/scripts/spring-vanilla.groovy deleted file mode 100644 index b085d8ad388..00000000000 --- a/spring-bootstrap-groovy/src/main/scripts/spring-vanilla.groovy +++ /dev/null @@ -1,27 +0,0 @@ -// Spring stuff needs to be on the system classloader apparently (when using @Configuration) -@GrabResolver(name='spring-milestone', root='http://maven.springframework.org/milestone') -@GrabConfig(systemClassLoader=true) -@Grab("org.springframework:spring-context:4.0.0.BOOTSTRAP-SNAPSHOT") -@GrabExclude("commons-logging:commons-logging") -@Grab("org.slf4j:jcl-over-slf4j:1.6.1") -@Grab("org.slf4j:slf4j-jdk14:1.6.1") -import org.springframework.context.annotation.AnnotationConfigApplicationContext - -// Now create a Spring context -AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext() -// Get the args and turn them into classes -def configs = [] -def parameters = [] -boolean endconfigs = false -args.each { arg -> - if (arg.endsWith(".class")) { - configs += arg.replaceAll(".class", "") - } else { - parameters += arg - } - } -configs = configs as Class[] -parameters = parameters as String[] -// Register the config classes, can be @Configuration or @Component etc. -ctx.register(configs) -ctx.refresh() diff --git a/spring-bootstrap-groovy/src/test/apps/App.groovy b/spring-bootstrap-groovy/src/test/apps/App.groovy deleted file mode 100644 index d39908e7e11..00000000000 --- a/spring-bootstrap-groovy/src/test/apps/App.groovy +++ /dev/null @@ -1,8 +0,0 @@ -@Controller -class App { - @RequestMapping("/") - @ResponseBody - String home() { - return "Hello World!" - } -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/test/apps/Empty.groovy b/spring-bootstrap-groovy/src/test/apps/Empty.groovy deleted file mode 100644 index d1fcdd80661..00000000000 --- a/spring-bootstrap-groovy/src/test/apps/Empty.groovy +++ /dev/null @@ -1,4 +0,0 @@ -@Configuration -class Empty { - -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/test/apps/JobConfig.groovy b/spring-bootstrap-groovy/src/test/apps/JobConfig.groovy deleted file mode 100644 index 9ec7c0ebb01..00000000000 --- a/spring-bootstrap-groovy/src/test/apps/JobConfig.groovy +++ /dev/null @@ -1,30 +0,0 @@ -@Grab("org.hsqldb:hsqldb-j5:2.0.0") -@EnableBatchProcessing -class JobConfig { - - @Autowired - private JobBuilderFactory jobs - - @Autowired - private StepBuilderFactory steps - - @Bean - protected Tasklet tasklet() { - return new Tasklet() { - RepeatStatus execute(StepContribution contribution, ChunkContext context) { - return RepeatStatus.FINISHED - } - } - } - - @Bean - Job job() throws Exception { - return jobs.get("job").start(step1()).build() - } - - @Bean - protected Step step1() throws Exception { - return steps.get("step1").tasklet(tasklet()).build() - } - -} diff --git a/spring-bootstrap-groovy/src/test/apps/Signal.groovy b/spring-bootstrap-groovy/src/test/apps/Signal.groovy deleted file mode 100644 index 9e13bee58d3..00000000000 --- a/spring-bootstrap-groovy/src/test/apps/Signal.groovy +++ /dev/null @@ -1,18 +0,0 @@ -import java.io.File; - -import org.springframework.bootstrap.CommandLineRunner; - -@Component -class Signal implements CommandLineRunner { - - private File messages = new File("target/messages") - - boolean ready = false - - @Override - void run(String... args) { - messages.mkdirs() - new File(messages, "ready").write("Ready!") - ready = true - } -} \ No newline at end of file diff --git a/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/BashEnv.groovy b/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/BashEnv.groovy deleted file mode 100644 index c9e170346fc..00000000000 --- a/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/BashEnv.groovy +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Cloud Foundry 2012.02.03 Beta - * Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. - * - * This product is licensed to you under the Apache License, Version 2.0 (the "License"). - * You may not use this product except in compliance with the License. - * - * This product includes a number of subcomponents with - * separate copyright notices and license terms. Your use of these - * subcomponents is subject to the terms and conditions of the - * subcomponent's license, as noted in the LICENSE file. - */ - -package org.springframework.bootstrap.groovy - -/** - *

As part of the gvm test suite we need to launch a bash shell and execute - * multiple commands in it. This is tricky to do using Java's support for - * working with external processes as the API can't tell you when a command - * has finished executing.

- *

This class provides some hacks that allow you to serially execute commands - * in an external bash process in a fairly reliable manner and to retrieve the - * output of those commands.

- */ -class BashEnv { - - static final PROMPT = "" - static final EXIT_CODE_CMD = 'echo "Exit code is: $?"' - static final EXIT_CODE_PATTERN = ~/Exit code is: (\d+)\s*${PROMPT}?$/ - - private final Object outputLock = new Object() - - def exitCode - def process - def processOutput = new StringBuilder() - def commandOutput - - // Command timeout in milliseconds - def timeout = 5000 - def workDir - def env - - BashEnv(workDir, Map env) { - this.workDir = workDir as File - - env = env + [PS1: PROMPT] - this.env = env.collect { k, v -> k + '=' + v } - } - - /** - * Starts the external bash process. - */ - void start() { - process = ["bash", "--noprofile", "--norc", "-i"].execute(env, workDir) - - consumeProcessStream(process.inputStream) - consumeProcessStream(process.errorStream) - } - - /** - * Stops the external bash process and waits for it to finish. - */ - void stop() { - execute("exit") - process.waitFor() - } - - /** - * Sends a command line to the external bash process and returns once the - * command has finished executing. If the command is interactive and requires - * input during it's execution (for example a y/n answer to a question) you - * can provide that input as a list of strings. - */ - void execute(String cmdline, List inputs = []) { - resetOutput() - - if (cmdline != "exit") { - exitCode = null - } - - process.outputStream << cmdline << "\n" - process.outputStream.flush() - - if (cmdline != "exit") { - for (input in inputs) { - process.outputStream << input << "\n" - } - process.outputStream << EXIT_CODE_CMD << "\n" - process.outputStream.flush() - } - - def start = System.currentTimeMillis() - while (cmdline != "exit") { - Thread.sleep 100 - - synchronized (outputLock) { - // Remove all the extraneous text that's not related to the - // command's output. This includes the command string itself, - // the 'echo' command to display the command's exit code, and - // the exit code line. - removeFromOutput(cmdline + "\n") - removeFromOutput(PROMPT + EXIT_CODE_CMD + "\n") - - def str = processOutput.toString() - def m = EXIT_CODE_PATTERN.matcher(str) - commandOutput = str - if (m) { - exitCode = m[0][1] - - // Remove this exit code line from the output. - commandOutput = m.replaceAll('') - break - } - - // If the command times out, we should break out of the loop and - // display whatever output has already been produced. - if (System.currentTimeMillis() - start > timeout) { - commandOutput = "ALERT! Command timed out. Last output was:\n\n${processOutput}" - break - } - } - } - } - - /** - * Returns the exit code of the last command that was executed. - */ - int getStatus() { - if (!exitCode) throw new IllegalStateException("Did you run execute() before getting the status?") - return exitCode.toInteger() - } - - /** - * Returns the text output (both stdout and stderr) of the last command - * that was executed. - */ - String getOutput() { - return commandOutput - } - - /** - * Clears the saved command output. - */ - void resetOutput() { - synchronized (outputLock) { - processOutput = new StringBuilder() - } - } - - private void consumeProcessStream(final InputStream stream) { - char[] buffer = new char[256] - Thread.start { - def reader = new InputStreamReader(stream) - def charsRead = 0 - while (charsRead != -1) { - charsRead = reader.read(buffer, 0, 256) - if (charsRead > 0) { - synchronized (outputLock) { - processOutput.append(buffer, 0, charsRead) - } - } - } - } - } - - private void removeFromOutput(String line) { - synchronized (outputLock) { - def pos = processOutput.indexOf(line) - if (pos != -1) { - processOutput.delete(pos, pos + line.size() - 1) - } - } - } -} diff --git a/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/ScriptTests.groovy b/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/ScriptTests.groovy deleted file mode 100644 index fbeeb7890df..00000000000 --- a/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/ScriptTests.groovy +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Cloud Foundry 2012.02.03 Beta - * Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. - * - * This product is licensed to you under the Apache License, Version 2.0 (the "License"). - * You may not use this product except in compliance with the License. - * - * This product includes a number of subcomponents with - * separate copyright notices and license terms. Your use of these - * subcomponents is subject to the terms and conditions of the - * subcomponent's license, as noted in the LICENSE file. - */ - -package org.springframework.bootstrap.groovy; - -import static org.junit.Assert.* - -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors - -import org.junit.After -import org.junit.Before -import org.junit.Test - -/** - * @author Dave Syer - * - */ -class ScriptTests { - - private BashEnv bash - - private ExecutorService executor = Executors.newFixedThreadPool(2) - - @Before - void init() { - bash = new BashEnv(".", [SPRING_HOME: "target"]) - bash.start() - bash.execute("export GVM_DIR=~/.gvm") - bash.execute("source ~/.gvm/bin/gvm-init.sh") - assertEquals("You need to install gvm to run these tests", 0, bash.status) - bash.execute("gvm use groovy 2.1.0") - assertEquals("You need to do this before running the tests: > gvm install groovy 2.1.0", 0, bash.status) - } - - @After - void clean() { - bash?.stop() - } - - @Test - void testVanillaApplicationContext() { - execute(bash, "src/main/scripts/spring src/test/apps/Empty.groovy") - assertEquals(0, bash.status) - } - - @Test - void testBatchApplicationContext() { - execute(bash, "src/main/scripts/spring src/test/apps/JobConfig.groovy foo=bar") - assertEquals(0, bash.status) - assertTrue(bash.output.contains("[SimpleJob: [name=job]] completed with the following parameters: [{foo=bar}]")) - } - - private void execute(BashEnv bash, String cmdline) { - bash.execute(cmdline) - if (bash.exitCode && bash.status!=0) { - println "Unsuccessful execution (${cmdline}). Output: \n${bash.output}" - } - } -} diff --git a/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/WebScriptTests.groovy b/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/WebScriptTests.groovy deleted file mode 100644 index e17620e5b75..00000000000 --- a/spring-bootstrap-groovy/src/test/java/org/springframework/bootstrap/groovy/WebScriptTests.groovy +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Cloud Foundry 2012.02.03 Beta - * Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved. - * - * This product is licensed to you under the Apache License, Version 2.0 (the "License"). - * You may not use this product except in compliance with the License. - * - * This product includes a number of subcomponents with - * separate copyright notices and license terms. Your use of these - * subcomponents is subject to the terms and conditions of the - * subcomponent's license, as noted in the LICENSE file. - */ - -package org.springframework.bootstrap.groovy; - -import static org.junit.Assert.* - -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors - -import org.junit.After -import org.junit.Before -import org.junit.Ignore -import org.junit.Test -import org.springframework.web.client.RestTemplate - -/** - * @author Dave Syer - * - */ -class WebScriptTests { - - private BashEnv bash - - private ExecutorService executor = Executors.newFixedThreadPool(2) - - private File messages = new File("target/messages") - - @Before - void init() { - assertTrue("Couldn't delete messages directory", messages.deleteDir()) - bash = new BashEnv(".", [SPRING_HOME: "target"]) - bash.start() - bash.execute("export GVM_DIR=~/.gvm") - bash.execute("source ~/.gvm/bin/gvm-init.sh") - assertEquals("You need to install gvm to run these tests", 0, bash.status) - bash.execute("gvm use groovy 2.1.0") - assertEquals("You need to do this before running the tests: > gvm install groovy 2.1.0", 0, bash.status) - } - - @After - void clean() { - killit() - bash?.stop() - } - - @Test - @Ignore - void testWebApplicationContext() { - executor.submit { - execute(bash, "src/main/scripts/spring src/test/apps/App.groovy src/test/apps/Signal.groovy") - } - File ready = new File(messages, "ready") - long timeout = 10000 - long t0 = System.currentTimeMillis() - while (!ready.exists() && System.currentTimeMillis() - t0 < timeout) { - println "Waiting for app to start" - Thread.sleep(1000) - } - if (ready.exists()) { - println ready.text - } else { - fail("Timed out waiting for app to start") - } - - // assertEquals(0, bash.status) - def response = new RestTemplate().getForEntity("http://localhost:8080", String.class) - assertEquals("Hello World!", response.body) - } - - private void killit() { - BashEnv reaper = new BashEnv(".", [SPRING_HOME: "target"]) - reaper.start() - reaper?.execute("pkill -9 -f '\\--configscript src/main/scripts/customizer.groovy'") - reaper?.stop() - } - - private void execute(BashEnv bash, String cmdline) { - bash.execute(cmdline) - if (bash.exitCode && bash.status!=0) { - println "Unsuccessful execution (${cmdline}). Output: \n${bash.output}" - } - } -}