This commit is contained in:
Phillip Webb 2014-06-06 22:33:46 -07:00
parent 93aefa8537
commit e891aa3525
30 changed files with 196 additions and 174 deletions

View File

@ -81,14 +81,12 @@ import org.springframework.util.StringUtils;
* into a Spring Boot enabled application. By default a SSH daemon is started on port
* 2000. If the CRaSH Telnet plugin is available on the classpath, Telnet daemon will be
* launched on port 5000.
*
* <p>
* The default shell authentication method uses a username and password combination. If no
* configuration is provided the default username is 'user' and the password will be
* printed to console during application startup. Those default values can be overridden
* by using <code>shell.auth.simple.username</code> and
* <code>shell.auth.simple.password</code>.
*
* <p>
* If a Spring Security {@link AuthenticationManager} is detected, this configuration will
* create a {@link CRaSHPlugin} to forward shell authentication requests to Spring
@ -98,21 +96,19 @@ import org.springframework.util.StringUtils;
* restricted to users having roles that match those configured in
* {@link ManagementServerProperties}. Required roles can be overridden by
* <code>shell.auth.spring.roles</code>.
*
* <p>
* To add customizations to the shell simply define beans of type {@link CRaSHPlugin} in
* the application context. Those beans will get auto detected during startup and
* registered with the underlying shell infrastructure. To configure plugins and the CRaSH
* infrastructure add beans of type {@link CrshShellProperties} to the application
* context.
*
* <p>
* Additional shell commands can be implemented using the guide and documentation at <a
* href="http://www.crashub.org">crashub.org</a>. By default Boot will search for commands
* using the following classpath scanning pattern <code>classpath*:/commands/**</code>. To
* add different locations or override the default use
* <code>shell.command_path_patterns</code> in your application configuration.
*
*
* @author Christian Dupuis
* @see ShellProperties
*/

View File

@ -58,7 +58,7 @@ import static org.junit.Assert.assertTrue;
/**
* Tests for {@link CrshAutoConfiguration}.
*
*
* @author Christian Dupuis
*/
@SuppressWarnings({ "rawtypes", "unchecked" })

View File

