Skip to content

Commit

Permalink
#459 and #460: Avoid feature version in spring boot starter name and …
Browse files Browse the repository at this point in the history
…upgrade to latest spring boot version (#461)
  • Loading branch information
ebussieres authored Aug 8, 2019
1 parent 2a6bd4c commit 9b9217a
Show file tree
Hide file tree
Showing 83 changed files with 86 additions and 1,576 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ addons:

language: java
jdk:
- oraclejdk8
- openjdk8
- openjdk11
- openjdk12

Expand Down
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.pebbletemplates</groupId>
<artifactId>pebble-project</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
</parent>

<artifactId>docs</artifactId>
Expand Down
12 changes: 12 additions & 0 deletions docs/src/orchid/resources/changelog/v3_1_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: '3.1.0'
---

- **BREAKING CHANGES**: Consider avoiding feature version in spring boot starter name (#459)
- Upgrade spring boot integration to Spring Boot 2.1 (#460)
- Allow override core operators (#455, #456)
- Allows variables to be set in templates when provided context is an immutable map (#453)
- Fixed a few typos in the docs (#452)
- Remove unnecessary variable 'state' in LexerImpl by using Stack (#450)
- Updates Orchid to 0.17.1 and fixes its breaking changes (#448)
- Null value in a Map should not throw AttributeNotFoundException (#447, #446)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Spring Boot starter for autoconfiguring Pebble as an MVC ViewResolver.
## Basic Usage
Add the starter dependency to your pom.xml:

### spring-boot v1
### spring-boot v2
```XML
<dependency>
<groupId>io.pebbletemplates</groupId>
Expand All @@ -20,17 +20,17 @@ Or build.gradle:
compile "io.pebbletemplates:pebble-spring-boot-starter:{{ site.version }}"
```

### spring-boot v2
### spring-boot v1
```XML
<dependency>
<groupId>io.pebbletemplates</groupId>
<artifactId>pebble-spring-boot-2-starter</artifactId>
<artifactId>pebble-legacy-spring-boot-starter</artifactId>
<version>{{ site.version }}</version>
</dependency>
```
Or build.gradle:
```groovy
compile "io.pebbletemplates:pebble-spring-boot-2-starter:{{ site.version }}"
compile "io.pebbletemplates:pebble-legacy-spring-boot-starter:{{ site.version }}"
```

This is enough for autoconfiguration to kick in. This includes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>
<parent>
<artifactId>pebble-spring</artifactId>
<groupId>io.pebbletemplates</groupId>
<version>3.0.11-SNAPSHOT</version>
<artifactId>pebble-spring</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>

<artifactId>pebble-spring-boot-2-starter</artifactId>
<artifactId>pebble-legacy-spring-boot-starter</artifactId>

<name>Pebble Spring Boot 2 Starter</name>
<description>Spring Boot 2 starter or Pebble Template Engine</description>
<name>Pebble Spring Boot Starter</name>
<description>Spring Boot starter for Pebble Template Engine</description>
<url>http://pebbletemplates.io</url>

<properties>
<boot.version>2.0.1.RELEASE</boot.version>
<boot.version>1.5.21.RELEASE</boot.version>
</properties>

<dependencies>
Expand All @@ -26,7 +26,7 @@
</dependency>
<dependency>
<groupId>io.pebbletemplates</groupId>
<artifactId>pebble-spring5</artifactId>
<artifactId>pebble-spring4</artifactId>
<version>${project.version}</version>
</dependency>

Expand All @@ -38,7 +38,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand All @@ -53,4 +53,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import com.mitchellbosecke.pebble.extension.Extension;
import com.mitchellbosecke.pebble.loader.ClasspathLoader;
import com.mitchellbosecke.pebble.loader.Loader;
import com.mitchellbosecke.pebble.spring.PebbleViewResolver;
import com.mitchellbosecke.pebble.spring.extension.SpringExtension;
import com.mitchellbosecke.pebble.spring4.PebbleViewResolver;
import com.mitchellbosecke.pebble.spring4.extension.SpringExtension;
import java.util.List;
import javax.servlet.Servlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -96,7 +96,7 @@ public static class PebbleViewResolverConfiguration {
@ConditionalOnMissingBean(name = "pebbleViewResolver")
public PebbleViewResolver pebbleViewResolver() {
PebbleViewResolver pvr = new PebbleViewResolver();
this.properties.applyToMvcViewResolver(pvr);
this.properties.applyToViewResolver(pvr);

pvr.setPebbleEngine(this.pebbleEngine);
if (this.pebbleEngine.getLoader() instanceof ClasspathLoader) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.mitchellbosecke.pebble.boot.autoconfigure;

import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ClassUtils;

Expand All @@ -11,8 +13,9 @@ public class PebbleTemplateAvailabilityProvider implements TemplateAvailabilityP
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) {
String prefix = environment.getProperty("pebble.prefix", PebbleProperties.DEFAULT_PREFIX);
String suffix = environment.getProperty("pebble.suffix", PebbleProperties.DEFAULT_SUFFIX);
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble.");
String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(prefix + view + suffix).exists();
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
provides: pebble,pebble-spring4
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ public LocaleResolver localeResolver() {
return new AcceptHeaderLocaleResolver();
}

@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
messageSource.setFallbackToSystemLocale(false);
return messageSource;
}

@Bean
public Extension testExtension() {
return new TestExtension();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mitchellbosecke.pebble.boot;

import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand All @@ -12,15 +11,16 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment=WebEnvironment.RANDOM_PORT)
public class ControllerTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(SpringRunner.class)
@SpringBootTest(classes = NonWebApplication.class)
public class CoreTests {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mitchellbosecke.pebble.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.MessageSource;
Expand All @@ -12,9 +11,7 @@
public class NonWebApplication {

public static void main(String[] args) {
SpringApplication sa = new SpringApplicationBuilder(NonWebApplication.class)
.web(WebApplicationType.NONE)
.build();
SpringApplication sa = new SpringApplicationBuilder(NonWebApplication.class).web(false).build();
sa.run(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
Expand Down Expand Up @@ -60,9 +60,8 @@ private void scanPackage(ClassPathScanningCandidateComponentProvider componentPr
}

private boolean isRunningInEmbeddedContainer() {
return this.applicationContext instanceof ServletWebServerApplicationContext
&& ((ServletWebServerApplicationContext) this.applicationContext).getServletContext()
== null;
return this.applicationContext instanceof EmbeddedWebApplicationContext
&& ((EmbeddedWebApplicationContext) this.applicationContext).getServletContext() == null;
}

private ClassPathScanningCandidateComponentProvider createComponentProvider() {
Expand Down

This file was deleted.

18 changes: 9 additions & 9 deletions pebble-spring/pebble-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>
<parent>
<groupId>io.pebbletemplates</groupId>
<artifactId>pebble-spring</artifactId>
<version>3.0.11-SNAPSHOT</version>
<groupId>io.pebbletemplates</groupId>
<version>3.1.0-SNAPSHOT</version>
</parent>

<artifactId>pebble-spring-boot-starter</artifactId>

<name>Pebble Spring Boot Starter</name>
<description>Spring Boot starter for Pebble Template Engine</description>
<name>Pebble Spring Boot 2 Starter</name>
<description>Spring Boot 2 starter or Pebble Template Engine</description>
<url>http://pebbletemplates.io</url>

<properties>
<boot.version>1.5.21.RELEASE</boot.version>
<boot.version>2.1.7.RELEASE</boot.version>
</properties>

<dependencies>
Expand All @@ -26,7 +26,7 @@
</dependency>
<dependency>
<groupId>io.pebbletemplates</groupId>
<artifactId>pebble-spring4</artifactId>
<artifactId>pebble-spring5</artifactId>
<version>${project.version}</version>
</dependency>

Expand All @@ -38,7 +38,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand All @@ -53,4 +53,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import com.mitchellbosecke.pebble.extension.Extension;
import com.mitchellbosecke.pebble.loader.ClasspathLoader;
import com.mitchellbosecke.pebble.loader.Loader;
import com.mitchellbosecke.pebble.spring4.PebbleViewResolver;
import com.mitchellbosecke.pebble.spring4.extension.SpringExtension;
import com.mitchellbosecke.pebble.spring.PebbleViewResolver;
import com.mitchellbosecke.pebble.spring.extension.SpringExtension;
import java.util.List;
import javax.servlet.Servlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -96,7 +96,7 @@ public static class PebbleViewResolverConfiguration {
@ConditionalOnMissingBean(name = "pebbleViewResolver")
public PebbleViewResolver pebbleViewResolver() {
PebbleViewResolver pvr = new PebbleViewResolver();
this.properties.applyToViewResolver(pvr);
this.properties.applyToMvcViewResolver(pvr);

pvr.setPebbleEngine(this.pebbleEngine);
if (this.pebbleEngine.getLoader() instanceof ClasspathLoader) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.mitchellbosecke.pebble.boot.autoconfigure;

import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ClassUtils;

Expand All @@ -13,9 +11,8 @@ public class PebbleTemplateAvailabilityProvider implements TemplateAvailabilityP
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble.");
String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX);
String prefix = environment.getProperty("pebble.prefix", PebbleProperties.DEFAULT_PREFIX);
String suffix = environment.getProperty("pebble.suffix", PebbleProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(prefix + view + suffix).exists();
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
provides: pebble,pebble-spring4
provides: pebble,pebble-spring5
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ public LocaleResolver localeResolver() {
return new AcceptHeaderLocaleResolver();
}

@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
messageSource.setFallbackToSystemLocale(false);
return messageSource;
}

@Bean
public Extension testExtension() {
return new TestExtension();
Expand Down
Loading

0 comments on commit 9b9217a

Please sign in to comment.