Add springcli.properties for version labels
[Fixes #53030591] [bs-191] Use filtering in maven build
This commit is contained in:
parent
c055cf063d
commit
fff2a804bc
5
pom.xml
5
pom.xml
|
|
@ -18,6 +18,7 @@
|
||||||
<spring.security.version>3.2.0.M2</spring.security.version>
|
<spring.security.version>3.2.0.M2</spring.security.version>
|
||||||
<spring.integration.version>2.2.4.RELEASE</spring.integration.version>
|
<spring.integration.version>2.2.4.RELEASE</spring.integration.version>
|
||||||
<spring.batch.version>2.2.0.RELEASE</spring.batch.version>
|
<spring.batch.version>2.2.0.RELEASE</spring.batch.version>
|
||||||
|
<groovy.version>2.1.6</groovy.version>
|
||||||
<tomcat.version>7.0.42</tomcat.version>
|
<tomcat.version>7.0.42</tomcat.version>
|
||||||
<jetty.version>8.1.9.v20130131</jetty.version>
|
<jetty.version>8.1.9.v20130131</jetty.version>
|
||||||
<aspectj.version>1.7.3</aspectj.version>
|
<aspectj.version>1.7.3</aspectj.version>
|
||||||
|
|
@ -352,12 +353,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
<artifactId>groovy</artifactId>
|
<artifactId>groovy</artifactId>
|
||||||
<version>2.1.6</version>
|
<version>${groovy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
<artifactId>groovy-templates</artifactId>
|
<artifactId>groovy-templates</artifactId>
|
||||||
<version>2.1.6</version>
|
<version>${groovy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import java.security.ProtectionDomain;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
@ -47,11 +48,17 @@ class StartupInfoLogger {
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
message.append("Starting ");
|
message.append("Starting ");
|
||||||
message.append(getApplicationName());
|
message.append(getApplicationName());
|
||||||
message.append(getVersion());
|
message.append(getVersion(this.sourceClass));
|
||||||
message.append(getOn());
|
message.append(getOn());
|
||||||
message.append(getPid());
|
message.append(getPid());
|
||||||
message.append(getContext());
|
message.append(getContext());
|
||||||
log.info(message);
|
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() {
|
private String getApplicationName() {
|
||||||
|
|
@ -59,14 +66,13 @@ class StartupInfoLogger {
|
||||||
: "application");
|
: "application");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getVersion() {
|
private String getVersion(final Class<?> source) {
|
||||||
return getValue(" v", new Callable<Object>() {
|
return getValue(" v", new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
return StartupInfoLogger.this.sourceClass.getPackage()
|
return source.getPackage().getImplementationVersion();
|
||||||
.getImplementationVersion();
|
|
||||||
}
|
}
|
||||||
});
|
}, " v[N/A]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOn() {
|
private String getOn() {
|
||||||
|
|
@ -129,6 +135,10 @@ class StartupInfoLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getValue(String prefix, Callable<Object> call) {
|
private String getValue(String prefix, Callable<Object> call) {
|
||||||
|
return getValue(prefix, call, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getValue(String prefix, Callable<Object> call, String defaultValue) {
|
||||||
try {
|
try {
|
||||||
Object value = call.call();
|
Object value = call.call();
|
||||||
if (value != null && StringUtils.hasLength(value.toString())) {
|
if (value != null && StringUtils.hasLength(value.toString())) {
|
||||||
|
|
@ -138,6 +148,6 @@ class StartupInfoLogger {
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
// Swallow and continue
|
// Swallow and continue
|
||||||
}
|
}
|
||||||
return "";
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -35,6 +35,12 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,14 @@ import groovy.grape.Grape;
|
||||||
import groovy.lang.Grapes;
|
import groovy.lang.Grapes;
|
||||||
import groovy.lang.GroovyClassLoader;
|
import groovy.lang.GroovyClassLoader;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customizer that allows dependencies to be added during compilation. Delegates to Groovy
|
* Customizer that allows dependencies to be added during compilation. Delegates to Groovy
|
||||||
|
|
@ -40,6 +43,8 @@ public class DependencyCustomizer {
|
||||||
|
|
||||||
private final List<Map<String, Object>> dependencies;
|
private final List<Map<String, Object>> dependencies;
|
||||||
|
|
||||||
|
private Properties properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link DependencyCustomizer} instance. The {@link #call()} method must
|
* Create a new {@link DependencyCustomizer} instance. The {@link #call()} method must
|
||||||
* be used to actually resolve dependencies.
|
* be used to actually resolve dependencies.
|
||||||
|
|
@ -59,6 +64,26 @@ public class DependencyCustomizer {
|
||||||
this.dependencies = parent.dependencies;
|
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
|
* Create a nested {@link DependencyCustomizer} that only applies if any of the
|
||||||
* specified class names are not on the class path.
|
* specified class names are not on the class path.
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,11 @@ public class SpringBatchCompilerAutoConfiguration extends CompilerAutoConfigurat
|
||||||
@Override
|
@Override
|
||||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||||
dependencies.ifAnyMissingClasses("org.springframework.batch.core.Job").add(
|
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")
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ public class SpringCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||||
dependencies.ifAnyMissingClasses(
|
dependencies.ifAnyMissingClasses(
|
||||||
"org.springframework.bootstrap.SpringApplication").add(
|
"org.springframework.bootstrap.SpringApplication").add(
|
||||||
"org.springframework.zero", "spring-starter", "0.5.0.BUILD-SNAPSHOT");
|
"org.springframework.zero", "spring-starter",
|
||||||
// FIXME get the version
|
dependencies.getProperty("spring.zero.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -73,7 +73,7 @@ public class SpringCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||||
public void applyToMainClass(GroovyClassLoader loader,
|
public void applyToMainClass(GroovyClassLoader loader,
|
||||||
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
|
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
|
||||||
SourceUnit source, ClassNode classNode) throws CompilationFailedException {
|
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);
|
addEnableAutoConfigurationAnnotation(source, classNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,14 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf
|
||||||
dependencies
|
dependencies
|
||||||
.ifAnyMissingClasses("org.springframework.integration.Message")
|
.ifAnyMissingClasses("org.springframework.integration.Message")
|
||||||
.add("org.springframework.integration", "spring-integration-core",
|
.add("org.springframework.integration", "spring-integration-core",
|
||||||
"2.2.3.RELEASE")
|
dependencies.getProperty("spring.integration.version"))
|
||||||
.add("org.springframework.integration",
|
.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(
|
dependencies.ifAnyMissingClasses("groovy.util.XmlParser").add(
|
||||||
"org.codehaus.groovy", "groovy-xml", "2.1.6");
|
"org.codehaus.groovy", "groovy-xml",
|
||||||
|
dependencies.getProperty("groovy.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -34,18 +34,21 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
|
||||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||||
dependencies
|
dependencies
|
||||||
.ifAnyMissingClasses("org.springframework.web.servlet.mvc.Controller")
|
.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",
|
dependencies.ifAnyMissingClasses("org.eclipse.jetty.server.Server").add(
|
||||||
"org.eclipse.jetty.server.Server").add("org.eclipse.jetty",
|
"org.eclipse.jetty", "jetty-webapp",
|
||||||
"jetty-webapp", "8.1.10.v20130312");
|
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
|
// FIXME restore Tomcat when we can get reload to work
|
||||||
// dependencies.ifMissingClasses("org.apache.catalina.startup.Tomcat",
|
// dependencies.ifMissingClasses("org.apache.catalina.startup.Tomcat")
|
||||||
// "org.eclipse.jetty.server.Server")
|
// .add("org.apache.tomcat.embed", "tomcat-embed-core",
|
||||||
// .add("org.apache.tomcat.embed", "tomcat-embed-core", "7.0.39")
|
// dependencies.getProperty("tomcat.version"))
|
||||||
// .add("org.apache.tomcat.embed", "tomcat-embed-logging-juli", "7.0.39");
|
// .add("org.apache.tomcat.embed", "tomcat-embed-logging-juli",
|
||||||
|
// dependencies.getProperty("tomcat.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<!-- NOTE: Intentionally does not inherit from root parent. Autogenerated,
|
<!-- NOTE: Intentionally does not inherit from root parent. Autogenerated,
|
||||||
from ../src/main/parent do not edit. -->
|
do not edit. -->
|
||||||
<groupId>org.springframework.zero</groupId>
|
<groupId>org.springframework.zero</groupId>
|
||||||
<artifactId>spring-starter-parent</artifactId>
|
<artifactId>spring-starter-parent</artifactId>
|
||||||
<version>0.5.0.BUILD-SNAPSHOT</version>
|
<version>0.5.0.BUILD-SNAPSHOT</version>
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n%wex"/>
|
||||||
|
|
||||||
|
<conversionRule conversionWord="wex" converterClass="org.springframework.bootstrap.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||||
|
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--logger name="org.springframework.zero" level="DEBUG"/>
|
||||||
|
<logger name="org.springframework.security" level="DEBUG"/-->
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
Loading…
Reference in New Issue