@ -48,7 +48,7 @@ public abstract class AutoConfigurationPackages {
/**
* Determine if the auto-configuration base packages for the given bean factory are
* available
* available.
* @param beanFactory the source bean factory
* @return true if there are auto-config packages available
*/

View File

@ -1,5 +1,5 @@
/*
On * Copyright 2012-2014 the original author or authors.
* 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.

View File

@ -32,7 +32,7 @@ import org.springframework.util.StringUtils;
/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
* Auto-configuration} for Elasticsearch.
*
*
* @author Artur Konczak
* @author Mohsin Husen
* @author Andy Wilkinson
@ -54,17 +54,19 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
@Bean
public Client elasticsearchClient() {
try {
if (StringUtils.hasLength(this.properties.getClusterNodes())) {
this.client = createTransportClient();
}
else {
this.client = createNodeClient();
}
this.client = createClient();
return this.client;
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
return this.client;
}
private Client createClient() throws Exception {
if (StringUtils.hasLength(this.properties.getClusterNodes())) {
return createTransportClient();
}
return createNodeClient();
}
private Client createNodeClient() throws Exception {

View File

@ -20,7 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Configuration properties for Elasticsearch.
*
*
* @author Artur Konczak
* @author Mohsin Husen
* @since 1.1.0

View File

@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* 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.
@ -32,7 +32,7 @@ import org.springframework.integration.jmx.config.IntegrationMBeanExportConfigur
*
* @author Artem Bilan
* @author Dave Syer
* @since 1.1
* @since 1.1.0
*/
@Configuration
@ConditionalOnClass(EnableIntegration.class)

View File

@ -49,7 +49,7 @@ import com.fasterxml.jackson.datatype.jsr310.JSR310Module;
* <li>auto-registration for all {@link Module} beans with all {@link ObjectMapper} beans
* (including the defaulted ones).</li>
* </ul>
*
*
* @author Oliver Gierke
* @since 1.1.0
*/
@ -65,33 +65,29 @@ public class JacksonAutoConfiguration {
private ListableBeanFactory beanFactory;
@Bean
@ConditionalOnMissingBean
@Primary
@ConditionalOnMissingBean
public ObjectMapper jacksonObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
if (this.properties.isJsonSortKeys()) {
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
}
return objectMapper;
}
@PostConstruct
public void init() {
Collection<ObjectMapper> mappers = BeanFactoryUtils
.beansOfTypeIncludingAncestors(this.beanFactory, ObjectMapper.class)
.values();
Collection<Module> modules = BeanFactoryUtils.beansOfTypeIncludingAncestors(
this.beanFactory, Module.class).values();
for (ObjectMapper mapper : mappers) {
mapper.registerModules(modules);
private void registerModulesWithObjectMappers() {
Collection<Module> modules = getBeans(Module.class);
for (ObjectMapper objectMapper : getBeans(ObjectMapper.class)) {
objectMapper.registerModules(modules);
}
}
private <T> Collection<T> getBeans(Class<T> type) {
return BeanFactoryUtils.beansOfTypeIncludingAncestors(this.beanFactory, type)
.values();
}
@Configuration
@ConditionalOnClass(JodaModule.class)
static class JodaModuleAutoConfiguration {
@ -101,6 +97,7 @@ public class JacksonAutoConfiguration {
JodaModule jacksonJodaModule() {
return new JodaModule();
}
}
@Configuration
@ -113,5 +110,6 @@ public class JacksonAutoConfiguration {
JSR310Module jacksonJsr310Module() {
return new JSR310Module();
}
}
}

View File

@ -53,9 +53,9 @@ import org.springframework.util.ClassUtils;
/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
* Auto-configuration} to integrate with an HornetQ broker. If the necessary
* classes are present, embed the broker in the application by default. Otherwise,
* connect to a broker available on the local machine with the default settings.
* Auto-configuration} to integrate with an HornetQ broker. If the necessary classes are
* present, embed the broker in the application by default. Otherwise, connect to a broker
* available on the local machine with the default settings.
*
* @author Stephane Nicoll
* @since 1.1.0

View File

@ -58,6 +58,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Import(DataSourceInitializedPublisher.Registrar.class)
public abstract class JpaBaseConfiguration implements BeanFactoryAware {
private static final String[] NO_PACKAGES = new String[0];
private ConfigurableListableBeanFactory beanFactory;
@Autowired
@ -118,7 +120,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
List<String> basePackages = AutoConfigurationPackages.get(this.beanFactory);
return basePackages.toArray(new String[basePackages.size()]);
}
return new String[0];
return NO_PACKAGES;
}
protected void configure(

View File

@ -36,7 +36,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link HttpMessageConverter}s.
*
*
* @author Dave Syer
* @author Christian Dupuis
* @author Piotr Maj
@ -75,5 +75,7 @@ public class HttpMessageConvertersAutoConfiguration {
converter.setPrettyPrint(this.properties.isJsonPrettyPrint());
return converter;
}
}
}

