Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play 2.8 support #163

Merged
merged 2 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
env: GRADLE_TASK=integrationTest PLAY_VERSION=2.6.25
- name: "Play 2.7.5 Integration Tests"
env: GRADLE_TASK=integrationTest PLAY_VERSION=2.7.5
- name: "Play 2.8.2 Integration Tests"
env: GRADLE_TASK=integrationTest PLAY_VERSION=2.8.2
- name: "Documentation Tests"
env: GRADLE_TASK=docTest PLAY_VERSION=not_used

Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/00-intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Play plugin defines the following requirements for a consuming build.

* The build has to be run with Java 8 or higher.
* The build has to use Gradle 5.0 or higher.
* The supported Play versions are 2.4.x, 2.5.x, 2.6.x, and 2.7.x.
* The supported Play versions are 2.4.x, 2.5.x, 2.6.x, 2.7.x, and 2.8.x.

=== Limitations

Expand Down
4 changes: 4 additions & 0 deletions src/docs/asciidoc/11-play-framework.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The following versions of Play and Scala are supported:
|===
| Play | Scala | Java

| 2.8.x
| 2.12 and 2.13
| 1.8

| 2.7.x
| 2.11, 2.12 and 2.13
| 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ final class PlayCoverage {
VersionNumber.parse('2.4.11'),
VersionNumber.parse('2.5.19'),
VersionNumber.parse('2.7.5'),
// Not supported yet
// VersionNumber.parse('2.8.0'),
VersionNumber.parse('2.8.0'),
DEFAULT
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package controllers

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import play.api._
import play.api.mvc._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import jva.html.*;

public class PureJava extends Controller {

<#if playVersion == "2.7">
<#if playVersion == "2.8" || playVersion == "2.7">
public Result index() {
<#else>
public static Result index() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import views.html.*;

public class MixedJava extends Controller {

<#if playVersion == "2.7">
<#if playVersion == "2.8" || playVersion == "2.7">
public Result index() {
<#else>
public static Result index() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package special.strangename

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import play.api._
import play.api.mvc._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sourceSets {
}
}

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
dependencies {
implementation "com.typesafe.play:play-guice_2.12:2.6.15"
implementation "ch.qos.logback:logback-classic:1.2.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
# Routes
GET / @controllers.Application.index
GET /root @controllers.Application.root
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
GET /one controllers.scla.MixedJava.index
POST /two @special.strangename.Application.index

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package controllers

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import play.api._
import play.api.mvc._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
plugins {
id 'org.gradle.playframework'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
# Routes
# Home page
GET / @controllers.Application.index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package controllers

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import com.google.common.base.Strings
import play.api._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
plugins {
id 'org.gradle.playframework'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
# Routes
# Home page
GET / @controllers.Application.index
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import play.api._
import play.api.mvc._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
plugins {
id 'org.gradle.playframework'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
GET / @controllers.Application.index
GET /shutdown @controllers.Application.shutdown
GET /assets/*file @controllers.Assets.at(path="/public", file)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
plugins {
id 'org.gradle.playframework'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import play.api._
import play.api.mvc._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
plugins {
id 'org.gradle.playframework'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
# https://www.playframework.com/documentation/2.6.x/ApplicationSecret
play.http.secret.key="somethingsecret"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
GET / @controllers.Application.index
GET /shutdown @controllers.Application.shutdown
GET /submodule @controllers.submodule.Application.index
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package controllers.submodule

<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
import javax.inject._
import play.api._
import play.api.mvc._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
plugins {
id 'org.gradle.playframework'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#if playVersion == "2.7" || playVersion == "2.6">
<#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6">
play.http.secret.key="TY9[b`xw2MeXUt;M<i_B0kUKm8/?PD1cS1WhFYyZ[1^6`Apew34q6DyNL=UqG/1l"

<#else>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ public enum PlayMajorVersion {
PLAY_2_4_X("2.4.x", true, "2.11", "2.10"),
PLAY_2_5_X("2.5.x", true,"2.11"),
PLAY_2_6_X("2.6.x", true, "2.12", "2.11"),
PLAY_2_7_X("2.7.x", false, "2.13", "2.12", "2.11");
// Not supported yet
// PLAY_2_8_X("2.8.x", false, "2.13", "2.12");
PLAY_2_7_X("2.7.x", false, "2.13", "2.12", "2.11"),
PLAY_2_8_X("2.8.x", false, "2.13", "2.12");

private final String name;
private final boolean supportForStaticRoutes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private void addAutomaticDependencies(DependencyHandler dependencies, PlayPlatfo
// if the project is Java or Scala based.
case PLAY_2_6_X:
case PLAY_2_7_X:
case PLAY_2_8_X:
dependencies.add(PLATFORM_CONFIGURATION, playPlatform.getDependencyNotation("play-java-forms").get());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static VersionedRoutesCompilerAdapter createAdapter(PlayPlatform playPlat
case PLAY_2_6_X:
return new RoutesCompilerAdapterV24X(playVersion, scalaVersion);
case PLAY_2_7_X:
case PLAY_2_8_X:
default:
return new RoutesCompilerAdapterV27X(playVersion, scalaVersion);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.gradle.playframework.tools.internal.twirl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.gradle.playframework.sourcesets.TwirlImports;

class PlayTwirlAdapterV28X implements VersionedPlayTwirlAdapter {

// Based on https://github.com/playframework/playframework/blob/2.8.x/dev-mode/build-link/src/main/java/play/TemplateImports.java
private static List<String> defaultTemplateImports = Collections.unmodifiableList(
Arrays.asList(
"models._",
"controllers._",
"play.api.i18n._",
"play.api.templates.PlayMagic._"
));

private static final List<String> DEFAULT_JAVA_IMPORTS;
private static final List<String> DEFAULT_SCALA_IMPORTS;
static {
List<String> minimalJavaImports = new ArrayList<String>();
minimalJavaImports.addAll(defaultTemplateImports);
minimalJavaImports.add("java.lang._");
minimalJavaImports.add("java.util._");
minimalJavaImports.add("play.core.j.PlayMagicForJava._");
minimalJavaImports.add("play.mvc._");
minimalJavaImports.add("play.api.data.Field");

List<String> defaultJavaImports = new ArrayList<String>();
defaultJavaImports.addAll(minimalJavaImports);
defaultJavaImports.add("play.data._");
defaultJavaImports.add("play.core.j.PlayFormsMagicForJava._");
DEFAULT_JAVA_IMPORTS = Collections.unmodifiableList(defaultJavaImports);

List<String> scalaImports = new ArrayList<String>();
scalaImports.addAll(defaultTemplateImports);
scalaImports.add("play.api.mvc._");
scalaImports.add("play.api.data._");
DEFAULT_SCALA_IMPORTS = Collections.unmodifiableList(scalaImports);
}

@Override
public List<String> getDefaultImports(TwirlImports language) {
return language == TwirlImports.JAVA ? DEFAULT_JAVA_IMPORTS : DEFAULT_SCALA_IMPORTS;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public static VersionedPlayTwirlAdapter createPlayTwirlAdapter(PlayPlatform play
return new PlayTwirlAdapterV23X();
case PLAY_2_6_X:
case PLAY_2_7_X:
default:
return new PlayTwirlAdapterV26X();
case PLAY_2_8_X:
default:
return new PlayTwirlAdapterV28X();
}
}

Expand Down