diff --git a/pom.xml b/pom.xml index d0f6f4e65a..1d9b647e4e 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ 3.2.0.M2 2.2.4.RELEASE 2.2.0.RELEASE + 2.1.6 7.0.42 8.1.9.v20130131 1.7.3 @@ -352,12 +353,12 @@ org.codehaus.groovy groovy - 2.1.6 + ${groovy.version} org.codehaus.groovy groovy-templates - 2.1.6 + ${groovy.version} org.codehaus.plexus diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/StartupInfoLogger.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/StartupInfoLogger.java index 368b9d48e4..4c799e5559 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/StartupInfoLogger.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/StartupInfoLogger.java @@ -25,6 +25,7 @@ import java.security.ProtectionDomain; import java.util.concurrent.Callable; import org.apache.commons.logging.Log; +import org.springframework.context.ApplicationContext; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; @@ -47,11 +48,17 @@ class StartupInfoLogger { StringBuilder message = new StringBuilder(); message.append("Starting "); message.append(getApplicationName()); - message.append(getVersion()); + message.append(getVersion(this.sourceClass)); message.append(getOn()); message.append(getPid()); message.append(getContext()); log.info(message); + message.setLength(0); + message.append("Running with Spring Bootstrap"); + message.append(getVersion(SpringApplication.class)); + message.append(", Spring"); + message.append(getVersion(ApplicationContext.class)); + log.info(message); } private String getApplicationName() { @@ -59,14 +66,13 @@ class StartupInfoLogger { : "application"); } - private String getVersion() { + private String getVersion(final Class source) { return getValue(" v", new Callable() { @Override public Object call() throws Exception { - return StartupInfoLogger.this.sourceClass.getPackage() - .getImplementationVersion(); + return source.getPackage().getImplementationVersion(); } - }); + }, " v[N/A]"); } private String getOn() { @@ -129,6 +135,10 @@ class StartupInfoLogger { } private String getValue(String prefix, Callable call) { + return getValue(prefix, call, ""); + } + + private String getValue(String prefix, Callable call, String defaultValue) { try { Object value = call.call(); if (value != null && StringUtils.hasLength(value.toString())) { @@ -138,6 +148,6 @@ class StartupInfoLogger { catch (Exception ex) { // Swallow and continue } - return ""; + return defaultValue; } } diff --git a/spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLoggerInfoTests.java b/spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLoggerInfoTests.java new file mode 100644 index 0000000000..fa17d26c87 --- /dev/null +++ b/spring-bootstrap/src/test/java/org/springframework/bootstrap/StartUpLoggerInfoTests.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.bootstrap; + +import org.apache.commons.logging.impl.SimpleLog; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +/** + * @author Dave Syer + */ +public class StartUpLoggerInfoTests { + + private StringBuffer output = new StringBuffer(); + + private SimpleLog log = new SimpleLog("test") { + @Override + protected void write(StringBuffer buffer) { + StartUpLoggerInfoTests.this.output.append(buffer).append("\n"); + }; + }; + + @Test + public void sourceClassIncluded() { + new StartupInfoLogger(getClass()).log(this.log); + assertTrue("Wrong output: " + this.output, + this.output.toString().contains("Starting " + getClass().getSimpleName())); + // System.err.println(this.output); + } + + @Test + public void bootstrapVersionIncluded() { + new StartupInfoLogger(getClass()).log(this.log); + assertTrue("Wrong output: " + this.output, + this.output.toString().contains("Spring Bootstrap v")); + } + +} diff --git a/spring-cli/pom.xml b/spring-cli/pom.xml index e156314342..1ae8e8f39c 100644 --- a/spring-cli/pom.xml +++ b/spring-cli/pom.xml @@ -35,6 +35,12 @@ + + + src/main/resources + true + + maven-shade-plugin diff --git a/spring-cli/src/main/java/org/springframework/cli/compiler/DependencyCustomizer.java b/spring-cli/src/main/java/org/springframework/cli/compiler/DependencyCustomizer.java index aae2a74ccd..dd8d4617b2 100644 --- a/spring-cli/src/main/java/org/springframework/cli/compiler/DependencyCustomizer.java +++ b/spring-cli/src/main/java/org/springframework/cli/compiler/DependencyCustomizer.java @@ -20,11 +20,14 @@ import groovy.grape.Grape; import groovy.lang.Grapes; import groovy.lang.GroovyClassLoader; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; /** * Customizer that allows dependencies to be added during compilation. Delegates to Groovy @@ -40,6 +43,8 @@ public class DependencyCustomizer { private final List> dependencies; + private Properties properties; + /** * Create a new {@link DependencyCustomizer} instance. The {@link #call()} method must * be used to actually resolve dependencies. @@ -59,6 +64,26 @@ public class DependencyCustomizer { this.dependencies = parent.dependencies; } + public String getProperty(String key) { + return getProperty(key, ""); + } + + public String getProperty(String key, String defaultValue) { + if (this.properties == null) { + this.properties = new Properties(); + try { + for (URL url : Collections.list(this.loader + .getResources("META-INF/springcli.properties"))) { + this.properties.load(url.openStream()); + } + } + catch (Exception e) { + // swallow and continue + } + } + return this.properties.getProperty(key, defaultValue); + } + /** * Create a nested {@link DependencyCustomizer} that only applies if any of the * specified class names are not on the class path. diff --git a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringBatchCompilerAutoConfiguration.java b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringBatchCompilerAutoConfiguration.java index b1a631008e..b96ee1b8a0 100644 --- a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringBatchCompilerAutoConfiguration.java +++ b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringBatchCompilerAutoConfiguration.java @@ -38,9 +38,11 @@ public class SpringBatchCompilerAutoConfiguration extends CompilerAutoConfigurat @Override public void applyDependencies(DependencyCustomizer dependencies) { dependencies.ifAnyMissingClasses("org.springframework.batch.core.Job").add( - "org.springframework.batch", "spring-batch-core", "2.2.0.RC2"); + "org.springframework.batch", "spring-batch-core", + dependencies.getProperty("spring.batch.version", "2.2.0.RELEASE")); dependencies.ifAnyMissingClasses("org.springframework.jdbc.core.JdbcTemplate") - .add("org.springframework", "spring-jdbc", "4.0.0.BUILD-SNAPSHOT"); + .add("org.springframework", "spring-jdbc", + dependencies.getProperty("spring.version")); } @Override diff --git a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringCompilerAutoConfiguration.java b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringCompilerAutoConfiguration.java index f5781cce7a..9387238f88 100644 --- a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringCompilerAutoConfiguration.java +++ b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringCompilerAutoConfiguration.java @@ -40,8 +40,8 @@ public class SpringCompilerAutoConfiguration extends CompilerAutoConfiguration { public void applyDependencies(DependencyCustomizer dependencies) { dependencies.ifAnyMissingClasses( "org.springframework.bootstrap.SpringApplication").add( - "org.springframework.zero", "spring-starter", "0.5.0.BUILD-SNAPSHOT"); - // FIXME get the version + "org.springframework.zero", "spring-starter", + dependencies.getProperty("spring.zero.version")); } @Override @@ -73,7 +73,7 @@ public class SpringCompilerAutoConfiguration extends CompilerAutoConfiguration { public void applyToMainClass(GroovyClassLoader loader, GroovyCompilerConfiguration configuration, GeneratorContext generatorContext, SourceUnit source, ClassNode classNode) throws CompilationFailedException { - // FIXME: add switch for auto config + // Could add switch for auto config, but it seems like it wouldn't get used much addEnableAutoConfigurationAnnotation(source, classNode); } diff --git a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java index 10ffec1bda..d8451c5cb6 100644 --- a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java +++ b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java @@ -48,11 +48,14 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf dependencies .ifAnyMissingClasses("org.springframework.integration.Message") .add("org.springframework.integration", "spring-integration-core", - "2.2.3.RELEASE") + dependencies.getProperty("spring.integration.version")) .add("org.springframework.integration", - "spring-integration-dsl-groovy-core", "1.0.0.M1"); + "spring-integration-dsl-groovy-core", + dependencies.getProperty("spring.integration.dsl.version", + "1.0.0.M1")); dependencies.ifAnyMissingClasses("groovy.util.XmlParser").add( - "org.codehaus.groovy", "groovy-xml", "2.1.6"); + "org.codehaus.groovy", "groovy-xml", + dependencies.getProperty("groovy.version")); } @Override diff --git a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringMvcCompilerAutoConfiguration.java b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringMvcCompilerAutoConfiguration.java index fc144bd2a6..c952ba8a95 100644 --- a/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringMvcCompilerAutoConfiguration.java +++ b/spring-cli/src/main/java/org/springframework/cli/compiler/autoconfigure/SpringMvcCompilerAutoConfiguration.java @@ -34,18 +34,21 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio public void applyDependencies(DependencyCustomizer dependencies) { dependencies .ifAnyMissingClasses("org.springframework.web.servlet.mvc.Controller") - .add("org.springframework", "spring-webmvc", "4.0.0.BUILD-SNAPSHOT"); + .add("org.springframework", "spring-webmvc", + dependencies.getProperty("spring.version")); - dependencies.ifAnyMissingClasses("org.apache.catalina.startup.Tomcat", - "org.eclipse.jetty.server.Server").add("org.eclipse.jetty", - "jetty-webapp", "8.1.10.v20130312"); + dependencies.ifAnyMissingClasses("org.eclipse.jetty.server.Server").add( + "org.eclipse.jetty", "jetty-webapp", + dependencies.getProperty("jetty.version")); - dependencies.add("org.codehaus.groovy", "groovy-templates", "2.1.6"); + dependencies.add("org.codehaus.groovy", "groovy-templates", + dependencies.getProperty("groovy.version")); // FIXME restore Tomcat when we can get reload to work - // dependencies.ifMissingClasses("org.apache.catalina.startup.Tomcat", - // "org.eclipse.jetty.server.Server") - // .add("org.apache.tomcat.embed", "tomcat-embed-core", "7.0.39") - // .add("org.apache.tomcat.embed", "tomcat-embed-logging-juli", "7.0.39"); + // dependencies.ifMissingClasses("org.apache.catalina.startup.Tomcat") + // .add("org.apache.tomcat.embed", "tomcat-embed-core", + // dependencies.getProperty("tomcat.version")) + // .add("org.apache.tomcat.embed", "tomcat-embed-logging-juli", + // dependencies.getProperty("tomcat.version")); } @Override diff --git a/spring-cli/src/main/resources/META-INF/springcli.properties b/spring-cli/src/main/resources/META-INF/springcli.properties new file mode 100644 index 0000000000..e8c9937e72 --- /dev/null +++ b/spring-cli/src/main/resources/META-INF/springcli.properties @@ -0,0 +1,7 @@ +spring.zero.version: ${project.version} +spring.version: ${spring.version} +spring.batch.version: ${spring.batch.version} +spring.integration.version: ${spring.integration.version} +groovy.version: ${groovy.version} +jetty.version: ${jetty.version} +tomcat.version: ${tomcat.version} \ No newline at end of file diff --git a/spring-starters/spring-starter-parent/pom.xml b/spring-starters/spring-starter-parent/pom.xml index a9094c225d..52e573b463 100644 --- a/spring-starters/spring-starter-parent/pom.xml +++ b/spring-starters/spring-starter-parent/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + do not edit. --> org.springframework.zero spring-starter-parent 0.5.0.BUILD-SNAPSHOT diff --git a/spring-zero-samples/spring-zero-sample-actuator-ui/src/test/resources/logging.properties b/spring-zero-samples/spring-zero-sample-actuator-ui/src/test/resources/logging.properties deleted file mode 100644 index e423ea60da..0000000000 --- a/spring-zero-samples/spring-zero-sample-actuator-ui/src/test/resources/logging.properties +++ /dev/null @@ -1,7 +0,0 @@ -handlers = java.util.logging.ConsoleHandler -.level = INFO - -java.util.logging.ConsoleHandler.level = FINE -sun.net.www.protocol.http.HttpURLConnection.level = ALL -org.springframework.zero.context.annotation.level = ALL -org.springframework.zero.actuate.autoconfigure.level = ALL diff --git a/spring-zero-samples/spring-zero-sample-actuator/src/main/resources/logback.xml b/spring-zero-samples/spring-zero-sample-actuator/src/main/resources/logback.xml new file mode 100644 index 0000000000..402304a693 --- /dev/null +++ b/spring-zero-samples/spring-zero-sample-actuator/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + + + + + diff --git a/spring-zero-samples/spring-zero-sample-actuator/src/main/resources/logging.properties b/spring-zero-samples/spring-zero-sample-actuator/src/main/resources/logging.properties deleted file mode 100644 index b1899920c5..0000000000 --- a/spring-zero-samples/spring-zero-sample-actuator/src/main/resources/logging.properties +++ /dev/null @@ -1,7 +0,0 @@ -handlers = java.util.logging.ConsoleHandler -.level = INFO - -#java.util.logging.ConsoleHandler.level = FINE -#sun.net.www.protocol.http.HttpURLConnection.level = ALL -#org.springframework.zero.level = ALL -#org.springframework.security.level = ALL diff --git a/spring-zero-samples/spring-zero-sample-web-ui/src/test/resources/logging.properties b/spring-zero-samples/spring-zero-sample-web-ui/src/test/resources/logging.properties deleted file mode 100644 index 95c0d6b589..0000000000 --- a/spring-zero-samples/spring-zero-sample-web-ui/src/test/resources/logging.properties +++ /dev/null @@ -1,6 +0,0 @@ -handlers = java.util.logging.ConsoleHandler -.level = INFO - -java.util.logging.ConsoleHandler.level = FINE -sun.net.www.protocol.http.HttpURLConnection.level = ALL -org.springframework.zero.context.annotation.level = ALL