View File

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.batch;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.core.Job;
@ -46,6 +44,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;
import static org.junit.Assert.assertEquals;
/**
* Tests for {@link JobLauncherCommandLineRunner}.
*

View File

@ -57,21 +57,21 @@ public class HypermediaAutoConfigurationTests {
LinkDiscoverer discoverer = discoverers.getLinkDiscovererFor(MediaTypes.HAL_JSON);
assertTrue(HalLinkDiscoverer.class.isInstance(discoverer));
}
@Test
public void doesBackOffIfEnableHypermediaSupportIsDeclaredManually() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SampleConfig.class, HypermediaAutoConfiguration.class);
this.context.refresh();
this.context.getBean(LinkDiscoverers.class);
}
@Configuration
@EnableHypermediaSupport(type = HypermediaType.HAL)
static class SampleConfig {
}
}

View File

@ -17,9 +17,8 @@
package org.springframework.boot.autoconfigure.jackson;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import org.hamcrest.Matchers;
import org.joda.time.LocalDateTime;
import org.junit.After;
import org.junit.Before;
@ -40,6 +39,7 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
@ -50,7 +50,7 @@ import static org.mockito.Mockito.verify;
/**
* Tests for {@link JacksonAutoConfiguration}.
*
*
* @author Dave Syer
* @author Oliver Gierke
*/
@ -72,27 +72,20 @@ public class JacksonAutoConfigurationTests {
@Test
public void registersJodaModuleAutomatically() {
this.context.register(JacksonAutoConfiguration.class);
this.context.refresh();
Collection<Module> modules = this.context.getBeansOfType(Module.class).values();
assertThat(modules, is(Matchers.<Module> iterableWithSize(1)));
assertThat(modules.iterator().next(), is(instanceOf(JodaModule.class)));
Map<String, Module> modules = this.context.getBeansOfType(Module.class);
assertThat(modules.size(), greaterThanOrEqualTo(1)); // Depends on the JDK
assertThat(modules.get("jacksonJodaModule"), is(instanceOf(JodaModule.class)));
ObjectMapper objectMapper = this.context.getBean(ObjectMapper.class);
assertThat(objectMapper.canSerialize(LocalDateTime.class), is(true));
}
@Test
public void customJacksonModules() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(ModulesConfig.class, JacksonAutoConfiguration.class);
this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
@SuppressWarnings({ "unchecked", "unused" })
ObjectMapper result = verify(mapper).registerModules(
(Iterable<Module>) argThat(hasItem(this.context.getBean("jacksonModule",
@ -101,12 +94,9 @@ public class JacksonAutoConfigurationTests {
@Test
public void doubleModuleRegistration() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(DoubleModulesConfig.class,
HttpMessageConvertersAutoConfiguration.class);
this.context.refresh();
ObjectMapper mapper = this.context.getBean(ObjectMapper.class);
assertEquals("{\"foo\":\"bar\"}", mapper.writeValueAsString(new Foo()));
}
@ -124,6 +114,7 @@ public class JacksonAutoConfigurationTests {
public ObjectMapper objectMapper() {
return Mockito.mock(ObjectMapper.class);
}
}
@Configuration
@ -153,6 +144,7 @@ public class JacksonAutoConfigurationTests {
mapper.registerModule(jacksonModule());
return mapper;
}
}
protected static class Foo {
@ -160,7 +152,6 @@ public class JacksonAutoConfigurationTests {
private String name;
private Foo() {
}
static Foo create() {
@ -176,4 +167,5 @@ public class JacksonAutoConfigurationTests {
}
}
}

View File

@ -16,11 +16,6 @@
package org.springframework.boot.autoconfigure.orm.jpa;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import javax.sql.DataSource;
import org.junit.After;
@ -34,6 +29,10 @@ import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
/**
* Tests for {@link HibernateJpaAutoConfiguration}.
*
@ -66,7 +65,7 @@ public class CustomHibernateJpaAutoConfigurationTests {
String actual = bean.getHibernateProperties(dataSource).get(
"hibernate.hbm2ddl.auto");
// Default is generic and safe
assertThat(actual, is(nullValue()));
assertThat(actual, nullValue());
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* 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.
@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.reactor;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@ -27,7 +25,11 @@ import reactor.core.Environment;
import reactor.core.Reactor;
import reactor.core.spec.Reactors;
import static org.junit.Assert.assertNotNull;
/**
* Tests for {@link ReactorAutoConfiguration}.
*
* @author Dave Syer
*/
public class ReactorAutoConfigurationTests {

View File

@ -1,9 +1,32 @@
/*
* 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 org.springframework.boot.autoconfigure.security.jpa;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.user.SecurityConfig;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
@ -13,11 +36,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* their instantiation order was accelerated by Security).
*
* @author Dave Syer
*
* @since 1.1
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Main.class)
@SpringApplicationConfiguration(classes = JpaUserDetailsTests.Main.class)
public class JpaUserDetailsTests {
@Test
@ -28,4 +49,10 @@ public class JpaUserDetailsTests {
SpringApplication.run(Main.class, args);
}
}
@Import({ DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
@ComponentScan(basePackageClasses = SecurityConfig.class)
public static class Main {
}
}

View File

@ -1,31 +0,0 @@
/*
* 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.boot.autoconfigure.security.jpa;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.user.SecurityConfig;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
@Import({ DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
@ComponentScan(basePackageClasses = SecurityConfig.class)
public class Main {
}

View File

@ -1,4 +1,3 @@
package org.springframework.boot.autoconfigure.security.user;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,40 +1,60 @@
package org.springframework.boot.autoconfigure.security.user;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
private String email;
public User() {
}
public User(String email) {
this.email = email;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return getClass().getSimpleName() + ":" + id;
}
}
/*
* 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 org.springframework.boot.autoconfigure.security.user;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class User {
@Id
@GeneratedValue
private Long id;
private String email;
public User() {
}
public User(String email) {
this.email = email;
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return getClass().getSimpleName() + ":" + this.id;
}
}

View File

@ -1,7 +1,25 @@
/*
* 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 org.springframework.boot.autoconfigure.security.user;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepository extends JpaRepository<User, Integer> {
public User findByEmail(String email);
}
}

View File

@ -30,13 +30,13 @@ import static org.junit.Assert.assertTrue;
/**
* Tests for {@link HttpMessageConvertersAutoConfiguration}.
*
*
* @author Dave Syer
* @author Oliver Gierke
*/
public class HttpMessageConvertersAutoConfigurationTests {
private AnnotationConfigApplicationContext context;
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();;
@After
public void close() {
@ -47,17 +47,13 @@ public class HttpMessageConvertersAutoConfigurationTests {
@Test
public void customJacksonConverter() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JacksonConfig.class,
HttpMessageConvertersAutoConfiguration.class);
this.context.refresh();
MappingJackson2HttpMessageConverter converter = this.context
.getBean(MappingJackson2HttpMessageConverter.class);
assertEquals(this.context.getBean(ObjectMapper.class),
converter.getObjectMapper());
HttpMessageConverters converters = this.context
.getBean(HttpMessageConverters.class);
assertTrue(converters.getConverters().contains(converter));
@ -77,5 +73,7 @@ public class HttpMessageConvertersAutoConfigurationTests {
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
}
}

View File

@ -319,7 +319,7 @@ public class WebMvcAutoConfigurationTests {
}
@Configuration
protected static class Config {
public static class Config {
@Bean
public EmbeddedServletContainerFactory containerFactory() {

View File

@ -33,4 +33,3 @@ databaseChangeLog:
type: varchar(50)
constraints:
nullable: true

View File

@ -26,7 +26,7 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
/**
* Context used when resolving dependencies.
*
*
* @author Andy Wilkinson
* @since 1.1.0
*/
@ -52,7 +52,7 @@ public class DependencyResolutionContext {
managedDependencies);
this.managedDependencies = new ArrayList<Dependency>(
new ManagedDependenciesFactory(managedDependencies)
.getManagedDependencies());
.getManagedDependencies());
}
public ArtifactCoordinatesResolver getArtifactCoordinatesResolver() {

View File

@ -25,7 +25,7 @@ import static org.junit.Assert.assertThat;
/**
* Integration tests to exercise and reproduce specific issues.
*
*
* @author Phillip Webb
* @author Andy Wilkinson
*/

View File

@ -35,7 +35,7 @@ import static org.junit.Assert.assertTrue;
/**
* Tests for {@link AetherGrapeEngine}.
*
*
* @author Andy Wilkinson
*/
public class AetherGrapeEngineTests {
@ -45,7 +45,7 @@ public class AetherGrapeEngineTests {
private final AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create(
this.groovyClassLoader, Arrays.asList(new RepositoryConfiguration("central",
URI.create("http://repo1.maven.org/maven2"), false)),
new DependencyResolutionContext());
new DependencyResolutionContext());
@Test
public void dependencyResolution() {

View File

@ -9,4 +9,5 @@ class Sample implements CommandLineRunner {
void run(String... args) {
println "Hello World"
}
}
}

View File

@ -21,7 +21,6 @@ import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.compile.Compile
import org.springframework.boot.gradle.agent.AgentPluginFeatures
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures
import org.springframework.boot.gradle.resolve.ResolvePluginFeatures
@ -48,11 +47,14 @@ class SpringBootPlugin implements Plugin<Project> {
new RepackagePluginFeatures().apply(project)
new RunPluginFeatures().apply(project)
// default to UTF-8 encoding
project.tasks.withType(Compile).all { t->
t.doFirst {
if(!t.options.encoding) {
t.options.encoding = 'UTF-8'
useUtf8Encoding(project)
}
private useUtf8Encoding(Project project) {
project.tasks.withType(org.gradle.api.tasks.compile.Compile).all {
it.doFirst {
if(!it.options.encoding) {
it.options.encoding = 'UTF-8'
}
}
}

View File

@ -383,10 +383,6 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
/**
* Convenience class to flatten out a tree of property sources without losing the
* reference to the backing data (which can therefore be updated in the background).
*
* @param propertySources some PropertySources, possibly containing environment
* properties
* @return another PropertySources containing the same properties
*/
private static class FlatPropertySources implements PropertySources {
@ -414,7 +410,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
private MutablePropertySources getFlattened() {
MutablePropertySources result = new MutablePropertySources();
for (PropertySource<?> propertySource : propertySources) {
for (PropertySource<?> propertySource : this.propertySources) {
flattenPropertySources(propertySource, result);
}
return result;