├── .editorconfig ├── .github ├── dco.yml ├── dependabot.yml └── workflows │ ├── create-release.yml │ ├── gradle-build.yml │ └── gradle-wrapper-validation.yml ├── .gitignore ├── LICENSE ├── README.adoc ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ └── org │ └── gradle │ └── playframework │ ├── DocumentationTestPlugin.kt │ ├── GitHubPagesPlugin.kt │ ├── IntegrationTestFixturesPlugin.kt │ ├── IntegrationTestPlugin.kt │ ├── TestSetupPlugin.kt │ └── UserGuidePlugin.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── release-notes-0.16.0.txt ├── settings.gradle.kts └── src ├── docTest └── groovy │ └── org │ └── gradle │ └── playframework │ ├── AdvancedGroovyUserGuideIntegrationTest.groovy │ ├── BasicGroovyUserGuideIntegrationTest.groovy │ ├── InDepthUserGuideSamplesIntegrationTest.groovy │ ├── InjectedRoutesUserGuideIntegrationTest.groovy │ ├── LogOutputUserGuideSamplesIntegrationTest.groovy │ ├── MiscUserGuideIntegrationTest.groovy │ ├── MultiProjectUserGuideIntegrationTest.groovy │ └── runner │ └── GradlePluginSamplesRunner.groovy ├── docs ├── asciidoc │ ├── 00-intro.adoc │ ├── 10-plugin-conventions.adoc │ ├── 11-play-framework.adoc │ ├── 12-project-layout.adoc │ ├── 13-tasks.adoc │ ├── 14-source-sets.adoc │ ├── 15-dependency-configurations.adoc │ ├── 16-generated-files-comments.adoc │ ├── 20-usage.adoc │ ├── 21-add-dependencies.adoc │ ├── 22-run-application.adoc │ ├── 23-package-distribution.adoc │ ├── 24-multi-project.adoc │ ├── 25-ide.adoc │ ├── 30-plugin-configuration.adoc │ ├── 31-play-extension.adoc │ ├── 32-routes-style.adoc │ ├── 33-add-source-directories.adoc │ ├── 34-compiler-options.adoc │ ├── 35-add-distribution-files.adoc │ ├── 40-migrating-software-model.adoc │ ├── 50-changes.adoc │ └── index.adoc └── samples │ ├── advanced │ └── groovy │ │ ├── advanced.sample.conf │ │ ├── advanced.sample.out │ │ ├── app │ │ ├── assets │ │ │ └── javascripts │ │ │ │ └── sample.js │ │ ├── controllers │ │ │ ├── Application.scala │ │ │ ├── QuestionsThreeController.scala │ │ │ └── hello │ │ │ │ └── HelloController.java │ │ ├── models │ │ │ └── Person.scala │ │ └── views │ │ │ ├── fields.scala.html │ │ │ ├── index.scala.html │ │ │ ├── main.scala.html │ │ │ ├── pass.scala.html │ │ │ ├── person.scala.html │ │ │ └── square.scala.html │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ ├── hello.routes │ │ └── routes │ │ ├── public │ │ ├── images │ │ │ └── favicon.png │ │ ├── javascripts │ │ │ ├── hello.js │ │ │ └── jquery-2.1.3.min.js │ │ └── stylesheets │ │ │ ├── bootstrap.min.css │ │ │ └── main.css │ │ ├── settings.gradle │ │ └── test │ │ ├── ApplicationSpec.scala │ │ └── IntegrationSpec.scala │ ├── basic │ └── groovy │ │ ├── app │ │ ├── controllers │ │ │ └── Application.scala │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ │ ├── basic.sample.conf │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ └── routes │ │ ├── public │ │ ├── images │ │ │ └── favicon.png │ │ ├── javascripts │ │ │ └── hello.js │ │ └── stylesheets │ │ │ └── main.css │ │ ├── settings.gradle │ │ └── test │ │ ├── ApplicationSpec.scala │ │ └── IntegrationSpec.scala │ ├── configure-compiler │ └── groovy │ │ ├── app │ │ ├── controllers │ │ │ └── Application.scala │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ └── routes │ │ ├── configure-compiler.sample.conf │ │ ├── public │ │ ├── images │ │ │ └── favicon.png │ │ ├── javascripts │ │ │ └── hello.js │ │ └── stylesheets │ │ │ └── main.css │ │ ├── settings.gradle │ │ └── test │ │ ├── ApplicationSpec.scala │ │ └── IntegrationSpec.scala │ ├── custom-distribution │ └── groovy │ │ ├── README.md │ │ ├── app │ │ ├── controllers │ │ │ └── Application.scala │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ └── routes │ │ ├── custom-distribution.sample.conf │ │ ├── public │ │ ├── images │ │ │ └── favicon.png │ │ ├── javascripts │ │ │ └── hello.js │ │ └── stylesheets │ │ │ └── main.css │ │ ├── scripts │ │ └── runPlayBinaryAsUser.sh │ │ └── settings.gradle │ ├── multi-project │ └── groovy │ │ ├── app │ │ ├── controllers │ │ │ └── Application.scala │ │ └── views │ │ │ └── index.scala.html │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ └── routes │ │ ├── modules │ │ ├── admin │ │ │ ├── app │ │ │ │ ├── controllers │ │ │ │ │ └── admin │ │ │ │ │ │ ├── Application.scala │ │ │ │ │ │ └── Assets.scala │ │ │ │ └── views │ │ │ │ │ └── admin │ │ │ │ │ └── index.scala.html │ │ │ ├── build.gradle │ │ │ ├── conf │ │ │ │ ├── admin.routes │ │ │ │ └── application.conf │ │ │ └── public │ │ │ │ └── javascript │ │ │ │ └── admin.js │ │ ├── user │ │ │ ├── app │ │ │ │ ├── controllers │ │ │ │ │ └── user │ │ │ │ │ │ └── Application.scala │ │ │ │ └── views │ │ │ │ │ └── user │ │ │ │ │ └── index.scala.html │ │ │ ├── build.gradle │ │ │ └── conf │ │ │ │ ├── application.conf │ │ │ │ └── user.routes │ │ └── util │ │ │ ├── build.gradle │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── sample │ │ │ └── util │ │ │ └── BuiltBy.java │ │ ├── multi-project.sample.conf │ │ ├── public │ │ ├── images │ │ │ └── gradle.ico │ │ └── javascript │ │ │ └── timestamp.js │ │ └── settings.gradle │ ├── play-2.4 │ └── groovy │ │ ├── app │ │ ├── controllers │ │ │ └── Application.scala │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ └── routes │ │ ├── play-2.4.sample.conf │ │ ├── public │ │ ├── images │ │ │ └── favicon.png │ │ ├── javascripts │ │ │ └── hello.js │ │ └── stylesheets │ │ │ └── main.css │ │ └── settings.gradle │ ├── play-2.6 │ └── groovy │ │ ├── app │ │ ├── controllers │ │ │ └── HomeController.java │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ │ ├── build.gradle │ │ ├── conf │ │ ├── application.conf │ │ ├── logback.xml │ │ └── routes │ │ ├── play-26.sample.conf │ │ ├── public │ │ ├── images │ │ │ ├── external.png │ │ │ ├── favicon.png │ │ │ └── header-pattern.png │ │ ├── javascripts │ │ │ └── hello.js │ │ └── stylesheets │ │ │ └── main.css │ │ └── settings.gradle │ ├── play-platform │ └── groovy │ │ ├── build.gradle │ │ ├── dependencies.sample.conf │ │ ├── dependencies.sample.out │ │ └── settings.gradle │ └── source-sets │ └── groovy │ ├── additional │ ├── java │ │ └── controllers │ │ │ └── hello │ │ │ └── HelloController.java │ └── javascript │ │ ├── old_sample.js │ │ └── sample.js │ ├── app │ ├── assets │ │ └── greetings.js │ └── controllers │ │ └── Application.scala │ ├── build.gradle │ ├── conf │ ├── application.conf │ └── routes │ ├── extra │ ├── java │ │ └── controllers │ │ │ └── date │ │ │ └── DateController.java │ ├── routes │ │ ├── date.routes │ │ └── hello.routes │ └── twirl │ │ └── main.scala.html │ ├── public │ ├── images │ │ └── favicon.png │ ├── javascripts │ │ └── hello.js │ └── stylesheets │ │ └── main.css │ ├── settings.gradle │ └── source-sets.sample.conf ├── integTest └── groovy │ └── org │ └── gradle │ └── playframework │ ├── AbstractIntegrationTest.groovy │ ├── PlayMultiVersionApplicationIntegrationTest.groovy │ ├── PlayMultiVersionIntegrationTest.groovy │ ├── WellBehavedPluginTest.groovy │ ├── application │ ├── PlayAppWithFailingTestsIntegrationTest.groovy │ ├── PlayApplicationCompilationIntegrationTest.groovy │ ├── PlayApplicationDependenciesIntegrationTest.groovy │ ├── PlayApplicationPluginIntegrationTest.groovy │ ├── PlayCompositeBuildIntegrationTest.groovy │ ├── PlayDistributionApplicationIntegrationTest.groovy │ ├── PlayIdePluginIntegrationTest.groovy │ ├── PlayIdeaPluginIntegrationTest.groovy │ ├── PlayTestApplicationIntegrationTest.groovy │ ├── advanced │ │ ├── PlayBinaryAdvancedAppIntegrationTest.groovy │ │ ├── PlayDistributionAdvancedAppIntegrationTest.groovy │ │ └── PlayIdeaPluginAdvancedIntegrationTest.groovy │ ├── basic │ │ ├── PlayBasicAppIntegrationTest.groovy │ │ ├── PlayDistributionBasicAppIntegrationTest.groovy │ │ ├── PlayIdeaPluginBasicIntegrationTest.groovy │ │ └── PlayTestBasicAppIntegrationTest.groovy │ ├── dependencies │ │ ├── PlayBinaryAppWithDependenciesIntegrationTest.groovy │ │ ├── PlayDistributionAppWithDependenciesIntegrationTest.groovy │ │ ├── PlayJavaAnnotationProcessingIntegrationTest.groovy │ │ └── PlayTestAppWithDependenciesIntegrationTest.groovy │ └── multiproject │ │ ├── PlayIdeaPluginMultiprojectIntegrationTest.groovy │ │ └── PlayMultiProjectApplicationIntegrationTest.groovy │ ├── plugins │ ├── PlayJavaScriptPluginIntegrationTest.groovy │ ├── PlayPluginWellBehavedIntegrationTest.groovy │ ├── PlayRoutesPluginIntegrationTest.groovy │ └── PlayTwirlPluginIntegrationTest.groovy │ └── tasks │ ├── AbstractJavaScriptMinifyIntegrationTest.groovy │ ├── AbstractRoutesCompileIntegrationTest.groovy │ ├── DistributionZipIntegrationTest.groovy │ ├── JavaScriptMinifyIntegrationTest.groovy │ ├── Play24RoutesCompileIntegrationTest.groovy │ ├── PlayAssetsJarIntegrationTest.groovy │ └── TwirlCompileIntegrationTest.groovy ├── integTestFixtures ├── groovy │ └── org │ │ └── gradle │ │ └── playframework │ │ └── fixtures │ │ ├── Repositories.groovy │ │ ├── app │ │ ├── AdvancedPlayApp.groovy │ │ ├── BasicPlayApp.groovy │ │ ├── PlayApp.groovy │ │ ├── PlayAppWithDependencies.groovy │ │ ├── PlayCompositeBuild.groovy │ │ ├── PlayMultiProject.groovy │ │ ├── SourceFile.groovy │ │ └── WithFailingTestsApp.groovy │ │ ├── archive │ │ ├── ArchiveTestFixture.groovy │ │ ├── JarTestFixture.groovy │ │ ├── TarTestFixture.groovy │ │ └── ZipTestFixture.groovy │ │ ├── file │ │ └── FileFixtures.groovy │ │ ├── ide │ │ ├── IdeProjectFixture.groovy │ │ ├── IdeWorkspaceFixture.groovy │ │ ├── IdeaFixtures.groovy │ │ ├── IdeaModuleFixture.groovy │ │ └── IdeaProjectFixture.groovy │ │ ├── multiversion │ │ ├── PlayCoverage.groovy │ │ └── TargetCoverage.groovy │ │ └── test │ │ ├── JUnitTestClassExecutionResult.groovy │ │ ├── JUnitXmlTestExecutionResult.groovy │ │ ├── TestClassExecutionResult.groovy │ │ ├── TestExecutionResult.groovy │ │ └── TestResultOutputAssociation.groovy └── resources │ └── org │ └── gradle │ └── playframework │ └── fixtures │ └── app │ ├── advancedplayapp │ ├── app │ │ ├── assets │ │ │ └── javascripts │ │ │ │ └── sample.js │ │ ├── controllers │ │ │ ├── Application.scala.ftl │ │ │ ├── jva │ │ │ │ └── PureJava.java.ftl │ │ │ └── scla │ │ │ │ └── MixedJava.java.ftl │ │ ├── models │ │ │ ├── DataType.java │ │ │ └── ScalaClass.scala │ │ ├── special │ │ │ └── strangename │ │ │ │ └── Application.scala.ftl │ │ └── views │ │ │ ├── awesome │ │ │ └── index.scala.html │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ ├── build.gradle.ftl │ ├── conf │ │ ├── evolutions │ │ │ └── default │ │ │ │ └── 1.sql │ │ ├── jva.routes.ftl │ │ ├── routes.ftl │ │ └── scala.routes.ftl │ └── templates │ │ └── jva │ │ └── index.scala.html │ ├── basicplayapp │ ├── app │ │ ├── controllers │ │ │ └── Application.scala.ftl │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ ├── build.gradle.ftl │ ├── conf │ │ └── routes.ftl │ ├── settings.gradle │ └── test │ │ ├── ApplicationSpec.scala │ │ ├── IntegrationSpec.scala │ │ └── notATest.yaml │ ├── playappwithdependencies │ ├── app │ │ ├── controllers │ │ │ └── Application.scala.ftl │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ ├── build.gradle.ftl │ ├── conf │ │ └── routes.ftl │ └── test │ │ ├── ApplicationSpec.scala │ │ ├── IntegrationSpec.scala │ │ └── notATest.yaml │ ├── playcompositebuild │ ├── app │ │ ├── controllers │ │ │ └── Application.scala.ftl │ │ └── views │ │ │ ├── index.scala.html │ │ │ └── main.scala.html │ ├── build.gradle.ftl │ ├── conf │ │ └── routes.ftl │ ├── javalibrary │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── test │ │ │ └── Util.java │ ├── public │ │ └── primary.txt │ └── settings.gradle │ ├── playmultiproject │ ├── build.gradle.ftl │ ├── javalibrary │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── test │ │ │ └── Util.java │ ├── primary │ │ ├── app │ │ │ └── controllers │ │ │ │ └── Application.scala.ftl │ │ ├── build.gradle.ftl │ │ ├── conf │ │ │ ├── application.conf.ftl │ │ │ └── routes.ftl │ │ └── public │ │ │ └── primary.txt │ ├── settings.gradle │ └── submodule │ │ ├── app │ │ └── controllers │ │ │ └── submodule │ │ │ └── Application.scala.ftl │ │ ├── build.gradle.ftl │ │ └── public │ │ └── submodule.txt │ ├── shared │ ├── README │ ├── conf │ │ ├── application.conf.ftl │ │ └── logback.xml │ └── public │ │ ├── images │ │ └── favicon.svg │ │ ├── javascripts │ │ └── hello.js │ │ └── stylesheets │ │ └── main.css │ └── withfailingtestsapp │ └── test │ ├── FailingApplicationSpec.scala │ └── FailingIntegrationSpec.scala └── main └── java └── org └── gradle └── playframework ├── extensions ├── PlayExtension.java ├── PlayPlatform.java └── internal │ └── PlayMajorVersion.java ├── plugins ├── JavaScriptSourceDirectorySet.java ├── PlayApplicationPlugin.java ├── PlayDistributionPlugin.java ├── PlayGeneratedSourcePlugin.java ├── PlayIdePlugin.java ├── PlayIdeaPlugin.java ├── PlayJavaScriptPlugin.java ├── PlayPlugin.java ├── PlayRoutesPlugin.java ├── PlayTwirlPlugin.java ├── RoutesSourceDirectorySet.java ├── TwirlSourceDirectorySet.java └── internal │ ├── DefaultPlaySourceDirectorySet8.java │ ├── DefaultPlaySourceDirectorySetBefore8.java │ ├── DefaultTwirlSourceDirectorySet8.java │ ├── DefaultTwirlSourceDirectorySetBefore8.java │ └── PlayPluginHelper.java ├── sourcesets ├── TwirlImports.java ├── TwirlTemplateFormat.java └── internal │ └── DefaultTwirlTemplateFormat.java ├── tasks ├── JavaScriptMinify.java ├── PlayRun.java ├── RoutesCompile.java ├── TwirlCompile.java └── internal │ ├── JavaScriptMinifyParameters.java │ ├── JavaScriptMinifyRunnable.java │ ├── JavaScriptMinifyWorkAction.java │ ├── RoutesCompileParameters.java │ ├── RoutesCompileRunnable.java │ ├── RoutesCompileWorkAction.java │ ├── TwirlCompileParameters.java │ ├── TwirlCompileRunnable.java │ └── TwirlCompileWorkAction.java ├── tools └── internal │ ├── CompileSpec.java │ ├── Compiler.java │ ├── PlayCompileSpec.java │ ├── javascript │ ├── DefaultJavaScriptCompileSpec.java │ ├── GoogleClosureCompiler.java │ ├── JavaScriptCompileDestinationCalculator.java │ ├── JavaScriptCompileSpec.java │ ├── SimpleStaleClassCleaner.java │ └── StaleClassCleaner.java │ ├── reflection │ ├── DirectInstantiator.java │ ├── Instantiator.java │ ├── JavaMethod.java │ ├── JavaReflectionUtil.java │ ├── NoSuchMethodException.java │ ├── NoSuchPropertyException.java │ ├── ObjectInstantiationException.java │ ├── PropertyAccessor.java │ └── ReflectionCache.java │ ├── routes │ ├── DefaultRoutesCompileSpec.java │ ├── DefaultRoutesPostProcessor.java │ ├── DefaultVersionedRoutesCompilerAdapter.java │ ├── RoutesCompileSpec.java │ ├── RoutesCompiler.java │ ├── RoutesCompilerAdapterV23X.java │ ├── RoutesCompilerAdapterV24X.java │ ├── RoutesCompilerAdapterV27X.java │ ├── RoutesCompilerFactory.java │ └── VersionedRoutesCompilerAdapter.java │ ├── run │ ├── AssetsClassLoader.java │ ├── DefaultPlayRunSpec.java │ ├── DefaultVersionedPlayRunAdapter.java │ ├── PlayAppLifecycleUpdate.java │ ├── PlayAppReload.java │ ├── PlayAppStart.java │ ├── PlayAppStop.java │ ├── PlayApplication.java │ ├── PlayApplicationDeploymentHandle.java │ ├── PlayApplicationRunner.java │ ├── PlayApplicationRunnerFactory.java │ ├── PlayRunAdapterV23X.java │ ├── PlayRunAdapterV24X.java │ ├── PlayRunAdapterV25X.java │ ├── PlayRunAdapterV26X.java │ ├── PlayRunAdapterV27X.java │ ├── PlayRunSpec.java │ ├── PlayRunWorkerClientProtocol.java │ ├── PlayRunWorkerServerProtocol.java │ ├── PlayWorkerServer.java │ ├── Reloader.java │ └── VersionedPlayRunAdapter.java │ ├── scala │ ├── ScalaCodecMapper.java │ ├── ScalaListBuffer.java │ ├── ScalaMethod.java │ ├── ScalaObject.java │ ├── ScalaOptionInvocationWrapper.java │ ├── ScalaReflectionUtil.java │ └── ScalaSeq.java │ └── twirl │ ├── DefaultTwirlCompileSpec.java │ ├── DefaultTwirlPostProcessor.java │ ├── PlayTwirlAdapterV23X.java │ ├── PlayTwirlAdapterV26X.java │ ├── PlayTwirlAdapterV28X.java │ ├── TwirlCompileSpec.java │ ├── TwirlCompiler.java │ ├── TwirlCompilerAdapterV10X.java │ ├── TwirlCompilerAdapterV13X.java │ ├── TwirlCompilerFactory.java │ ├── VersionedPlayTwirlAdapter.java │ └── VersionedTwirlCompilerAdapter.java └── util ├── CollectionUtils.java ├── PathUtil.java └── VersionNumber.java /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | # Change these settings to your own preference 9 | indent_style = space 10 | indent_size = 4 11 | charset = utf-8 12 | trim_trailing_whitespace = true 13 | insert_final_newline = true 14 | 15 | [*.{yml,yaml}] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | # Disable sign-off checking for members of the Gradle GitHub organization 2 | require: 3 | members: false 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | labels: 13 | - "@dev-productivity" 14 | -------------------------------------------------------------------------------- /.github/workflows/gradle-build.yml: -------------------------------------------------------------------------------- 1 | # .github/workflows/gradle-build-pr.yml 2 | name: Run integration tests 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | jobs: 9 | gradle8: 10 | strategy: 11 | matrix: 12 | task: [docTest, integrationTest] 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: actions/setup-java@v4 17 | with: 18 | java-version: 8 19 | distribution: 'temurin' 20 | - name: Setup Gradle 21 | uses: gradle/actions/setup-gradle@v4 22 | # run the build 23 | - run: ./gradlew ${{ matrix.task }} 24 | # upload build output for later inspection, if the build failed 25 | # N.B only applies to the last task in the matrix 26 | - uses: actions/upload-artifact@v4 27 | if: failure() 28 | with: 29 | name: wholebuild #testreports 30 | path: build #build/reports/tests 31 | 32 | gradle17: 33 | strategy: 34 | matrix: 35 | task: [docTest, integrationTest] 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: actions/checkout@v4 39 | - uses: actions/setup-java@v4 40 | with: 41 | java-version: 17 42 | distribution: 'temurin' 43 | - name: Setup Gradle 44 | uses: gradle/actions/setup-gradle@v4 45 | # run the build 46 | - run: ./gradlew ${{ matrix.task }} 47 | # upload build output for later inspection, if the build failed 48 | # N.B only applies to the last task in the matrix 49 | - uses: actions/upload-artifact@v4 50 | if: failure() 51 | with: 52 | name: wholebuild #testreports 53 | path: build #build/reports/tests 54 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | validation: 9 | name: "Validation" 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: gradle/actions/wrapper-validation@v4 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build 3 | out 4 | *.iml 5 | *.ipr 6 | *.iws 7 | .idea 8 | .gradle 9 | *.classpath 10 | .project 11 | .settings 12 | */bin/ 13 | *.swp 14 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/org/gradle/playframework/IntegrationTestFixturesPlugin.kt: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.GroovySourceSet 6 | import org.gradle.api.tasks.SourceSetContainer 7 | import org.gradle.kotlin.dsl.* 8 | 9 | 10 | class IntegrationTestFixturesPlugin : Plugin { 11 | override fun apply(project: Project): Unit = project.run { 12 | val sourceSets = the() 13 | val testRuntimeClasspath by configurations 14 | 15 | sourceSets.create("integTestFixtures") { 16 | withConvention(GroovySourceSet::class) { 17 | groovy.srcDir("src/integTestFixtures/groovy") 18 | } 19 | resources.srcDir("src/integTestFixtures/resources") 20 | val main by sourceSets 21 | compileClasspath += main.output + testRuntimeClasspath 22 | runtimeClasspath += output + compileClasspath 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/org/gradle/playframework/TestSetupPlugin.kt: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.testing.Test 6 | import org.gradle.api.tasks.testing.logging.TestExceptionFormat 7 | import org.gradle.kotlin.dsl.withType 8 | 9 | 10 | class TestSetupPlugin : Plugin { 11 | override fun apply(project: Project): Unit = project.run { 12 | tasks.withType().configureEach { 13 | // Log test execution so that Travis CI doesn't time out 14 | if (System.getenv("CI") != null) { 15 | // Enable detailed logging when running in Travis CI, 16 | // so that we can understand why a build failed 17 | // From: https://stackoverflow.com/a/47458666 18 | testLogging { 19 | events("started", "passed", "skipped", "failed") 20 | showStackTraces = true 21 | exceptionFormat = TestExceptionFormat.FULL 22 | } 23 | } 24 | 25 | maxParallelForks = determineMaxParallelForks() 26 | } 27 | } 28 | 29 | private 30 | fun determineMaxParallelForks(): Int { 31 | return if ((Runtime.getRuntime().availableProcessors() / 2) < 1) 1 else (Runtime.getRuntime().availableProcessors() / 2) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | systemProp.gradle.publish.skip.namespace.check=true 2 | org.gradle.caching=true 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /release-notes-0.16.0.txt: -------------------------------------------------------------------------------- 1 | - support Gradle 9.0 2 | - don't use deprecated APIs 3 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.gradle.enterprise").version("3.1.1") 3 | } 4 | 5 | rootProject.name = "gradle-playframework" 6 | -------------------------------------------------------------------------------- /src/docTest/groovy/org/gradle/playframework/AdvancedGroovyUserGuideIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.exemplar.test.rule.UsesSample 4 | import org.gradle.playframework.fixtures.test.JUnitXmlTestExecutionResult 5 | import org.gradle.playframework.fixtures.test.TestExecutionResult 6 | import spock.lang.Unroll 7 | 8 | @Unroll 9 | class AdvancedGroovyUserGuideIntegrationTest extends InDepthUserGuideSamplesIntegrationTest { 10 | 11 | @UsesSample("advanced/groovy") 12 | def "advanced sample is buildable #gradleVersion"(String gradleVersion) { 13 | setupRunner(gradleVersion) 14 | 15 | when: 16 | build("build") 17 | 18 | then: 19 | new File(sample.dir, "build/libs/advanced.jar").isFile() 20 | TestExecutionResult result = new JUnitXmlTestExecutionResult(sample.dir) 21 | result.assertTestClassesExecuted("ApplicationSpec", "IntegrationSpec") 22 | result.testClass("ApplicationSpec").assertTestCount(2, 0, 0) 23 | result.testClass("IntegrationSpec").assertTestCount(1, 0, 0) 24 | 25 | where: 26 | gradleVersion << VERSIONS_UNDER_TEST 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/docTest/groovy/org/gradle/playframework/BasicGroovyUserGuideIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.exemplar.test.rule.UsesSample 4 | import org.gradle.playframework.fixtures.test.JUnitXmlTestExecutionResult 5 | import org.gradle.playframework.fixtures.test.TestExecutionResult 6 | import spock.lang.Unroll 7 | 8 | @Unroll 9 | class BasicGroovyUserGuideIntegrationTest extends InDepthUserGuideSamplesIntegrationTest { 10 | 11 | @UsesSample("basic/groovy") 12 | def "basic sample is buildable #gradleVersion"(String gradleVersion) { 13 | setupRunner(gradleVersion) 14 | 15 | when: 16 | build("build") 17 | 18 | then: 19 | new File(sample.dir, "build/libs/basic.jar").isFile() 20 | TestExecutionResult result = new JUnitXmlTestExecutionResult(sample.dir) 21 | result.assertTestClassesExecuted("ApplicationSpec", "IntegrationSpec") 22 | result.testClass("ApplicationSpec").assertTestCount(4, 0, 0) 23 | result.testClass("IntegrationSpec").assertTestCount(1, 0, 0) 24 | 25 | where: 26 | gradleVersion << VERSIONS_UNDER_TEST 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/docTest/groovy/org/gradle/playframework/InjectedRoutesUserGuideIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.exemplar.test.rule.UsesSample 4 | import spock.lang.Unroll 5 | 6 | @Unroll 7 | class InjectedRoutesUserGuideIntegrationTest extends InDepthUserGuideSamplesIntegrationTest { 8 | @UsesSample("play-2.4/groovy") 9 | def "injected routes sample is buildable for Play 2.4 #gradleVersion"(String gradleVersion) { 10 | setupRunner(gradleVersion) 11 | 12 | when: 13 | build("build") 14 | 15 | then: 16 | assertRoutesCompilationOutput() 17 | 18 | where: 19 | gradleVersion << VERSIONS_UNDER_TEST 20 | } 21 | 22 | @UsesSample("play-2.6/groovy") 23 | def "injected routes sample is buildable for Play 2.6 #gradleVersion"(String gradleVersion) { 24 | setupRunner(gradleVersion) 25 | 26 | when: 27 | build("build") 28 | 29 | then: 30 | assertRoutesCompilationOutput() 31 | 32 | where: 33 | gradleVersion << VERSIONS_UNDER_TEST 34 | } 35 | 36 | private void assertRoutesCompilationOutput() { 37 | File routesCompilationOutputDir = new File(sample.dir, "build/src/play/routes") 38 | [ 39 | "controllers/routes.java", 40 | "controllers/ReverseRoutes.scala", 41 | "router/Routes.scala", 42 | "controllers/javascript/JavaScriptReverseRoutes.scala", 43 | "router/RoutesPrefix.scala" 44 | ].each { 45 | assert new File(routesCompilationOutputDir, it).isFile() 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/docTest/groovy/org/gradle/playframework/LogOutputUserGuideSamplesIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.exemplar.test.runner.SamplesRoot 4 | import org.gradle.playframework.runner.GradlePluginSamplesRunner 5 | import org.junit.runner.RunWith 6 | 7 | /** 8 | * Scans user guide samples root directory, executes task in discovered {@code sample.conf} file and inspects output. 9 | * 10 | * Note: The intention of this test suite is to inspect output. More elaborate testing is performed in {@link InDepthUserGuideSamplesIntegrationTest}. 11 | */ 12 | @RunWith(GradlePluginSamplesRunner) 13 | @SamplesRoot("src/docs/samples") 14 | class LogOutputUserGuideSamplesIntegrationTest { 15 | } 16 | -------------------------------------------------------------------------------- /src/docTest/groovy/org/gradle/playframework/MultiProjectUserGuideIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.exemplar.test.rule.UsesSample 4 | import spock.lang.Unroll 5 | 6 | @Unroll 7 | class MultiProjectUserGuideIntegrationTest extends InDepthUserGuideSamplesIntegrationTest { 8 | @UsesSample("multi-project/groovy") 9 | def "multi-project sample is buildable #gradleVersion"(String gradleVersion) { 10 | setupRunner(gradleVersion) 11 | 12 | when: 13 | build("assemble") 14 | 15 | then: 16 | new File(sample.dir, "modules/admin/build/libs/admin.jar").isFile() 17 | new File(sample.dir, "modules/user/build/libs/user.jar").isFile() 18 | new File(sample.dir, "modules/util/build/libs/util.jar").isFile() 19 | 20 | where: 21 | gradleVersion << VERSIONS_UNDER_TEST 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/docs/asciidoc/10-plugin-conventions.adoc: -------------------------------------------------------------------------------- 1 | == Plugin conventions 2 | 3 | include::11-play-framework.adoc[] 4 | 5 | include::12-project-layout.adoc[] 6 | 7 | include::13-tasks.adoc[] 8 | 9 | include::14-source-sets.adoc[] 10 | 11 | include::15-dependency-configurations.adoc[] 12 | 13 | include::16-generated-files-comments.adoc[] -------------------------------------------------------------------------------- /src/docs/asciidoc/11-play-framework.adoc: -------------------------------------------------------------------------------- 1 | === Play framework 2 | 3 | By default, Gradle uses Play 2.6.25, Scala 2.12 and the version of Java used to start the build. A Play application can select a different version by <>. 4 | 5 | The following versions of Play and Scala are supported: 6 | 7 | .Play supported versions 8 | [%header%autowidth,compact] 9 | |=== 10 | | Play | Scala | Java 11 | 12 | | 2.8.x 13 | | 2.12 and 2.13 14 | | 1.8 15 | 16 | | 2.7.x 17 | | 2.11, 2.12 and 2.13 18 | | 1.8 19 | 20 | | 2.6.x 21 | | 2.11 and 2.12 22 | | 1.8 23 | 24 | | 2.5.x 25 | | 2.11 26 | | 1.8 27 | 28 | | 2.4.x 29 | | 2.10 and 2.11 30 | | 1.8 31 | 32 | | 2.3.x 33 | | 2.10 and 2.11 34 | | 1.6, 1.7 and 1.8 35 | |=== 36 | -------------------------------------------------------------------------------- /src/docs/asciidoc/12-project-layout.adoc: -------------------------------------------------------------------------------- 1 | === Project layout 2 | 3 | The Play plugin follows the typical Play application layout. You can configure source sets to include additional directories or change the defaults. 4 | 5 | ---- 6 | ├── app → Application source code. 7 | │   ├── assets → Assets that require compilation. 8 | │   │   └── javascripts → JavaScript source code to be minified. 9 | │   ├── controllers → Application controller source code. 10 | │   ├── models → Application business source code. 11 | │   └── views → Application UI templates. 12 | ├── build.gradle → Your project's build script. 13 | ├── conf → Main application configuration file and routes files. 14 | ├── public → Public assets. 15 | │   ├── images → Application image files. 16 | │   ├── javascripts → Typically JavaScript source code. 17 | │   └── stylesheets → Typically CSS source code. 18 | └── test → Test source code. 19 | ---- 20 | -------------------------------------------------------------------------------- /src/docs/asciidoc/14-source-sets.adoc: -------------------------------------------------------------------------------- 1 | === Source sets 2 | 3 | One type of element that describes the application are the source sets that define where the application controller, route, template and model class source files should be found. These source sets are logical groupings of files of a particular type and a default source set for each type is created when the Play plugin is applied. 4 | 5 | .Default Play source sets 6 | [%header%autowidth,compact] 7 | |=== 8 | | Source Set | Type | Directory | Filters 9 | 10 | | java 11 | | {uri-gradle-dsl-reference}/org.gradle.api.tasks.SourceSet.html[SourceSet] 12 | | app 13 | | \**/*.java 14 | 15 | | scala 16 | | {uri-gradle-dsl-reference}/org.gradle.api.tasks.SourceSet.html[SourceSet] 17 | | app 18 | | \**/*.scala 19 | 20 | | routes 21 | | link:{uri-plugin-api}/org/gradle/playframework/sourcesets/RoutesSourceSet.html[RoutesSourceSet] 22 | | conf 23 | | routes, *.routes 24 | 25 | | twirl 26 | | link:{uri-plugin-api}/org/gradle/playframework/sourcesets/TwirlSourceSet.html[TwirlSourceSet] 27 | | app 28 | | \**/*.scala.* 29 | 30 | | javaScript 31 | | link:{uri-plugin-api}/org/gradle/playframework/sourcesets/JavaScriptSourceSet.html[JavaScriptSourceSet] 32 | | app/assets 33 | | \**/*.js 34 | |=== 35 | 36 | These <>. -------------------------------------------------------------------------------- /src/docs/asciidoc/15-dependency-configurations.adoc: -------------------------------------------------------------------------------- 1 | === Dependency configurations 2 | 3 | You can add compile, test and runtime dependencies to a Play application through the standard link:{uri-gradle-dsl-reference}/org.gradle.api.artifacts.Configuration.html[Configuration]s created by the {uri-gradle-userguide}/java_plugin.html[Java plugin]. 4 | 5 | If you are coming from SBT, the Play SBT plugin provides short names for common dependencies. For instance, if your project has a dependency on `ws`, you will need to add a dependency to `com.typesafe.play:play-ws_2.11:2.3.9` where `2.11` is your Scala version and `2.3.9` is your Play framework version. 6 | 7 | Other dependencies that have short names, such as `jackson` may actually be multiple dependencies. For those dependencies, you will need to work out the dependency coordinates from a dependency report. 8 | 9 | You can <> to those configurations as needed. 10 | 11 | The Play plugin creates a custom configuration and assigns Play dependencies automatically based on the configuration of the Play platform. The custom configuration is not meant for assigning dependencies from a project using the plugin. 12 | 13 | * `play` is used for Play-specific compile time dependencies. -------------------------------------------------------------------------------- /src/docs/asciidoc/16-generated-files-comments.adoc: -------------------------------------------------------------------------------- 1 | === Generated files comments 2 | 3 | Files generated by Twirl and Route compilers contain comments which are changing across builds (absolute path and date depending on the framework version), this prevents tasks using those files as inputs to benefit from build cache. 4 | The plugin is post-processing those files to remove timestamp and convert absolute paths to relative paths. 5 | -------------------------------------------------------------------------------- /src/docs/asciidoc/20-usage.adoc: -------------------------------------------------------------------------------- 1 | == Typical usage patterns 2 | 3 | include::21-add-dependencies.adoc[] 4 | 5 | include::22-run-application.adoc[] 6 | 7 | include::23-package-distribution.adoc[] 8 | 9 | include::24-multi-project.adoc[] 10 | 11 | include::25-ide.adoc[] -------------------------------------------------------------------------------- /src/docs/asciidoc/21-add-dependencies.adoc: -------------------------------------------------------------------------------- 1 | [[adding-dependencies]] 2 | === Adding dependencies 3 | 4 | Your Play application might need additional dependencies. The Java plugin exposes standard configurations for adding dependencies. 5 | 6 | [source,groovy] 7 | .build.gradle 8 | ---- 9 | include::{samplesCodeDir}/advanced/groovy/build.gradle[tag=play-dependencies] 10 | ---- -------------------------------------------------------------------------------- /src/docs/asciidoc/22-run-application.adoc: -------------------------------------------------------------------------------- 1 | === Running an application 2 | 3 | The `runPlay` task starts the Play application under development. During development it is beneficial to execute this task as a {uri-gradle-userguide}/command_line_interface.html#sec:continuous_build[continuous build]. Continuous build is a generic feature that supports automatically re-running a build when inputs change. The `runPlay` task is “continuous build aware” in that it behaves differently when run as part of a continuous build. 4 | 5 | When not run as part of a continuous build, the `runPlay` task will _block_ the build. That is, the task will not complete as long as the application is running. When running as part of a continuous build, the task will start the application if not running and otherwise propagate any changes to the code of the application to the running instance. This is useful for quickly iterating on your Play application with an edit->rebuild->refresh cycle. Changes to your application will not take affect until the end of the overall build. 6 | 7 | To enable continuous build, run Gradle with `-t runPlay` or `--continuous runPlay`. 8 | 9 | Users of Play used to such a workflow with Play's default build system should note that compile errors are handled differently. If a build failure occurs during a continuous build, the Play application will not be reloaded. Instead, you will be presented with an exception message. The exception message will only contain the overall cause of the build failure. More detailed information will only be available from the console. -------------------------------------------------------------------------------- /src/docs/asciidoc/23-package-distribution.adoc: -------------------------------------------------------------------------------- 1 | === Packaging a distribution 2 | 3 | Gradle provides the capability to package your Play application so that it can easily be distributed and run in a target environment. The distribution package (zip file) contains the Play binary jars, all dependencies, and generated scripts that set up the classpath and run the application in a Play-specific http://netty.io[Netty] container. 4 | 5 | The distribution can be created by running the `dist` lifecycle task and places the distribution in the `$buildDir/distributions` directory. Alternatively, one can validate the contents by running the `stage` lifecycle task which copies the files to the `$buildDir/stage` directory using the layout of the distribution package. 6 | 7 | You can <> to the distribution. -------------------------------------------------------------------------------- /src/docs/asciidoc/24-multi-project.adoc: -------------------------------------------------------------------------------- 1 | === Modeling multi-project applications 2 | 3 | Play applications can be built in multi-project builds as well. Simply apply the `org.gradle.playframework` plugin in the appropriate subprojects and create any project dependencies on the `play` configuration. 4 | 5 | [source,groovy] 6 | .build.gradle 7 | ---- 8 | include::{samplesCodeDir}/multi-project/groovy/build.gradle[tag=play-multiproject-dependencies] 9 | ---- 10 | -------------------------------------------------------------------------------- /src/docs/asciidoc/25-ide.adoc: -------------------------------------------------------------------------------- 1 | === Building an application in an IDE 2 | 3 | If you want to generate IDE metadata configuration for your Play project, you need to apply the appropriate IDE plugin. Gradle supports generating IDE metadata for IDEA only for Play projects at this time. 4 | 5 | To generate IDEA's metadata, apply the `idea` plugin along with the `org.gradle.playframework` plugin. 6 | 7 | [source,groovy] 8 | .build.gradle 9 | ---- 10 | include::{samplesCodeDir}/configure-compiler/groovy/build.gradle[tag=plugin-definition] 11 | ---- 12 | 13 | Source code generated by routes and Twirl templates cannot be generated by IDEA directly, so changes made to those files will not affect compilation until the next Gradle build. You can run the Play application with Gradle in {uri-gradle-userguide}/command_line_interface.html#sec:continuous_build[continuous build] to automatically rebuild and reload the application whenever something changes. -------------------------------------------------------------------------------- /src/docs/asciidoc/30-plugin-configuration.adoc: -------------------------------------------------------------------------------- 1 | == Plugin configuration 2 | 3 | include::31-play-extension.adoc[] 4 | 5 | include::32-routes-style.adoc[] 6 | 7 | include::33-add-source-directories.adoc[] 8 | 9 | include::34-compiler-options.adoc[] 10 | 11 | include::35-add-distribution-files.adoc[] -------------------------------------------------------------------------------- /src/docs/asciidoc/31-play-extension.adoc: -------------------------------------------------------------------------------- 1 | [[targeting-play-version]] 2 | === Targeting a Play version 3 | 4 | A Play application can be configured to target a certain version of Play. You can configure the Play, Scala and Java version individually with the help of the {uri-plugin-api}/org/gradle/playframework/extensions/PlayPlatform.html[PlayPlatform] which is exposed by the method {uri-plugin-api}/org/gradle/playframework/extensions/PlayExtension.html#platform(org.gradle.api.Action)[PlayExtension.platform(org.gradle.api.Action)]. 5 | 6 | [source,groovy] 7 | .build.gradle 8 | ---- 9 | include::{samplesCodeDir}/play-platform/groovy/build.gradle[tag=play-extension] 10 | ---- -------------------------------------------------------------------------------- /src/docs/asciidoc/32-routes-style.adoc: -------------------------------------------------------------------------------- 1 | === Configuring routes style 2 | 3 | If your Play application's router uses dependency injection to access your controllers, you'll need to configure your application to _not_ use the default static router. Under the covers, the Play plugin is using the `InjectedRoutesGenerator` instead of the default `StaticRoutesGenerator` to generate the router classes. 4 | 5 | [NOTE] 6 | ==== 7 | The injected router is only supported in Play Framework 2.4 or better. 8 | ==== 9 | 10 | [source,groovy] 11 | .build.gradle 12 | ---- 13 | include::{samplesCodeDir}/play-2.4/groovy/build.gradle[tag=injected-routes-compiler] 14 | ---- -------------------------------------------------------------------------------- /src/docs/asciidoc/33-add-source-directories.adoc: -------------------------------------------------------------------------------- 1 | [[adding-source-directories]] 2 | === Adding source directories 3 | 4 | You can add extra source directories to the default source sets provided by this plugin. Gradle will automatically add them to the appropriate compile tasks. You can further configure the default source sets to do things like add new directories, add filters, etc. 5 | 6 | [source,groovy] 7 | .build.gradle 8 | ---- 9 | include::{samplesCodeDir}/source-sets/groovy/build.gradle[tag=add-source-directories] 10 | ---- 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/docs/asciidoc/34-compiler-options.adoc: -------------------------------------------------------------------------------- 1 | === Configuring compiler options 2 | 3 | If your Play application requires additional Scala compiler flags, you can add these arguments directly to the Scala compiler task. 4 | 5 | [source,groovy] 6 | .build.gradle 7 | ---- 8 | include::{samplesCodeDir}/configure-compiler/groovy/build.gradle[tag=additional-params] 9 | ---- -------------------------------------------------------------------------------- /src/docs/asciidoc/35-add-distribution-files.adoc: -------------------------------------------------------------------------------- 1 | [[adding-distribution-files]] 2 | === Adding additional files to the distribution 3 | 4 | You can add additional files to the distribution package using the link:{uri-gradle-dsl-reference}/org.gradle.api.distribution.Distribution.html[Distribution] API. 5 | 6 | [source,groovy] 7 | .build.gradle 8 | ---- 9 | include::{samplesCodeDir}/custom-distribution/groovy/build.gradle[tag=add-files] 10 | ---- 11 | -------------------------------------------------------------------------------- /src/docs/asciidoc/40-migrating-software-model.adoc: -------------------------------------------------------------------------------- 1 | [[migrating-from-standard-play-plugin]] 2 | == Migrating from Gradle's standard Play plugin 3 | 4 | The following features are not available in this plugin: 5 | 6 | * Any features of the https://blog.gradle.org/state-and-future-of-the-gradle-software-model[Gradle software model] and its plugin ecosystem. 7 | * The custom configurations `playTest` and `playRun` do not exist anymore. Use the standard configurations `implementation`, `testImplementation` and `runtime` of the Java/Scala plugin instead. 8 | * The extension does not allow for configuring a target platform. You will need to configure Play, Scala and Java version individually. 9 | * {uri-gradle-userguide}//play_plugin.html#sec:adding_extra_source_sets[Adding new source sets] of a specific type is a built-in feature of the software model. This functionality is currently not available. 10 | * The concept of an "asset" does not exist and therefore cannot be used to {uri-gradle-userguide}/play_plugin.html#sec:injecting_a_custom_asset_pipeline[configure a custom asset pipeline]. 11 | * Source sets cannot be added by type. You will need to add additional source directories to the existing source sets provided by the plugin. 12 | * The CoffeeScript plugin is not available anymore. -------------------------------------------------------------------------------- /src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Gradle Play Plugin User Guide & Examples 2 | :uri-gradle-userguide: https://docs.gradle.org/current/userguide 3 | :uri-gradle-dsl-reference: https://docs.gradle.org/current/dsl 4 | :uri-ghpages: https://gradle.github.io/playframework 5 | :uri-plugin-api: {uri-ghpages}/api 6 | :uri-github: https://github.com/gradle/playframework 7 | :uri-github-issues: {uri-github}/issues 8 | 9 | {uri-github}[Gradle Play Framework Github Repository] 10 | 11 | include::00-intro.adoc[] 12 | 13 | include::10-plugin-conventions.adoc[] 14 | 15 | include::20-usage.adoc[] 16 | 17 | include::30-plugin-configuration.adoc[] 18 | 19 | include::40-migrating-software-model.adoc[] 20 | 21 | include::50-changes.adoc[] 22 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/advanced.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: "dependencies --configuration compileClasspath" 3 | expected-output-file: advanced.sample.out 4 | allow-additional-output: true -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/assets/javascripts/sample.js: -------------------------------------------------------------------------------- 1 | var cubes = (function() { 2 | var _i, _len, _results; 3 | _results = []; 4 | for (_i = 0, _len = list.length; _i < _len; _i++) { 5 | num = list[_i]; 6 | _results.push(math.cube(num)); 7 | } 8 | return _results; 9 | })(); -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import javax.inject._ 4 | import play.api._ 5 | import play.api.mvc._ 6 | 7 | @Singleton 8 | class Application @Inject() extends InjectedController { 9 | 10 | def index = Action { 11 | Ok(views.html.index("Your new application is ready.")) 12 | } 13 | 14 | def square = Action { 15 | Ok(views.html.square("Square it!")) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/controllers/QuestionsThreeController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api._ 4 | import play.api.mvc._ 5 | import play.api.i18n._ 6 | import play.api.data._ 7 | import play.api.data.Forms._ 8 | import models.Person 9 | 10 | import javax.inject._ 11 | 12 | @Singleton 13 | class QuestionsThreeController @Inject()(override val messagesApi: MessagesApi) extends InjectedController with I18nSupport { 14 | val personForm = Form( 15 | mapping( 16 | "name" -> nonEmptyText, 17 | "quest" -> nonEmptyText, 18 | "favoriteColor" -> text 19 | )(Person.apply)(Person.unapply) 20 | ) 21 | 22 | def submit = Action { implicit request => 23 | personForm.bindFromRequest.fold( 24 | formWithErrors => { 25 | // binding failure, you retrieve the form containing errors: 26 | BadRequest(views.html.person(formWithErrors)) 27 | }, 28 | person => { 29 | Ok(views.html.pass()) 30 | } 31 | ) 32 | } 33 | 34 | def index = Action { implicit request => 35 | Ok(views.html.person(personForm)) 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/controllers/hello/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package controllers.hello; 18 | 19 | import play.*; 20 | import play.mvc.*; 21 | import views.html.*; 22 | 23 | import org.apache.commons.lang.StringUtils; 24 | 25 | public class HelloController extends Controller { 26 | 27 | public Result index(String name) { 28 | return ok(String.format("Hello %s!", StringUtils.capitalize(name))); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/models/Person.scala: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | case class Person( 4 | firstName: String, 5 | quest: String, 6 | favoriteColor: String 7 | ) -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/views/fields.scala.html: -------------------------------------------------------------------------------- 1 | @(elements: helper.FieldElements) 2 | 3 |
4 | 5 | @elements.errors.mkString(", ") 6 |
7 | @elements.input 8 |
9 |
10 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | 14 | @content 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/views/pass.scala.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Success 4 | 5 | 6 | 7 | 8 |
9 |

You may pass...

10 | (Try Again) 11 |
12 | 13 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/views/person.scala.html: -------------------------------------------------------------------------------- 1 | @(personForm: Form[Person])(implicit messages: play.api.i18n.Messages) 2 | 3 | @implicitField = @{ helper.FieldConstructor(fields.f) } 4 | 5 | 6 | 7 | Questions Three 8 | 9 | 10 | 11 | 12 |
13 |

Answer me these questions three:

14 | @if(personForm.hasGlobalErrors) { 15 | @for(error <- personForm.globalErrors) { 16 |

@error.message

17 | } 18 | } 19 | @helper.form(action = routes.QuestionsThreeController.submit()) { 20 | @helper.inputText(personForm("name"), '_label -> "What is your name?", '_showConstraints -> false) 21 | @helper.inputText(personForm("quest"), '_label -> "What is your quest?", '_showConstraints -> false) 22 | @helper.inputText(personForm("favoriteColor"), '_label -> "What is your favorite color?") 23 |
24 | 25 |
26 | } 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/app/views/square.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

Square It!

16 |
17 | 18 |
19 | Square it! 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | play { 6 | platform { 7 | playVersion = '2.6.25' 8 | scalaVersion = '2.12' 9 | javaVersion = JavaVersion.VERSION_1_8 10 | } 11 | 12 | injectedRoutesGenerator = true 13 | } 14 | 15 | // tag::play-dependencies[] 16 | dependencies { 17 | implementation "commons-lang:commons-lang:2.6" 18 | implementation "com.typesafe.play:play-guice_2.12:2.6.25" 19 | implementation "ch.qos.logback:logback-classic:1.2.3" 20 | testImplementation "org.scalatestplus.play:scalatestplus-play_2.12:3.1.2" 21 | } 22 | // end::play-dependencies[] 23 | 24 | repositories { 25 | mavenCentral() 26 | maven { 27 | name = "lightbend-maven-release" 28 | url = "https://repo.lightbend.com/lightbend/maven-releases" 29 | } 30 | ivy { 31 | name = "lightbend-ivy-release" 32 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 33 | layout "ivy" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | play.http.secret.key="dxbAjiDdqlIV83LY<:;hSxql?tG`CPNgXEXt2asjk>lYQ /hello hello.Routes 20 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/public/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/advanced/groovy/public/images/favicon.png -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/public/javascripts/hello.js: -------------------------------------------------------------------------------- 1 | if (window.console) { 2 | console.log("Welcome to your Play application's JavaScript!"); 3 | } -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/public/stylesheets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/advanced/groovy/public/stylesheets/main.css -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'advanced' 2 | -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/test/ApplicationSpec.scala: -------------------------------------------------------------------------------- 1 | import org.junit.runner.RunWith 2 | import org.scalatest.junit.JUnitRunner 3 | import org.scalatestplus.play.PlaySpec 4 | import org.scalatestplus.play.guice.GuiceOneAppPerSuite 5 | import play.api.http.Status 6 | import play.api.test.FakeRequest 7 | import play.api.test.Helpers._ 8 | 9 | @RunWith(classOf[JUnitRunner]) 10 | class ApplicationSpec extends PlaySpec with GuiceOneAppPerSuite { 11 | 12 | "Application" should { 13 | 14 | "send 404 on a bad request" in { 15 | route(app, FakeRequest(GET, "/boum")).map(status(_)) mustBe Some(NOT_FOUND) 16 | } 17 | 18 | "render the index page" in { 19 | val home = route(app, FakeRequest(GET, "/")).get 20 | 21 | status(home) mustBe Status.OK 22 | contentType(home) mustBe Some("text/html") 23 | contentAsString(home) must include ("Your new application is ready.") 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/docs/samples/advanced/groovy/test/IntegrationSpec.scala: -------------------------------------------------------------------------------- 1 | import org.junit.runner.RunWith 2 | import org.scalatest.junit.JUnitRunner 3 | import org.scalatestplus.play._ 4 | import org.scalatestplus.play.guice.GuiceOneServerPerTest 5 | 6 | @RunWith(classOf[JUnitRunner]) 7 | class IntegrationSpec extends PlaySpec 8 | with OneBrowserPerTest 9 | with GuiceOneServerPerTest 10 | with HtmlUnitFactory 11 | with ServerProvider { 12 | 13 | "Application" should { 14 | 15 | "work from within a browser" in { 16 | 17 | go to ("http://localhost:" + port) 18 | 19 | pageSource must include ("Your new application is ready.") 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/docs/samples/basic/groovy/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import javax.inject._ 4 | import play.api._ 5 | import play.api.mvc._ 6 | 7 | import org.apache.commons.lang.StringUtils 8 | 9 | @Singleton 10 | class Application @Inject() extends InjectedController { 11 | 12 | def index = Action { 13 | Ok(views.html.index(StringUtils.trim(" Your new application is ready. "))) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/docs/samples/basic/groovy/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/basic/groovy/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @content 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/docs/samples/basic/groovy/basic.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: tasks 3 | -------------------------------------------------------------------------------- /src/docs/samples/basic/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | // tag::use-plugin[] 2 | plugins { 3 | id 'org.gradle.playframework' version '0.16.0' 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | maven { 9 | name = "lightbend-maven-release" 10 | url = "https://repo.lightbend.com/lightbend/maven-releases" 11 | } 12 | ivy { 13 | name = "lightbend-ivy-release" 14 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 15 | layout "ivy" 16 | } 17 | } 18 | // end::use-plugin[] 19 | 20 | dependencies { 21 | implementation 'commons-lang:commons-lang:2.6' 22 | testImplementation "com.google.guava:guava:17.0" 23 | testImplementation "org.scalatestplus.play:scalatestplus-play_2.12:3.1.2" 24 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 25 | implementation "ch.qos.logback:logback-classic:1.2.3" 26 | } 27 | -------------------------------------------------------------------------------- /src/docs/samples/basic/groovy/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | play.http.secret.key="dxbAjiDdqlIV83LY<:;hSxql?tG`CPNgXEXt2asjk>lYQ@message 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/configure-compiler/groovy/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @content 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/docs/samples/configure-compiler/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | // tag::plugin-definition[] 2 | plugins { 3 | id 'org.gradle.playframework' version '0.16.0' 4 | } 5 | // end::plugin-definition[] 6 | 7 | repositories { 8 | mavenCentral() 9 | maven { 10 | name = "lightbend-maven-release" 11 | url = "https://repo.lightbend.com/lightbend/maven-releases" 12 | } 13 | ivy { 14 | name = "lightbend-ivy-release" 15 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 16 | layout "ivy" 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation 'commons-lang:commons-lang:2.6' 22 | testImplementation "com.google.guava:guava:17.0" 23 | testImplementation "org.scalatestplus.play:scalatestplus-play_2.12:3.1.2" 24 | } 25 | 26 | // tag::additional-params[] 27 | tasks.withType(ScalaCompile) { 28 | scalaCompileOptions.additionalParameters = ["-feature", "-language:implicitConversions"] 29 | } 30 | // end::additional-params[] 31 | -------------------------------------------------------------------------------- /src/docs/samples/configure-compiler/groovy/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | play.http.secret.key="dxbAjiDdqlIV83LY<:;hSxql?tG`CPNgXEXt2asjk>lYQ@message 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/custom-distribution/groovy/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @content 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/docs/samples/custom-distribution/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "lightbend-maven-release" 9 | url = "https://repo.lightbend.com/lightbend/maven-releases" 10 | } 11 | ivy { 12 | name = "lightbend-ivy-release" 13 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 14 | layout "ivy" 15 | } 16 | } 17 | 18 | dependencies { 19 | implementation 'commons-lang:commons-lang:2.6' 20 | testImplementation "com.google.guava:guava:17.0" 21 | } 22 | 23 | // tag::add-files[] 24 | distributions { 25 | main { 26 | contents { 27 | from("README.md") 28 | from("scripts") { 29 | into "bin" 30 | } 31 | } 32 | } 33 | } 34 | // end::add-files[] 35 | -------------------------------------------------------------------------------- /src/docs/samples/custom-distribution/groovy/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | play.http.secret.key="dxbAjiDdqlIV83LY<:;hSxql?tG`CPNgXEXt2asjk>lYQ" 8 | exit 1 9 | fi 10 | 11 | SCRIPTDIR=`dirname $0` 12 | SCRIPTDIR=`cd ${SCRIPTDIR}; pwd` 13 | sudo -u ${RUNASUSER} ${SCRIPTDIR}/playBinary 14 | 15 | -------------------------------------------------------------------------------- /src/docs/samples/custom-distribution/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'custom-distribution' 2 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import javax.inject._ 4 | import play.api._ 5 | import play.api.mvc._ 6 | 7 | import org.sample.util.BuiltBy 8 | 9 | @Singleton 10 | class Application @Inject() extends InjectedController { 11 | def index = Action { 12 | Ok(views.html.index(BuiltBy.watermark("Here is a multiproject app!"))) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | 4 | 5 | 6 | 7 | Multi-project Play 8 | 9 | 10 | 11 | 12 |

@message

13 | 17 |

Page loaded at TIMESTAMP.

18 | 19 | 20 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | allprojects { 6 | repositories { 7 | mavenCentral() 8 | maven { 9 | name = "lightbend-maven-release" 10 | url = "https://repo.lightbend.com/lightbend/maven-releases" 11 | } 12 | ivy { 13 | name = "lightbend-ivy-release" 14 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 15 | layout "ivy" 16 | } 17 | } 18 | } 19 | 20 | // tag::play-multiproject-dependencies[] 21 | dependencies { 22 | implementation project(":admin") 23 | implementation project(":user") 24 | implementation project(":util") 25 | } 26 | // end::play-multiproject-dependencies[] 27 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | play.http.secret.key="somethingsecret" 12 | play.http.router=router.Routes 13 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/conf/routes: -------------------------------------------------------------------------------- 1 | # Routes 2 | # This file defines all application routes (Higher priority routes first) 3 | # ~~~~ 4 | 5 | # Home page 6 | GET / @controllers.Application.index 7 | GET /assets/*file @controllers.Assets.at(path="/public", file) 8 | 9 | # Module routes 10 | -> / admin.Routes 11 | -> / user.Routes 12 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/app/controllers/admin/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers.admin 2 | 3 | import javax.inject._ 4 | import play.api._ 5 | import play.api.mvc._ 6 | 7 | import org.sample.util.BuiltBy 8 | 9 | @Singleton 10 | class Application @Inject() extends InjectedController { 11 | def index = Action { 12 | Ok(views.html.admin.index(BuiltBy.watermark("Here is the ADMIN module."))) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/app/controllers/admin/Assets.scala: -------------------------------------------------------------------------------- 1 | package controllers.admin 2 | 3 | import javax.inject._ 4 | 5 | import play.api.http.HttpErrorHandler 6 | 7 | // https://www.playframework.com/documentation/2.6.x/SBTSubProjects 8 | class Assets @Inject() ( 9 | errorHandler: HttpErrorHandler, 10 | assetsMetadata: controllers.AssetsMetadata 11 | ) extends controllers.AssetsBuilder(errorHandler, assetsMetadata) 12 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/app/views/admin/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | 4 | 5 | 6 | 7 | The admin module 8 | 9 | 10 | 11 |

@message

12 |

REPLACED BY ADMIN MODULE JAVASCRIPT

13 | 14 | 15 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' 3 | } 4 | 5 | dependencies { 6 | implementation project(":util") 7 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 8 | implementation "ch.qos.logback:logback-classic:1.2.3" 9 | } 10 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/conf/admin.routes: -------------------------------------------------------------------------------- 1 | GET /admin @controllers.admin.Application.index 2 | GET /admin/assets/*file @controllers.admin.Assets.at(path="/public", file) 3 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/conf/application.conf: -------------------------------------------------------------------------------- 1 | include "../../../conf/application.conf" 2 | 3 | play.http.router=admin.Routes 4 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/admin/public/javascript/admin.js: -------------------------------------------------------------------------------- 1 | function displayAdminMessage() { 2 | document.getElementById("adminMessage").innerHTML = "Loaded admin module javascript at " + new Date(); 3 | } 4 | window.onload=displayAdminMessage; 5 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/user/app/controllers/user/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers.user 2 | 3 | import javax.inject._ 4 | import play.api._ 5 | import play.api.mvc._ 6 | 7 | import org.sample.util.BuiltBy 8 | 9 | @Singleton 10 | class Application @Inject() extends InjectedController { 11 | def index = Action { 12 | Ok(views.html.user.index(BuiltBy.watermark("Here is the USER module."))) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/user/app/views/user/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | 4 | 5 | 6 | 7 | The user module 8 | 9 | 10 |

@message

11 | 12 | 13 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/user/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' 3 | } 4 | 5 | dependencies { 6 | implementation project(":util") 7 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 8 | implementation "ch.qos.logback:logback-classic:1.2.3" 9 | } 10 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/user/conf/application.conf: -------------------------------------------------------------------------------- 1 | include "../../../conf/application.conf" 2 | 3 | play.http.router=user.Routes 4 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/user/conf/user.routes: -------------------------------------------------------------------------------- 1 | GET /user @controllers.user.Application.index 2 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/util/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/modules/util/src/main/java/org/sample/util/BuiltBy.java: -------------------------------------------------------------------------------- 1 | package org.sample.util; 2 | 3 | public class BuiltBy { 4 | public static String watermark(String input) { 5 | return input + " (built by Gradle)"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/multi-project.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: "tasks" -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/public/images/gradle.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/multi-project/groovy/public/images/gradle.ico -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/public/javascript/timestamp.js: -------------------------------------------------------------------------------- 1 | function updateTimestamp() { 2 | document.getElementById("timestamp").innerHTML = new Date(); 3 | } 4 | window.onload=updateTimestamp; 5 | -------------------------------------------------------------------------------- /src/docs/samples/multi-project/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'admin', 'user', 'util' 2 | 3 | project(':admin').projectDir = new File(settingsDir, 'modules/admin') 4 | project(':user').projectDir = new File(settingsDir, 'modules/user') 5 | project(':util').projectDir = new File(settingsDir, 'modules/util') 6 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api._ 4 | import play.api.mvc._ 5 | 6 | import org.apache.commons.lang.StringUtils 7 | 8 | class Application extends Controller { 9 | 10 | def index = Action { 11 | Ok(views.html.index(StringUtils.trim(" Your new application is ready. "))) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @content 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "lightbend-maven-release" 9 | url = "https://repo.lightbend.com/lightbend/maven-releases" 10 | } 11 | ivy { 12 | name = "lightbend-ivy-release" 13 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 14 | layout "ivy" 15 | } 16 | } 17 | 18 | dependencies { 19 | implementation 'commons-lang:commons-lang:2.6' 20 | testImplementation "com.google.guava:guava:17.0" 21 | } 22 | 23 | play { 24 | platform { 25 | playVersion = '2.4.0' 26 | scalaVersion = '2.11' 27 | javaVersion = JavaVersion.VERSION_1_8 28 | } 29 | } 30 | 31 | // tag::injected-routes-compiler[] 32 | play { 33 | injectedRoutesGenerator = true 34 | } 35 | // end::injected-routes-compiler[] 36 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/conf/routes: -------------------------------------------------------------------------------- 1 | # Routes 2 | # This file defines all application routes (Higher priority routes first) 3 | # ~~~~ 4 | 5 | # Home page 6 | GET / controllers.Application.index 7 | 8 | # Map static resources from the /public folder to the /assets URL path 9 | GET /assets/*file controllers.Assets.at(path="/public", file) 10 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/play-2.4.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: tasks 3 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/public/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/play-2.4/groovy/public/images/favicon.png -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/public/javascripts/hello.js: -------------------------------------------------------------------------------- 1 | if (window.console) { 2 | console.log("Welcome to your Play application's JavaScript!"); 3 | } -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/public/stylesheets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/play-2.4/groovy/public/stylesheets/main.css -------------------------------------------------------------------------------- /src/docs/samples/play-2.4/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'play-2.4' 2 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/app/controllers/HomeController.java: -------------------------------------------------------------------------------- 1 | package controllers; 2 | 3 | import play.mvc.*; 4 | 5 | import views.html.*; 6 | 7 | /** 8 | * This controller contains an action to handle HTTP requests 9 | * to the application's home page. 10 | */ 11 | public class HomeController extends Controller { 12 | 13 | /** 14 | * An action that renders an HTML page with a welcome message. 15 | * The configuration in the routes file means that 16 | * this method will be called when the application receives a 17 | * GET request with a path of /. 18 | */ 19 | public Result index() { 20 | return ok(index.render("Your new application is ready.")); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @content 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | play { 6 | platform { 7 | playVersion = '2.6.7' 8 | scalaVersion = '2.12' 9 | javaVersion = JavaVersion.VERSION_1_8 10 | } 11 | 12 | injectedRoutesGenerator = true 13 | } 14 | 15 | dependencies { 16 | implementation "com.typesafe.play:play-guice_2.12:2.6.7" 17 | } 18 | 19 | repositories { 20 | mavenCentral() 21 | maven { 22 | name = "lightbend-maven-releases" 23 | url = "https://repo.lightbend.com/lightbend/maven-release" 24 | } 25 | ivy { 26 | name = "lightbend-ivy-release" 27 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 28 | layout "ivy" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/conf/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ${application.home:-.}/logs/application.log 8 | 9 | %date [%level] from %logger in %thread - %message%n%xException 10 | 11 | 12 | 13 | 14 | 15 | %coloredLevel %logger{15} - %message%n%xException{10} 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/conf/routes: -------------------------------------------------------------------------------- 1 | # Routes 2 | # This file defines all application routes (Higher priority routes first) 3 | # ~~~~ 4 | 5 | # An example controller showing a sample home page 6 | GET / controllers.HomeController.index 7 | 8 | # Map static resources from the /public folder to the /assets URL path 9 | GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) 10 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/play-26.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: tasks 3 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/public/images/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/play-2.6/groovy/public/images/external.png -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/public/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/play-2.6/groovy/public/images/favicon.png -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/public/images/header-pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/play-2.6/groovy/public/images/header-pattern.png -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/public/javascripts/hello.js: -------------------------------------------------------------------------------- 1 | if (window.console) { 2 | console.log("Welcome to your Play application's JavaScript!"); 3 | } 4 | -------------------------------------------------------------------------------- /src/docs/samples/play-2.6/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'play-2.6' 2 | -------------------------------------------------------------------------------- /src/docs/samples/play-platform/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "lightbend-maven-release" 9 | url = "https://repo.lightbend.com/lightbend/maven-releases" 10 | } 11 | ivy { 12 | name = "lightbend-ivy-release" 13 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 14 | layout "ivy" 15 | } 16 | } 17 | 18 | // tag::play-extension[] 19 | play { 20 | platform { 21 | playVersion = '2.6.14' 22 | scalaVersion = '2.11' 23 | javaVersion = JavaVersion.VERSION_1_9 24 | } 25 | } 26 | // end::play-extension[] 27 | -------------------------------------------------------------------------------- /src/docs/samples/play-platform/groovy/dependencies.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: "dependencies --configuration play" 3 | expected-output-file: dependencies.sample.out 4 | allow-additional-output: true -------------------------------------------------------------------------------- /src/docs/samples/play-platform/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'play-platform' -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/additional/java/controllers/hello/HelloController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package controllers.hello; 18 | 19 | import play.*; 20 | import play.mvc.*; 21 | import views.html.*; 22 | 23 | import org.apache.commons.lang.StringUtils; 24 | 25 | public class HelloController extends Controller { 26 | 27 | public static Result index(String name) { 28 | return ok(String.format("Hello %s!", StringUtils.capitalize(name))); 29 | } 30 | } -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/additional/javascript/old_sample.js: -------------------------------------------------------------------------------- 1 | 2 | var old_cubes = (function() { 3 | var _i, _len, _results; 4 | _results = []; 5 | for (_i = 0, _len = list.length; _i < _len; _i++) { 6 | num = list[_i]; 7 | _results.push(math.cube(num)); 8 | } 9 | return _results; 10 | })(); 11 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/additional/javascript/sample.js: -------------------------------------------------------------------------------- 1 | var cubes = (function() { 2 | var _i, _len, _results; 3 | _results = []; 4 | for (_i = 0, _len = list.length; _i < _len; _i++) { 5 | num = list[_i]; 6 | _results.push(math.cube(num)); 7 | } 8 | return _results; 9 | })(); -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/app/assets/greetings.js: -------------------------------------------------------------------------------- 1 | 2 | if (window.console) { 3 | console.log("Greetings from your Play application's JavaScript!"); 4 | } 5 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import javax.inject._ 4 | import play.api._ 5 | import play.api.mvc._ 6 | 7 | import org.apache.commons.lang.StringUtils 8 | 9 | @Singleton 10 | class Application @Inject() extends InjectedController { 11 | 12 | def index = Action { 13 | Ok(" Your new application is ready. ") 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' version '0.16.0' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = "lightbend-maven-release" 9 | url = "https://repo.lightbend.com/lightbend/maven-releases" 10 | } 11 | ivy { 12 | name = "lightbend-ivy-release" 13 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 14 | layout "ivy" 15 | } 16 | } 17 | 18 | dependencies { 19 | implementation 'commons-lang:commons-lang:2.6' 20 | testImplementation "com.google.guava:guava:17.0" 21 | } 22 | 23 | // tag::add-source-directories[] 24 | sourceSets { 25 | main { 26 | scala { 27 | srcDir 'additional/java' 28 | } 29 | javaScript { 30 | srcDir 'additional/javascript' 31 | exclude '**/old_*.js' 32 | } 33 | } 34 | } 35 | // end::add-source-directories[] 36 | 37 | sourceSets { 38 | main { 39 | scala { 40 | srcDir 'extra/java' 41 | } 42 | twirl { 43 | srcDir 'extra/twirl' 44 | } 45 | routes { 46 | srcDir 'extra/routes' 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | play.http.secret.key="dxbAjiDdqlIV83LY<:;hSxql?tG`CPNgXEXt2asjk>lYQ /hello hello.Routes 13 | -> /date date.Routes 14 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/extra/java/controllers/date/DateController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package controllers.date; 18 | 19 | import play.*; 20 | import play.mvc.*; 21 | import views.html.*; 22 | 23 | import org.apache.commons.lang.StringUtils; 24 | 25 | import java.util.Date; 26 | 27 | public class DateController extends Controller { 28 | 29 | public static Result index() { 30 | return ok(String.format("The current date is %s!", new Date())); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/extra/routes/date.routes: -------------------------------------------------------------------------------- 1 | # date routes 2 | GET / controllers.date.DateController.index 3 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/extra/routes/hello.routes: -------------------------------------------------------------------------------- 1 | # Hello page 2 | GET /:name controllers.hello.HelloController.index(name) 3 | 4 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/extra/twirl/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 | 7 | @title 8 | 9 | 10 | 11 | 12 | 13 | @content 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/public/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/source-sets/groovy/public/images/favicon.png -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/public/javascripts/hello.js: -------------------------------------------------------------------------------- 1 | if (window.console) { 2 | console.log("Welcome to your Play application's JavaScript!"); 3 | } -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/public/stylesheets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/docs/samples/source-sets/groovy/public/stylesheets/main.css -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'source-sets' 2 | -------------------------------------------------------------------------------- /src/docs/samples/source-sets/groovy/source-sets.sample.conf: -------------------------------------------------------------------------------- 1 | executable: gradle 2 | args: "tasks" -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/PlayMultiVersionApplicationIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import org.gradle.playframework.fixtures.app.PlayApp 4 | import org.gradle.playframework.util.VersionNumber 5 | 6 | abstract class PlayMultiVersionApplicationIntegrationTest extends PlayMultiVersionIntegrationTest { 7 | 8 | def configurePlayApplication(VersionNumber playVersion) { 9 | PlayMultiVersionIntegrationTest.playVersion = playVersion 10 | 11 | getPlayApp().writeBuildFile(projectDir, playVersion) 12 | 13 | getPlayApp().writeSources(projectDir) 14 | 15 | settingsFile << """ 16 | rootProject.name = '${playApp.name}' 17 | """ 18 | } 19 | 20 | abstract PlayApp getPlayApp() 21 | } 22 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/WellBehavedPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework 2 | 3 | import static org.gradle.playframework.fixtures.Repositories.playRepositories 4 | 5 | abstract class WellBehavedPluginTest extends AbstractIntegrationTest { 6 | 7 | def setup() { 8 | buildFile << """ 9 | plugins { 10 | id '${getPluginName()}' 11 | id 'idea' 12 | } 13 | 14 | ${playRepositories()} 15 | """ 16 | } 17 | 18 | // TODO: End result should be that only the help task is realized 19 | def "does not realize all possible tasks"() { 20 | buildFile << """ 21 | def configuredTasks = [] 22 | tasks.configureEach { 23 | configuredTasks << it 24 | } 25 | 26 | gradle.buildFinished { 27 | def configuredTaskPaths = configuredTasks*.path 28 | 29 | assert configuredTaskPaths == [':compilePlayTwirlTemplates', ':help', ':clean'] 30 | } 31 | """ 32 | 33 | expect: 34 | build("help") 35 | } 36 | 37 | abstract String getPluginName() 38 | } 39 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/PlayCompositeBuildIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application 2 | 3 | import org.gradle.playframework.fixtures.app.PlayApp 4 | import org.gradle.playframework.fixtures.app.PlayCompositeBuild 5 | 6 | class PlayCompositeBuildIntegrationTest extends PlayApplicationPluginIntegrationTest { 7 | 8 | @Override 9 | PlayApp getPlayApp() { 10 | new PlayCompositeBuild(playVersion) 11 | } 12 | 13 | @Override 14 | String[] getBuildTasks() { 15 | return super.buildTasks + [ 16 | ":javalibrary:compileJava", 17 | ":javalibrary:classes", 18 | ":javalibrary:jar", 19 | ] 20 | } 21 | 22 | @Override 23 | void verifyJars() { 24 | super.verifyJars() 25 | jar("javalibrary/build/libs/java-lib.jar").hasDescendants("org/test/Util.class") 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/PlayIdePluginIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application 2 | 3 | import org.gradle.playframework.PlayMultiVersionApplicationIntegrationTest 4 | import org.gradle.testkit.runner.BuildResult 5 | import org.gradle.testkit.runner.TaskOutcome 6 | 7 | abstract class PlayIdePluginIntegrationTest extends PlayMultiVersionApplicationIntegrationTest { 8 | 9 | abstract String getIdePlugin() 10 | abstract String getIdeTask() 11 | abstract List getIdeFiles() 12 | abstract String[] getBuildTasks() 13 | abstract String[] getUnexecutedTasks() 14 | 15 | def "generates IDE configuration"() {given: 16 | configurePlayApplication(version) 17 | 18 | applyIdePlugin() 19 | when: 20 | BuildResult result = build(ideTask) 21 | then: 22 | buildTasks.each { 23 | assert result.task(it).outcome == TaskOutcome.SUCCESS 24 | } 25 | unexecutedTasks.each { 26 | assert !result.task(it) 27 | } 28 | ideFiles.each { 29 | assert it.exists() 30 | } 31 | 32 | where: 33 | version << getVersionsToTest() 34 | } 35 | 36 | def "does not blow up when no IDE plugin is applied"() { 37 | given: 38 | configurePlayApplication(version) 39 | 40 | expect: 41 | build("tasks") 42 | 43 | where: 44 | version << getVersionsToTest() 45 | } 46 | 47 | protected void applyIdePlugin() { 48 | buildFile << """ 49 | allprojects { 50 | apply plugin: "${idePlugin}" 51 | } 52 | """ 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/basic/PlayBasicAppIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application.basic 2 | 3 | import org.gradle.api.JavaVersion 4 | import org.gradle.playframework.PlayMultiVersionApplicationIntegrationTest 5 | import org.gradle.playframework.fixtures.app.BasicPlayApp 6 | import org.gradle.playframework.fixtures.app.PlayApp 7 | import org.junit.jupiter.api.Assumptions 8 | 9 | class PlayBasicAppIntegrationTest extends PlayMultiVersionApplicationIntegrationTest { 10 | 11 | @Override 12 | PlayApp getPlayApp() { 13 | new BasicPlayApp(playVersion) 14 | } 15 | 16 | def "does not emit deprecation warnings"() { 17 | given: 18 | Assumptions.assumeTrue(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) 19 | configurePlayApplication(version) 20 | 21 | expect: 22 | build("build", "--warning-mode=fail") 23 | 24 | where: 25 | version << getVersionsToTest() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/basic/PlayDistributionBasicAppIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application.basic 2 | 3 | import org.gradle.playframework.application.PlayDistributionApplicationIntegrationTest 4 | import org.gradle.playframework.fixtures.app.BasicPlayApp 5 | import org.gradle.playframework.fixtures.app.PlayApp 6 | 7 | class PlayDistributionBasicAppIntegrationTest extends PlayDistributionApplicationIntegrationTest { 8 | 9 | @Override 10 | PlayApp getPlayApp() { 11 | return new BasicPlayApp(playVersion) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/basic/PlayTestBasicAppIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application.basic 2 | 3 | import org.gradle.playframework.application.PlayTestApplicationIntegrationTest 4 | import org.gradle.playframework.fixtures.app.BasicPlayApp 5 | import org.gradle.playframework.fixtures.app.PlayApp 6 | import org.gradle.playframework.fixtures.test.TestExecutionResult 7 | 8 | class PlayTestBasicAppIntegrationTest extends PlayTestApplicationIntegrationTest { 9 | 10 | @Override 11 | PlayApp getPlayApp() { 12 | new BasicPlayApp(playVersion) 13 | } 14 | 15 | @Override 16 | void verifyTestOutput(TestExecutionResult result) { 17 | result.assertTestClassesExecuted("ApplicationSpec", "IntegrationSpec") 18 | result.testClass("ApplicationSpec").assertTestCount(2, 0, 0) 19 | result.testClass("IntegrationSpec").assertTestCount(1, 0, 0) 20 | } 21 | } -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/dependencies/PlayBinaryAppWithDependenciesIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application.dependencies 2 | 3 | import org.gradle.playframework.application.PlayApplicationPluginIntegrationTest 4 | import org.gradle.playframework.fixtures.app.PlayApp 5 | import org.gradle.playframework.fixtures.app.PlayAppWithDependencies 6 | 7 | class PlayBinaryAppWithDependenciesIntegrationTest extends PlayApplicationPluginIntegrationTest { 8 | 9 | @Override 10 | PlayApp getPlayApp() { 11 | new PlayAppWithDependencies(playVersion) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/dependencies/PlayDistributionAppWithDependenciesIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application.dependencies 2 | 3 | import org.gradle.playframework.application.PlayDistributionApplicationIntegrationTest 4 | import org.gradle.playframework.fixtures.app.PlayApp 5 | import org.gradle.playframework.fixtures.app.PlayAppWithDependencies 6 | 7 | class PlayDistributionAppWithDependenciesIntegrationTest extends PlayDistributionApplicationIntegrationTest { 8 | 9 | @Override 10 | PlayApp getPlayApp() { 11 | new PlayAppWithDependencies(playVersion) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/application/dependencies/PlayTestAppWithDependenciesIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.application.dependencies 2 | 3 | import org.gradle.playframework.application.PlayTestApplicationIntegrationTest 4 | import org.gradle.playframework.fixtures.app.PlayApp 5 | import org.gradle.playframework.fixtures.app.PlayAppWithDependencies 6 | import org.gradle.playframework.fixtures.test.TestExecutionResult 7 | 8 | class PlayTestAppWithDependenciesIntegrationTest extends PlayTestApplicationIntegrationTest { 9 | 10 | @Override 11 | PlayApp getPlayApp() { 12 | new PlayAppWithDependencies(playVersion) 13 | } 14 | 15 | @Override 16 | void verifyTestOutput(TestExecutionResult result) { 17 | result.assertTestClassesExecuted("ApplicationSpec", "IntegrationSpec") 18 | result.testClass("ApplicationSpec").assertTestCount(2, 0, 0) 19 | result.testClass("IntegrationSpec").assertTestCount(1, 0, 0) 20 | } 21 | } -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/plugins/PlayPluginWellBehavedIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins 2 | 3 | import org.gradle.playframework.WellBehavedPluginTest 4 | 5 | class PlayPluginWellBehavedIntegrationTest extends WellBehavedPluginTest { 6 | 7 | @Override 8 | String getPluginName() { 9 | 'org.gradle.playframework' 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/integTest/groovy/org/gradle/playframework/tasks/DistributionZipIntegrationTest.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks 2 | 3 | import org.gradle.playframework.AbstractIntegrationTest 4 | 5 | import static org.gradle.playframework.fixtures.Repositories.playRepositories 6 | 7 | class DistributionZipIntegrationTest extends AbstractIntegrationTest { 8 | def setup() { 9 | settingsFile << """ rootProject.name = 'dist-play-app' """ 10 | buildFile << """ 11 | plugins { 12 | id 'org.gradle.playframework' 13 | } 14 | 15 | ${playRepositories()} 16 | """ 17 | } 18 | 19 | def "can add to default distribution" () { 20 | buildFile << """ 21 | distributions { 22 | main { 23 | contents { 24 | from "additionalFile.txt" 25 | } 26 | } 27 | } 28 | """ 29 | file("additionalFile.txt").createNewFile() 30 | 31 | when: 32 | build "dist" 33 | 34 | then: 35 | zip("build/distributions/main.zip").containsDescendants("main/additionalFile.txt") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/Repositories.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures 2 | 3 | final class Repositories { 4 | 5 | private Repositories() {} 6 | 7 | static String playRepositories() { 8 | """ 9 | repositories { 10 | mavenCentral() 11 | maven { 12 | name = "lightbend-maven-release" 13 | url = "https://repo.lightbend.com/lightbend/maven-releases" 14 | } 15 | ivy { 16 | name = "lightbend-ivy-release" 17 | url = "https://repo.lightbend.com/lightbend/ivy-releases" 18 | layout "ivy" 19 | } 20 | } 21 | """ 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/AdvancedPlayApp.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | class AdvancedPlayApp extends PlayApp { 6 | AdvancedPlayApp(VersionNumber version) { 7 | super(version) 8 | } 9 | @Override 10 | List getViewSources() { 11 | return super.getViewSources() + sourceFiles("templates") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/BasicPlayApp.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | class BasicPlayApp extends PlayApp { 6 | BasicPlayApp(VersionNumber version) { 7 | super(version) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/PlayAppWithDependencies.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | class PlayAppWithDependencies extends PlayApp { 6 | PlayAppWithDependencies(VersionNumber version) { 7 | super(version) 8 | } 9 | } -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/PlayCompositeBuild.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | class PlayCompositeBuild extends PlayApp { 6 | PlayCompositeBuild(VersionNumber version) { 7 | super(version) 8 | } 9 | 10 | @Override 11 | List getAllFiles() { 12 | return super.getAllFiles() + sourceFiles("javalibrary") + sourceFile("", "settings.gradle") 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/PlayMultiProject.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | class PlayMultiProject extends PlayApp { 6 | PlayMultiProject(VersionNumber version) { 7 | super(version) 8 | } 9 | 10 | @Override 11 | List getAllFiles() { 12 | return sourceFiles("primary") + sourceFiles("submodule") + sourceFiles("javalibrary") + sourceFile("", "settings.gradle") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/SourceFile.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | class SourceFile { 4 | private final String path 5 | private final String name 6 | private final String content 7 | 8 | SourceFile(String path, String name, String content) { 9 | this.content = content 10 | this.path = path 11 | this.name = name 12 | } 13 | 14 | String getPath() { 15 | return path 16 | } 17 | 18 | String getName() { 19 | name 20 | } 21 | 22 | String getContent() { 23 | content 24 | } 25 | 26 | File writeToDir(File base) { 27 | writeToDir(base, name) 28 | } 29 | 30 | File writeToDir(File base, String name) { 31 | File baseFile = new File(base, path) 32 | createDirectory(baseFile) 33 | File file = new File(baseFile, name) 34 | writeToFile(file) 35 | file 36 | } 37 | 38 | private void createDirectory(File dir) { 39 | if (!dir.isDirectory()) { 40 | if (!dir.mkdirs()) { 41 | throw new RuntimeException("Unable to create directory '$dir'") 42 | } 43 | } 44 | } 45 | 46 | void writeToFile(File file) { 47 | if (file.exists()) { 48 | file.write("") 49 | } 50 | file.write(content) 51 | } 52 | 53 | @Override 54 | String toString() { 55 | return path + File.separator + name 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/app/WithFailingTestsApp.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.app 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | import static org.gradle.playframework.fixtures.Repositories.playRepositories 6 | 7 | class WithFailingTestsApp extends PlayApp { 8 | List appSources 9 | List viewSources 10 | List confSources 11 | List testSources 12 | 13 | @Override 14 | SourceFile getGradleBuild(VersionNumber playVersion) { 15 | def gradleBuild = sourceFile("", "build.gradle.ftl", "basicplayapp") 16 | def buildFileContent = gradleBuild.content.concat """ 17 | allprojects { 18 | ${playRepositories()} 19 | } 20 | """ 21 | if (playVersion != null) { 22 | buildFileContent = buildFileContent.concat """ 23 | play { 24 | platform { 25 | playVersion = '${playVersion.toString()}' 26 | } 27 | } 28 | """.stripIndent() 29 | } 30 | return new SourceFile(gradleBuild.path, gradleBuild.name, buildFileContent) 31 | } 32 | 33 | WithFailingTestsApp(VersionNumber version){ 34 | super(version) 35 | appSources = sourceFiles("app", "basicplayapp"); 36 | viewSources = sourceFiles("app/views", "basicplayapp"); 37 | confSources = sourceFiles("conf", "shared") + sourceFiles("conf", "basicplayapp") 38 | testSources = sourceFiles("test") + sourceFiles("test", "basicplayapp") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/archive/TarTestFixture.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.archive 2 | 3 | import org.apache.tools.tar.TarEntry 4 | import org.apache.tools.tar.TarInputStream 5 | 6 | import java.nio.charset.Charset 7 | import java.util.zip.GZIPInputStream 8 | 9 | class TarTestFixture extends ArchiveTestFixture { 10 | private final File tarFile 11 | 12 | TarTestFixture(File tarFile, String metadataCharset = null, String contentCharset = null) { 13 | this.tarFile = tarFile 14 | 15 | boolean gzip = !tarFile.name.endsWith("tar") 16 | tarFile.withInputStream { inputStream -> 17 | TarInputStream tarInputStream = new TarInputStream(gzip ? new GZIPInputStream(inputStream) : inputStream, metadataCharset) 18 | for (TarEntry tarEntry = tarInputStream.nextEntry; tarEntry != null; tarEntry = tarInputStream.nextEntry) { 19 | addMode(tarEntry.name, tarEntry.mode) 20 | if (tarEntry.directory) { 21 | continue 22 | } 23 | ByteArrayOutputStream stream = new ByteArrayOutputStream() 24 | tarInputStream.copyEntryContents(stream) 25 | add(tarEntry.name, new String(stream.toByteArray(), contentCharset ?: Charset.defaultCharset().name())) 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/archive/ZipTestFixture.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.archive 2 | 3 | import org.apache.tools.zip.ZipEntry 4 | import org.apache.tools.zip.ZipFile 5 | 6 | import java.nio.charset.Charset 7 | 8 | class ZipTestFixture extends ArchiveTestFixture { 9 | protected final String metadataCharset; 10 | protected final String contentCharset; 11 | 12 | ZipTestFixture(File file, String metadataCharset = null, String contentCharset = null) { 13 | this.metadataCharset = metadataCharset ?: Charset.defaultCharset().name() 14 | this.contentCharset = contentCharset ?: Charset.defaultCharset().name() 15 | def zipFile = new ZipFile(file, this.metadataCharset) 16 | try { 17 | def entries = zipFile.getEntries() 18 | while (entries.hasMoreElements()) { 19 | def entry = entries.nextElement() 20 | String content = getContentForEntry(entry, zipFile) 21 | if (!entry.directory) { 22 | add(entry.name, content) 23 | } 24 | addMode(entry.name, entry.getUnixMode()) 25 | } 26 | } finally { 27 | zipFile.close(); 28 | } 29 | } 30 | 31 | private String getContentForEntry(ZipEntry entry, ZipFile zipFile) { 32 | def extension = entry.name.tokenize(".").last() 33 | if (!(extension in ["jar", "zip"])) { 34 | return zipFile.getInputStream(entry).getText(contentCharset) 35 | } 36 | return "" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/ide/IdeProjectFixture.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.ide 2 | 3 | abstract class IdeProjectFixture { 4 | } 5 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/ide/IdeWorkspaceFixture.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.ide 2 | 3 | abstract class IdeWorkspaceFixture { 4 | abstract void assertContains(IdeProjectFixture project); 5 | } 6 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/ide/IdeaFixtures.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.ide 2 | 3 | class IdeaFixtures { 4 | static parseFile(File file) { 5 | assert file.isFile() 6 | new XmlSlurper().parse(file) 7 | } 8 | 9 | static IdeaProjectFixture parseIpr(File projectFile) { 10 | return new IdeaProjectFixture(projectFile, parseFile(projectFile)) 11 | } 12 | 13 | static IdeaModuleFixture parseIml(File moduleFile) { 14 | return new IdeaModuleFixture(moduleFile, parseFile(moduleFile)) 15 | } 16 | 17 | private IdeaFixtures() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/multiversion/PlayCoverage.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.multiversion 2 | 3 | import org.gradle.playframework.util.VersionNumber 4 | 5 | import static org.gradle.playframework.extensions.PlayPlatform.DEFAULT_PLAY_VERSION 6 | 7 | final class PlayCoverage { 8 | 9 | private PlayCoverage() {} 10 | 11 | public static final VersionNumber DEFAULT = VersionNumber.parse(DEFAULT_PLAY_VERSION) 12 | public static final List ALL = [ 13 | VersionNumber.parse('2.4.11'), 14 | VersionNumber.parse('2.5.19'), 15 | VersionNumber.parse('2.6.25'), 16 | VersionNumber.parse('2.7.5'), 17 | VersionNumber.parse('2.8.22'), 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/multiversion/TargetCoverage.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.multiversion 2 | 3 | import java.lang.annotation.ElementType 4 | import java.lang.annotation.Inherited 5 | import java.lang.annotation.Retention 6 | import java.lang.annotation.RetentionPolicy 7 | import java.lang.annotation.Target 8 | 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Target(ElementType.TYPE) 11 | @Inherited 12 | @interface TargetCoverage { 13 | Class value(); 14 | } 15 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/test/JUnitTestClassExecutionResult.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.test 2 | 3 | import groovy.util.slurpersupport.GPathResult 4 | 5 | class JUnitTestClassExecutionResult implements TestClassExecutionResult { 6 | GPathResult testClassNode 7 | String testClassName 8 | TestResultOutputAssociation outputAssociation 9 | 10 | JUnitTestClassExecutionResult(GPathResult testClassNode, String testClassName, TestResultOutputAssociation outputAssociation) { 11 | this.outputAssociation = outputAssociation 12 | this.testClassNode = testClassNode 13 | this.testClassName = testClassName 14 | } 15 | 16 | TestClassExecutionResult assertTestCount(int tests, int failures, int errors) { 17 | assert testClassNode.@tests == tests 18 | assert testClassNode.@failures == failures 19 | assert testClassNode.@errors == errors 20 | this 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/test/TestClassExecutionResult.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.test 2 | 3 | interface TestClassExecutionResult { 4 | TestClassExecutionResult assertTestCount(int tests, int failures, int errors); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/test/TestExecutionResult.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.test 2 | 3 | interface TestExecutionResult { 4 | /** 5 | * Asserts that the given test classes (and only the given test classes) were executed. 6 | */ 7 | TestExecutionResult assertTestClassesExecuted(String... testClasses); 8 | 9 | /** 10 | * Returns the result for the given test class. 11 | */ 12 | TestClassExecutionResult testClass(String testClass); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/integTestFixtures/groovy/org/gradle/playframework/fixtures/test/TestResultOutputAssociation.groovy: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.fixtures.test 2 | 3 | enum TestResultOutputAssociation { 4 | WITH_SUITE, 5 | WITH_TESTCASE 6 | } 7 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/assets/javascripts/sample.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var cubes, list, math, num, number, opposite, race, square, 3 | __slice = [].slice; 4 | 5 | number = 42; 6 | 7 | opposite = true; 8 | 9 | if (opposite) { 10 | number = -42; 11 | } 12 | 13 | square = function(x) { 14 | return x * x; 15 | }; 16 | 17 | list = [1, 2, 3, 4, 5]; 18 | 19 | math = { 20 | root: Math.sqrt, 21 | square: square, 22 | cube: function(x) { 23 | return x * square(x); 24 | } 25 | }; 26 | 27 | race = function() { 28 | var runners, winner; 29 | winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 30 | return print(winner, runners); 31 | }; 32 | 33 | if (typeof elvis !== "undefined" && elvis !== null) { 34 | alert("I knew it!"); 35 | } 36 | 37 | cubes = (function() { 38 | var _i, _len, _results; 39 | _results = []; 40 | for (_i = 0, _len = list.length; _i < _len; _i++) { 41 | num = list[_i]; 42 | _results.push(math.cube(num)); 43 | } 44 | return _results; 45 | })(); 46 | 47 | }).call(this); 48 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/controllers/jva/PureJava.java.ftl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package controllers.jva; 17 | 18 | import play.*; 19 | import play.mvc.*; 20 | import jva.html.*; 21 | 22 | public class PureJava extends Controller { 23 | 24 | <#if playVersion == "2.8" || playVersion == "2.7"> 25 | public Result index() { 26 | <#else> 27 | public static Result index() { 28 | 29 | return ok(index.render("Your new application is ready.")); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/controllers/scla/MixedJava.java.ftl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package controllers.scla; 18 | 19 | import play.*; 20 | import play.mvc.*; 21 | import views.html.*; 22 | 23 | public class MixedJava extends Controller { 24 | 25 | <#if playVersion == "2.8" || playVersion == "2.7"> 26 | public Result index() { 27 | <#else> 28 | public static Result index() { 29 | 30 | System.out.println(new models.ScalaClass("Java can also reference Scala files")); 31 | return ok(index.render("Your new mixed application is ready.")); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/models/DataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package models; 18 | 19 | public class DataType { 20 | private final String foo; 21 | private final int bar; 22 | 23 | public DataType(String foo, int bar) { 24 | this.foo = foo; 25 | this.bar = bar; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return String.format("%s:%s", foo, bar); 31 | } 32 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/models/ScalaClass.scala: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | class ScalaClass(val name: String) -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/special/strangename/Application.scala.ftl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package special.strangename 18 | 19 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 20 | import javax.inject._ 21 | import play.api._ 22 | import play.api.mvc._ 23 | 24 | @Singleton 25 | class Application @Inject() extends InjectedController { 26 | def index = Action { 27 | Ok(views.html.index("Your new application is ready.")) 28 | } 29 | } 30 | <#else> 31 | import play.api._ 32 | import play.api.mvc._ 33 | object Application extends Controller { 34 | def index = Action { 35 | Ok(views.html.index("Your new application is ready.")) 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/views/awesome/index.scala.html: -------------------------------------------------------------------------------- 1 | @(stuff: List[DataType]) 2 | 3 |
    4 | @for(s <- stuff) { 5 |
  • @s
  • 6 | } 7 |
-------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | @awesome.index(java.util.Arrays.asList(new DataType("foo", 1))) 8 | 9 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | @title 6 | @** 7 | 8 | **@ 9 | 10 | 11 | @content 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.gradle.playframework' 3 | } 4 | 5 | // repositories added in PlayApp class 6 | 7 | sourceSets { 8 | main { 9 | twirl { 10 | defaultImports = org.gradle.playframework.sourcesets.TwirlImports.JAVA 11 | srcDir "templates" 12 | include "jva/**/*" 13 | } 14 | } 15 | } 16 | 17 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 18 | dependencies { 19 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 20 | implementation "ch.qos.logback:logback-classic:1.2.3" 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/conf/evolutions/default/1.sql: -------------------------------------------------------------------------------- 1 | -- Blank database evolution script 2 | 3 | # --- !Ups 4 | 5 | # --- !Downs 6 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/conf/jva.routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7"> 2 | GET /one @controllers.jva.PureJava.index 3 | <#else> 4 | GET /one controllers.jva.PureJava.index 5 | 6 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/conf/routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | # Routes 3 | GET / @controllers.Application.index 4 | GET /root @controllers.Application.root 5 | GET /shutdown @controllers.Application.shutdown 6 | 7 | -> /scala scala.Routes 8 | -> /java jva.Routes 9 | 10 | # Map static resources from the /public folder to the /assets URL path 11 | GET /assets/*file @controllers.Assets.at(path="/public", file) 12 | 13 | <#else> 14 | # Routes 15 | GET / controllers.Application.index 16 | GET /root controllers.Application.root 17 | GET /shutdown controllers.Application.shutdown 18 | 19 | -> /scala scala.Routes 20 | -> /java jva.Routes 21 | 22 | # Map static resources from the /public folder to the /assets URL path 23 | GET /assets/*file controllers.Assets.at(path="/public", file) 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/conf/scala.routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7"> 2 | GET /one @controllers.scla.MixedJava.index 3 | <#else> 4 | GET /one controllers.scla.MixedJava.index 5 | 6 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 7 | POST /two @special.strangename.Application.index 8 | <#else> 9 | POST /two special.strangename.Application.index 10 | 11 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/advancedplayapp/templates/jva/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | @UUID.randomUUID().toString() 8 | 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/app/controllers/Application.scala.ftl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package controllers 18 | 19 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 20 | import javax.inject._ 21 | import play.api._ 22 | import play.api.mvc._ 23 | 24 | @Singleton 25 | class Application @Inject() extends InjectedController { 26 | 27 | def index = Action { 28 | Ok(views.html.index("Your new application is ready.")) 29 | } 30 | 31 | def shutdown = Action { 32 | Runtime.getRuntime().halt(0) 33 | Ok("shutdown") 34 | } 35 | } 36 | 37 | <#else> 38 | import play.api._ 39 | import play.api.mvc._ 40 | 41 | object Application extends Controller { 42 | 43 | def index = Action { 44 | Ok(views.html.index("Your new application is ready.")) 45 | } 46 | 47 | def shutdown = Action { 48 | System.exit(0) 49 | Ok("shutdown") 50 | } 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | @title 6 | 7 | 8 | 9 | 10 | 11 | @content 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | plugins { 3 | id 'org.gradle.playframework' 4 | } 5 | 6 | // repositories added in PlayApp class 7 | dependencies { 8 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 9 | implementation "ch.qos.logback:logback-classic:1.2.3" 10 | } 11 | 12 | <#else> 13 | plugins { 14 | id 'org.gradle.playframework' 15 | } 16 | 17 | // repositories added in PlayApp class 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/conf/routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | # Routes 3 | # Home page 4 | GET / @controllers.Application.index 5 | 6 | GET /shutdown @controllers.Application.shutdown 7 | 8 | # Map static resources from the /public folder to the /assets URL path 9 | GET /assets/*file @controllers.Assets.at(path="/public", file) 10 | 11 | <#else> 12 | # Routes 13 | # Home page 14 | GET / controllers.Application.index 15 | 16 | GET /shutdown controllers.Application.shutdown 17 | 18 | # Map static resources from the /public folder to the /assets URL path 19 | GET /assets/*file controllers.Assets.at(path="/public", file) 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/settings.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/settings.gradle -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/test/ApplicationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.junit._ 18 | 19 | class ApplicationSpec { 20 | @Test 21 | def passingTest() { 22 | } 23 | @Test 24 | def passingTest2() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/test/IntegrationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.junit._ 18 | 19 | class IntegrationSpec { 20 | @Test 21 | def passingTest() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/basicplayapp/test/notATest.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | number: 1234 3 | items: 4 | - name: item1 5 | description: first item 6 | - name: item2 7 | description: second item 8 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | @title 6 | 7 | 8 | 9 | 10 | 11 | @content 12 | 13 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | plugins { 3 | id 'org.gradle.playframework' 4 | } 5 | 6 | dependencies { 7 | implementation "com.google.guava:guava:17.0" 8 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 9 | implementation "ch.qos.logback:logback-classic:1.2.3" 10 | testImplementation "commons-lang:commons-lang:2.6" 11 | } 12 | 13 | // repositories added in PlayApp class 14 | 15 | <#else> 16 | plugins { 17 | id 'org.gradle.playframework' 18 | } 19 | 20 | dependencies { 21 | implementation "com.google.guava:guava:17.0" 22 | testImplementation "commons-lang:commons-lang:2.6" 23 | } 24 | 25 | // repositories added in PlayApp class 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/conf/routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | # Routes 3 | # Home page 4 | GET / @controllers.Application.index 5 | 6 | GET /shutdown @controllers.Application.shutdown 7 | 8 | # Map static resources from the /public folder to the /assets URL path 9 | GET /assets/*file @controllers.Assets.at(path="/public", file) 10 | 11 | <#else> 12 | # Routes 13 | # Home page 14 | GET / controllers.Application.index 15 | 16 | GET /shutdown controllers.Application.shutdown 17 | 18 | # Map static resources from the /public folder to the /assets URL path 19 | GET /assets/*file controllers.Assets.at(path="/public", file) 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/test/ApplicationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.junit._ 18 | 19 | class ApplicationSpec { 20 | @Test 21 | def passingTest() { 22 | } 23 | @Test 24 | def passingTest2() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/test/IntegrationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.junit._ 18 | 19 | class IntegrationSpec { 20 | @Test 21 | def passingTest() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playappwithdependencies/test/notATest.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | number: 1234 3 | items: 4 | - name: item1 5 | description: first item 6 | - name: item2 7 | description: second item 8 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/app/controllers/Application.scala.ftl: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 4 | import javax.inject._ 5 | import play.api._ 6 | import play.api.mvc._ 7 | 8 | import org.test.Util 9 | 10 | @Singleton 11 | class Application @Inject() extends InjectedController { 12 | 13 | def index = Action { 14 | Ok(Util.fullStop("Your new application is ready")) 15 | } 16 | 17 | def shutdown = Action { 18 | Runtime.getRuntime().halt(0) 19 | Ok("shutdown") 20 | } 21 | } 22 | 23 | <#else> 24 | import play.api._ 25 | import play.api.mvc._ 26 | 27 | import org.test.Util 28 | 29 | object Application extends Controller { 30 | 31 | def index = Action { 32 | Ok(Util.fullStop("Your new application is ready")) 33 | } 34 | 35 | def shutdown = Action { 36 | System.exit(0) 37 | Ok("shutdown") 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 |

@message

6 | 7 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | @title 6 | 7 | 8 | 9 | 10 | 11 | @content 12 | 13 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | plugins { 3 | id 'org.gradle.playframework' 4 | } 5 | 6 | dependencies { 7 | implementation "org.my:java-lib:1.0" 8 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 9 | implementation "ch.qos.logback:logback-classic:1.2.3" 10 | } 11 | 12 | <#else> 13 | plugins { 14 | id 'org.gradle.playframework' 15 | } 16 | 17 | dependencies { 18 | implementation "org.my:java-lib:1.0" 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/conf/routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | GET / @controllers.Application.index 3 | GET /shutdown @controllers.Application.shutdown 4 | GET /assets/*file @controllers.Assets.at(path="/public", file) 5 | 6 | <#else> 7 | GET / controllers.Application.index 8 | GET /shutdown controllers.Application.shutdown 9 | GET /assets/*file controllers.Assets.at(path="/public", file) 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/javalibrary/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | group = 'org.my' 5 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/javalibrary/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "java-lib" 2 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/javalibrary/src/main/java/org/test/Util.java: -------------------------------------------------------------------------------- 1 | package org.test; 2 | 3 | public class Util { 4 | public static String fullStop(String input) { 5 | return input + "."; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/public/primary.txt: -------------------------------------------------------------------------------- 1 | Primary asset -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playcompositebuild/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'play-composite-build' 2 | 3 | includeBuild 'javalibrary' 4 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | plugins { 3 | id 'org.gradle.playframework' 4 | } 5 | 6 | dependencies { 7 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 8 | implementation "ch.qos.logback:logback-classic:1.2.3" 9 | } 10 | 11 | <#else> 12 | plugins { 13 | id 'org.gradle.playframework' 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/javalibrary/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/javalibrary/src/main/java/org/test/Util.java: -------------------------------------------------------------------------------- 1 | package org.test; 2 | 3 | public class Util { 4 | public static String fullStop(String input) { 5 | return input + "."; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/primary/app/controllers/Application.scala.ftl: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 4 | import javax.inject._ 5 | import play.api._ 6 | import play.api.mvc._ 7 | 8 | import org.test.Util 9 | 10 | @Singleton 11 | class Application @Inject() extends InjectedController { 12 | 13 | def index = Action { 14 | Ok(Util.fullStop("Your new application is ready")) 15 | } 16 | 17 | def shutdown = Action { 18 | Runtime.getRuntime().halt(0) 19 | Ok("shutdown") 20 | } 21 | } 22 | 23 | <#else> 24 | import play.api._ 25 | import play.api.mvc._ 26 | 27 | import org.test.Util 28 | 29 | object Application extends Controller { 30 | 31 | def index = Action { 32 | Ok(Util.fullStop("Your new application is ready")) 33 | } 34 | 35 | def shutdown = Action { 36 | System.exit(0) 37 | Ok("shutdown") 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/primary/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | plugins { 3 | id 'org.gradle.playframework' 4 | } 5 | 6 | dependencies { 7 | implementation project(":submodule") 8 | implementation project(":javalibrary") 9 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 10 | implementation "ch.qos.logback:logback-classic:1.2.3" 11 | } 12 | 13 | <#else> 14 | plugins { 15 | id 'org.gradle.playframework' 16 | } 17 | 18 | dependencies { 19 | implementation project(":submodule") 20 | implementation project(":javalibrary") 21 | } 22 | 23 | 24 | 25 | play { 26 | platform { 27 | playVersion = "${fullPlayVersion}" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/primary/conf/application.conf.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | # https://www.playframework.com/documentation/2.6.x/ApplicationSecret 3 | play.http.secret.key="somethingsecret" 4 | 5 | <#else> 6 | application.secret="changeme" 7 | application.langs="en" 8 | 9 | # Root logger: 10 | logger.root=ERROR 11 | 12 | # Logger used by the framework: 13 | logger.play=INFO 14 | 15 | # Logger provided to your application: 16 | logger.application=DEBUG 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/primary/conf/routes.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | GET / @controllers.Application.index 3 | GET /shutdown @controllers.Application.shutdown 4 | GET /submodule @controllers.submodule.Application.index 5 | GET /assets/*file @controllers.Assets.at(path="/public", file) 6 | 7 | <#else> 8 | GET / controllers.Application.index 9 | GET /shutdown controllers.Application.shutdown 10 | GET /submodule controllers.submodule.Application.index 11 | GET /assets/*file controllers.Assets.at(path="/public", file) 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/primary/public/primary.txt: -------------------------------------------------------------------------------- 1 | Primary asset -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'primary', 'submodule', 'javalibrary' -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/submodule/app/controllers/submodule/Application.scala.ftl: -------------------------------------------------------------------------------- 1 | package controllers.submodule 2 | 3 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 4 | import javax.inject._ 5 | import play.api._ 6 | import play.api.mvc._ 7 | 8 | @Singleton 9 | class Application @Inject() extends InjectedController { 10 | 11 | def index = Action { 12 | Ok("Submodule page") 13 | } 14 | 15 | } 16 | <#else> 17 | import play.api._ 18 | import play.api.mvc._ 19 | 20 | object Application extends Controller { 21 | 22 | def index = Action { 23 | Ok("Submodule page") 24 | } 25 | 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/submodule/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | plugins { 3 | id 'org.gradle.playframework' 4 | } 5 | 6 | dependencies { 7 | implementation "com.typesafe.play:play-guice_2.12:2.6.15" 8 | implementation "ch.qos.logback:logback-classic:1.2.3" 9 | } 10 | 11 | <#else> 12 | plugins { 13 | id 'org.gradle.playframework' 14 | } 15 | 16 | 17 | 18 | play { 19 | platform { 20 | playVersion = "${fullPlayVersion}" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/playmultiproject/submodule/public/submodule.txt: -------------------------------------------------------------------------------- 1 | Submodule asset -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/README: -------------------------------------------------------------------------------- 1 | A test README file -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/conf/application.conf.ftl: -------------------------------------------------------------------------------- 1 | <#if playVersion == "2.8" || playVersion == "2.7" || playVersion == "2.6"> 2 | play.http.secret.key="TY9[b`xw2MeXUt;M 5 | application.secret="TY9[b`xw2MeXUt;M 18 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/conf/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %coloredLevel - %logger - %message%n%xException 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/public/images/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/public/javascripts/hello.js: -------------------------------------------------------------------------------- 1 | if (window.console) { 2 | console.log("Welcome to your Play application's JavaScript!"); 3 | } -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/public/stylesheets/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gradle/playframework/53385657fa3439bdc04ab98675c88567747288a4/src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/shared/public/stylesheets/main.css -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/withfailingtestsapp/test/FailingApplicationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.junit._ 18 | import org.junit.Assert._ 19 | 20 | class FailingApplicationSpec { 21 | @Test 22 | def failingTest() { 23 | fail() 24 | } 25 | @Test 26 | def passingTest() { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/integTestFixtures/resources/org/gradle/playframework/fixtures/app/withfailingtestsapp/test/FailingIntegrationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import org.junit._ 18 | import org.junit.Assert._ 19 | 20 | class FailingIntegrationSpec { 21 | @Test 22 | def failingTest() { 23 | fail() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/JavaScriptSourceDirectorySet.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins; 2 | 3 | import org.gradle.api.file.SourceDirectorySet; 4 | 5 | public interface JavaScriptSourceDirectorySet extends SourceDirectorySet { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/PlayGeneratedSourcePlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | import org.gradle.api.file.Directory; 6 | import org.gradle.api.file.DirectoryProperty; 7 | import org.gradle.api.file.SourceDirectorySet; 8 | import org.gradle.api.provider.Provider; 9 | 10 | public interface PlayGeneratedSourcePlugin extends Plugin { 11 | 12 | String GENERATED_SOURCE_ROOT_DIR_PATH = "src/play"; 13 | 14 | default Provider getOutputDir(Project project, SourceDirectorySet sourceDirectorySet) { 15 | DirectoryProperty buildDir = project.getLayout().getBuildDirectory(); 16 | return buildDir.dir(GENERATED_SOURCE_ROOT_DIR_PATH + "/" + sourceDirectorySet.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/PlayIdePlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | /** 7 | * Plugin for configuring IDE plugins when the project uses the Play Framework support. 8 | * 9 | *

NOTE: This currently supports configuring the 'idea' plugin only.

10 | */ 11 | public class PlayIdePlugin implements Plugin { 12 | 13 | @Override 14 | public void apply(Project project) { 15 | project.getPluginManager().withPlugin("idea", appliedPlugin -> project.getPluginManager().apply(PlayIdeaPlugin.class)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/PlayPlugin.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | import org.gradle.api.tasks.TaskProvider; 6 | import org.gradle.api.tasks.bundling.Jar; 7 | import org.gradle.playframework.tasks.JavaScriptMinify; 8 | 9 | import static org.gradle.api.plugins.BasePlugin.ASSEMBLE_TASK_NAME; 10 | 11 | public class PlayPlugin implements Plugin { 12 | 13 | @Override 14 | public void apply(Project project) { 15 | applyPlugins(project); 16 | configureJavaScriptTasks(project); 17 | } 18 | 19 | private static void applyPlugins(Project project) { 20 | project.getPluginManager().apply(PlayApplicationPlugin.class); 21 | project.getPluginManager().apply(PlayJavaScriptPlugin.class); 22 | project.getPluginManager().apply(PlayDistributionPlugin.class); 23 | project.getPluginManager().apply(PlayIdePlugin.class); 24 | } 25 | 26 | private static void configureJavaScriptTasks(Project project) { 27 | TaskProvider javaScriptMinifyTask = project.getTasks().named(PlayJavaScriptPlugin.JS_MINIFY_TASK_NAME, JavaScriptMinify.class); 28 | 29 | project.getTasks().named(ASSEMBLE_TASK_NAME, task -> task.dependsOn(javaScriptMinifyTask)); 30 | 31 | project.getTasks().named(PlayApplicationPlugin.ASSETS_JAR_TASK_NAME, Jar.class, task -> { 32 | task.dependsOn(javaScriptMinifyTask); 33 | task.from(javaScriptMinifyTask.get().getDestinationDir(), copySpec -> copySpec.into("public")); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/RoutesSourceDirectorySet.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins; 2 | 3 | import org.gradle.api.file.SourceDirectorySet; 4 | 5 | public interface RoutesSourceDirectorySet extends SourceDirectorySet { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/internal/DefaultPlaySourceDirectorySet8.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins.internal; 2 | 3 | import org.gradle.api.file.SourceDirectorySet; 4 | import org.gradle.api.internal.file.DefaultSourceDirectorySet; 5 | import org.gradle.api.internal.tasks.TaskDependencyFactory; 6 | import org.gradle.playframework.plugins.JavaScriptSourceDirectorySet; 7 | 8 | import javax.inject.Inject; 9 | 10 | public class DefaultPlaySourceDirectorySet8 extends DefaultSourceDirectorySet { 11 | @Inject 12 | public DefaultPlaySourceDirectorySet8(SourceDirectorySet sourceDirectorySet, TaskDependencyFactory taskDependencyFactory) { 13 | super(sourceDirectorySet, taskDependencyFactory); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/plugins/internal/DefaultPlaySourceDirectorySetBefore8.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.plugins.internal; 2 | 3 | import org.gradle.api.file.SourceDirectorySet; 4 | import org.gradle.api.internal.file.DefaultSourceDirectorySet; 5 | import org.gradle.playframework.plugins.JavaScriptSourceDirectorySet; 6 | 7 | import javax.inject.Inject; 8 | 9 | public class DefaultPlaySourceDirectorySetBefore8 extends DefaultSourceDirectorySet { 10 | @Inject 11 | public DefaultPlaySourceDirectorySetBefore8(SourceDirectorySet sourceDirectorySet) { 12 | super(sourceDirectorySet); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/sourcesets/TwirlImports.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.sourcesets; 2 | 3 | /** 4 | * Represents the available sets of default imports that can be used when compiling Twirl templates. 5 | */ 6 | public enum TwirlImports { 7 | SCALA, JAVA 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/sourcesets/TwirlTemplateFormat.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.sourcesets; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * Twirl Template format mapping. 7 | */ 8 | public interface TwirlTemplateFormat { 9 | /** 10 | * Extension without the leading '.'. 11 | * 12 | * @return file extension 13 | */ 14 | String getExtension(); 15 | 16 | /** 17 | * Fully qualified class name for the template format. 18 | * 19 | * @return class name of the format 20 | */ 21 | String getFormatType(); 22 | 23 | /** 24 | * Imports that are needed for this template format. 25 | *

26 | * These are just the packages or individual classes in Scala format. 27 | * Use {@code my.package._} and not {@code my.package.*}. 28 | *

29 | * @return collection of imports to be added after the default Twirl imports 30 | */ 31 | Collection getTemplateImports(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/JavaScriptMinifyParameters.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.api.provider.Property; 4 | import org.gradle.playframework.tools.internal.javascript.JavaScriptCompileSpec; 5 | import org.gradle.workers.WorkParameters; 6 | 7 | public interface JavaScriptMinifyParameters extends WorkParameters { 8 | Property getSpec(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/JavaScriptMinifyRunnable.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.playframework.tools.internal.javascript.GoogleClosureCompiler; 4 | import org.gradle.playframework.tools.internal.javascript.JavaScriptCompileSpec; 5 | 6 | import javax.inject.Inject; 7 | 8 | public class JavaScriptMinifyRunnable implements Runnable { 9 | 10 | private final JavaScriptCompileSpec spec; 11 | 12 | @Inject 13 | public JavaScriptMinifyRunnable(JavaScriptCompileSpec spec) { 14 | this.spec = spec; 15 | } 16 | 17 | @Override 18 | public void run() { 19 | new GoogleClosureCompiler().execute(spec); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/JavaScriptMinifyWorkAction.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.workers.WorkAction; 4 | 5 | public abstract class JavaScriptMinifyWorkAction implements WorkAction { 6 | 7 | @Override 8 | public void execute() { 9 | // TODO: When dropping support for <5.6, remove the Runnable and fold its functionality into here 10 | new JavaScriptMinifyRunnable(getParameters().getSpec().get()).run(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/RoutesCompileParameters.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.api.provider.Property; 4 | import org.gradle.playframework.tools.internal.Compiler; 5 | import org.gradle.playframework.tools.internal.routes.RoutesCompileSpec; 6 | import org.gradle.workers.WorkParameters; 7 | 8 | public interface RoutesCompileParameters extends WorkParameters { 9 | Property> getCompiler(); 10 | Property getSpec(); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/RoutesCompileRunnable.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.playframework.tools.internal.routes.RoutesCompileSpec; 4 | import org.gradle.playframework.tools.internal.Compiler; 5 | import org.gradle.api.UncheckedIOException; 6 | 7 | import javax.inject.Inject; 8 | import java.io.IOException; 9 | import java.nio.file.Files; 10 | import java.nio.file.Path; 11 | 12 | public class RoutesCompileRunnable implements Runnable { 13 | 14 | private final RoutesCompileSpec routesCompileSpec; 15 | private final Compiler compiler; 16 | 17 | @Inject 18 | public RoutesCompileRunnable(RoutesCompileSpec routesCompileSpec, Compiler compiler) { 19 | this.routesCompileSpec = routesCompileSpec; 20 | this.compiler = compiler; 21 | } 22 | 23 | @Override 24 | public void run() { 25 | Path destinationPath = routesCompileSpec.getDestinationDir().toPath(); 26 | deleteOutputs(destinationPath); 27 | compiler.execute(routesCompileSpec); 28 | } 29 | 30 | private void deleteOutputs(Path pathToBeDeleted) { 31 | try { 32 | Files.walk(pathToBeDeleted).map(path -> path.toFile()).forEach(file -> file.delete()); 33 | } catch (IOException e) { 34 | throw new UncheckedIOException(e); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/RoutesCompileWorkAction.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.workers.WorkAction; 4 | 5 | public abstract class RoutesCompileWorkAction implements WorkAction { 6 | 7 | @Override 8 | public void execute() { 9 | // TODO: When dropping support for <5.6, remove the Runnable and fold its functionality into here 10 | new RoutesCompileRunnable(getParameters().getSpec().get(), getParameters().getCompiler().get()).run(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/TwirlCompileParameters.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.api.provider.Property; 4 | import org.gradle.playframework.tools.internal.Compiler; 5 | import org.gradle.playframework.tools.internal.twirl.TwirlCompileSpec; 6 | import org.gradle.workers.WorkParameters; 7 | 8 | public interface TwirlCompileParameters extends WorkParameters { 9 | Property getTwirlCompileSpec(); 10 | Property> getCompiler(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/TwirlCompileRunnable.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.playframework.tools.internal.twirl.TwirlCompileSpec; 4 | import org.gradle.playframework.tools.internal.Compiler; 5 | import org.gradle.api.UncheckedIOException; 6 | 7 | import javax.inject.Inject; 8 | import java.io.IOException; 9 | import java.nio.file.Files; 10 | import java.nio.file.Path; 11 | 12 | public class TwirlCompileRunnable implements Runnable { 13 | 14 | private final TwirlCompileSpec twirlCompileSpec; 15 | private final Compiler compiler; 16 | 17 | @Inject 18 | public TwirlCompileRunnable(TwirlCompileSpec twirlCompileSpec, Compiler compiler) { 19 | this.twirlCompileSpec = twirlCompileSpec; 20 | this.compiler = compiler; 21 | } 22 | 23 | @Override 24 | public void run() { 25 | Path destinationPath = twirlCompileSpec.getDestinationDir().toPath(); 26 | deleteOutputs(destinationPath); 27 | compiler.execute(twirlCompileSpec); 28 | } 29 | 30 | private void deleteOutputs(Path pathToBeDeleted) { 31 | try { 32 | Files.walk(pathToBeDeleted).map(path -> path.toFile()).forEach(file -> file.delete()); 33 | } catch (IOException e) { 34 | throw new UncheckedIOException(e); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tasks/internal/TwirlCompileWorkAction.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tasks.internal; 2 | 3 | import org.gradle.workers.WorkAction; 4 | 5 | public abstract class TwirlCompileWorkAction implements WorkAction { 6 | 7 | @Override 8 | public void execute() { 9 | // TODO: When dropping support for <5.6, remove the Runnable and fold its functionality into here 10 | new TwirlCompileRunnable(getParameters().getTwirlCompileSpec().get(), getParameters().getCompiler().get()).run(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/CompileSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal; 2 | 3 | public interface CompileSpec { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/Compiler.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal; 2 | 3 | import org.gradle.api.tasks.WorkResult; 4 | 5 | public interface Compiler { 6 | WorkResult execute(T spec); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/PlayCompileSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal; 2 | 3 | import java.io.File; 4 | 5 | public interface PlayCompileSpec extends CompileSpec { 6 | File getDestinationDir(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/javascript/DefaultJavaScriptCompileSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.javascript; 2 | 3 | import org.gradle.api.internal.file.RelativeFile; 4 | 5 | import java.io.File; 6 | import java.io.Serializable; 7 | 8 | public class DefaultJavaScriptCompileSpec implements JavaScriptCompileSpec, Serializable { 9 | 10 | private final Iterable sources; 11 | private final File destinationDir; 12 | 13 | public DefaultJavaScriptCompileSpec(Iterable sources, File destinationDir) { 14 | this.sources = sources; 15 | this.destinationDir = destinationDir; 16 | } 17 | 18 | @Override 19 | public Iterable getSources() { 20 | return sources; 21 | } 22 | 23 | @Override 24 | public File getDestinationDir() { 25 | return destinationDir; 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/javascript/JavaScriptCompileDestinationCalculator.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.javascript; 2 | 3 | import org.gradle.api.Transformer; 4 | import org.gradle.api.internal.file.RelativeFile; 5 | 6 | import java.io.File; 7 | 8 | public class JavaScriptCompileDestinationCalculator implements Transformer { 9 | private final File destinationDir; 10 | 11 | public JavaScriptCompileDestinationCalculator(File destinationDir) { 12 | this.destinationDir = destinationDir; 13 | } 14 | 15 | @Override 16 | public File transform(RelativeFile file) { 17 | final File outputFileDir = new File(destinationDir, file.getRelativePath().getParent().getPathString()); 18 | return new File(outputFileDir, getMinifiedFileName(file.getFile().getName())); 19 | } 20 | 21 | private static String getMinifiedFileName(String fileName) { 22 | int extIndex = fileName.lastIndexOf('.'); 23 | if (extIndex == -1) { 24 | return fileName + ".min"; 25 | } 26 | String prefix = fileName.substring(0, extIndex); 27 | String extension = fileName.substring(extIndex); 28 | return prefix + ".min" + extension; 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/javascript/JavaScriptCompileSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.javascript; 2 | 3 | import org.gradle.playframework.tools.internal.PlayCompileSpec; 4 | import org.gradle.api.internal.file.RelativeFile; 5 | 6 | public interface JavaScriptCompileSpec extends PlayCompileSpec { 7 | Iterable getSources(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/javascript/StaleClassCleaner.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.javascript; 2 | 3 | import java.io.File; 4 | 5 | public abstract class StaleClassCleaner { 6 | public abstract void execute(); 7 | 8 | public abstract void addDirToClean(File toClean); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/reflection/Instantiator.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.reflection; 2 | 3 | /** 4 | * An object that can create new instances of a given type, which may be decorated in some fashion. 5 | */ 6 | public interface Instantiator { 7 | 8 | T newInstance(Class type, Object... parameters) throws ObjectInstantiationException; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/reflection/NoSuchMethodException.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.reflection; 2 | 3 | /** 4 | * Thrown when a requested method cannot be found. 5 | */ 6 | public class NoSuchMethodException extends RuntimeException { 7 | public NoSuchMethodException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/reflection/NoSuchPropertyException.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.reflection; 2 | 3 | /** 4 | * Thrown when a requested property cannot be found. 5 | */ 6 | public class NoSuchPropertyException extends RuntimeException { 7 | public NoSuchPropertyException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/reflection/ObjectInstantiationException.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.reflection; 2 | 3 | /** 4 | * Thrown when an object cannot be instantiated. 5 | */ 6 | public class ObjectInstantiationException extends RuntimeException { 7 | public ObjectInstantiationException(Class targetType, Throwable throwable) { 8 | super(String.format("Could not create an instance of type %s.", targetType.getName()), throwable); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/reflection/PropertyAccessor.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.reflection; 2 | 3 | public interface PropertyAccessor { 4 | String getName(); 5 | 6 | Class getType(); 7 | 8 | F getValue(T target); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/routes/DefaultVersionedRoutesCompilerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.routes; 2 | 3 | import java.util.Arrays; 4 | 5 | abstract class DefaultVersionedRoutesCompilerAdapter implements VersionedRoutesCompilerAdapter { 6 | private static final Iterable SHARED_PACKAGES = Arrays.asList("play.router", "scala.collection", "scala.collection.mutable", "scala.util.matching", "play.routes.compiler"); 7 | private final String playVersion; 8 | private final String scalaVersion; 9 | 10 | public DefaultVersionedRoutesCompilerAdapter(String playVersion, String scalaVersion) { 11 | this.playVersion = playVersion; 12 | this.scalaVersion = scalaVersion; 13 | } 14 | 15 | protected boolean isGenerateRefReverseRouter() { 16 | return false; 17 | } 18 | 19 | @Override 20 | public String getDependencyNotation() { 21 | if (playVersion.equals("2.7.4") || playVersion.equals("2.7.5")) { 22 | // this is a hack because of a Play Framework issue 23 | // See: https://github.com/playframework/playframework/issues/10333 24 | return "com.typesafe.play:routes-compiler_" + scalaVersion + ":2.7.3"; 25 | } 26 | return "com.typesafe.play:routes-compiler_" + scalaVersion + ":" + playVersion; 27 | } 28 | 29 | @Override 30 | public Iterable getClassLoaderPackages() { 31 | return SHARED_PACKAGES; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/routes/RoutesCompileSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.routes; 2 | 3 | import org.gradle.playframework.tools.internal.PlayCompileSpec; 4 | 5 | import java.io.File; 6 | import java.io.Serializable; 7 | import java.util.Collection; 8 | 9 | public interface RoutesCompileSpec extends PlayCompileSpec, Serializable { 10 | Iterable getSources(); 11 | 12 | boolean isJavaProject(); 13 | 14 | boolean isNamespaceReverseRouter(); 15 | 16 | boolean isGenerateReverseRoutes(); 17 | 18 | boolean isInjectedRoutesGenerator(); 19 | 20 | Collection getAdditionalImports(); 21 | 22 | File getProjectDir(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/routes/RoutesCompilerFactory.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.routes; 2 | 3 | import org.gradle.playframework.extensions.PlayPlatform; 4 | import org.gradle.playframework.extensions.internal.PlayMajorVersion; 5 | import org.gradle.playframework.util.VersionNumber; 6 | 7 | public class RoutesCompilerFactory { 8 | public static RoutesCompiler create(PlayPlatform playPlatform) { 9 | return new RoutesCompiler(createAdapter(playPlatform)); 10 | } 11 | 12 | public static VersionedRoutesCompilerAdapter createAdapter(PlayPlatform playPlatform) { 13 | String playVersion = playPlatform.getPlayVersion().get(); 14 | String scalaVersion = playPlatform.getScalaCompatibilityVersion().get(); 15 | switch (PlayMajorVersion.forPlatform(playPlatform)) { 16 | case PLAY_2_3_X: 17 | return new RoutesCompilerAdapterV23X(playVersion); 18 | case PLAY_2_4_X: 19 | if (VersionNumber.parse(playVersion).getMicro() < 6 && !"2.10".equals(scalaVersion)) { 20 | scalaVersion = "2.10"; 21 | } 22 | return new RoutesCompilerAdapterV24X(playVersion, scalaVersion); 23 | case PLAY_2_5_X: 24 | case PLAY_2_6_X: 25 | return new RoutesCompilerAdapterV24X(playVersion, scalaVersion); 26 | case PLAY_2_7_X: 27 | case PLAY_2_8_X: 28 | default: 29 | return new RoutesCompilerAdapterV27X(playVersion, scalaVersion); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/routes/VersionedRoutesCompilerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.routes; 2 | 3 | import org.gradle.playframework.tools.internal.scala.ScalaMethod; 4 | 5 | import java.io.File; 6 | import java.io.Serializable; 7 | import java.lang.reflect.InvocationTargetException; 8 | import java.util.Collection; 9 | 10 | public interface VersionedRoutesCompilerAdapter extends Serializable { 11 | String getDependencyNotation(); 12 | 13 | ScalaMethod getCompileMethod(ClassLoader cl) throws ClassNotFoundException; 14 | 15 | Object[] createCompileParameters(ClassLoader cl, File file, File destinationDir, boolean javaProject, boolean namespaceReverseRouter, boolean generateReverseRoutes, boolean injectedRoutesGenerator, Collection additionalImports) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException; 16 | 17 | Iterable getClassLoaderPackages(); 18 | 19 | Boolean interpretResult(Object result) throws ClassNotFoundException; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayAppLifecycleUpdate.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import java.io.Serializable; 4 | import java.net.InetSocketAddress; 5 | 6 | abstract class PlayAppLifecycleUpdate implements Serializable { 7 | static PlayAppLifecycleUpdate stopped() { 8 | return new PlayAppStop(); 9 | } 10 | 11 | static PlayAppLifecycleUpdate running(InetSocketAddress address) { 12 | return new PlayAppStart(address); 13 | } 14 | 15 | static PlayAppLifecycleUpdate failed(Exception exception) { 16 | return new PlayAppStart(exception); 17 | } 18 | 19 | static PlayAppLifecycleUpdate reloadRequested() { 20 | return new PlayAppReload(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayAppReload.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | public class PlayAppReload extends PlayAppLifecycleUpdate { 4 | @Override 5 | public String toString() { 6 | return "PlayAppReload{}"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayAppStart.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import java.net.InetSocketAddress; 4 | 5 | public class PlayAppStart extends PlayAppLifecycleUpdate { 6 | private final InetSocketAddress address; 7 | private final Exception exception; 8 | 9 | @Override 10 | public String toString() { 11 | return "PlayAppStart{" 12 | + "address=" + address 13 | + ", exception=" + exception 14 | + '}'; 15 | } 16 | 17 | public PlayAppStart(InetSocketAddress address) { 18 | this(address, null); 19 | } 20 | 21 | public PlayAppStart(Exception exception) { 22 | this(null, exception); 23 | } 24 | 25 | private PlayAppStart(InetSocketAddress address, Exception exception) { 26 | this.address = address; 27 | this.exception = exception; 28 | } 29 | 30 | public Exception getException() { 31 | return exception; 32 | } 33 | 34 | public InetSocketAddress getAddress() { 35 | return address; 36 | } 37 | 38 | public boolean isRunning() { 39 | return address!=null && exception == null; 40 | } 41 | 42 | public boolean isFailed() { 43 | return exception != null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayAppStop.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | public class PlayAppStop extends PlayAppLifecycleUpdate { 4 | @Override 5 | public String toString() { 6 | return "PlayAppStop{}"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayApplicationDeploymentHandle.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.deployment.internal.Deployment; 4 | import org.gradle.deployment.internal.DeploymentHandle; 5 | 6 | import javax.inject.Inject; 7 | import java.net.InetSocketAddress; 8 | 9 | public class PlayApplicationDeploymentHandle implements DeploymentHandle { 10 | private final PlayRunSpec spec; 11 | private final PlayApplicationRunner playApplicationRunner; 12 | private PlayApplication playApplication; 13 | 14 | @Inject 15 | public PlayApplicationDeploymentHandle(PlayRunSpec spec, PlayApplicationRunner playApplicationRunner) { 16 | this.spec = spec; 17 | this.playApplicationRunner = playApplicationRunner; 18 | } 19 | 20 | @Override 21 | public boolean isRunning() { 22 | return playApplication != null && playApplication.isRunning(); 23 | } 24 | 25 | @Override 26 | public void start(Deployment deployment) { 27 | playApplication = playApplicationRunner.start(spec, deployment); 28 | } 29 | 30 | public InetSocketAddress getPlayAppAddress() { 31 | if (isRunning()) { 32 | return playApplication.getPlayAppAddress(); 33 | } 34 | return null; 35 | } 36 | 37 | @Override 38 | public void stop() { 39 | playApplication.stop(); 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayApplicationRunnerFactory.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.api.internal.file.FileCollectionFactory; 4 | import org.gradle.playframework.extensions.PlayPlatform; 5 | import org.gradle.playframework.extensions.internal.PlayMajorVersion; 6 | import org.gradle.internal.fingerprint.classpath.ClasspathFingerprinter; 7 | import org.gradle.process.internal.worker.WorkerProcessFactory; 8 | 9 | public class PlayApplicationRunnerFactory { 10 | public static PlayApplicationRunner create(PlayPlatform playPlatform, WorkerProcessFactory workerFactory, ClasspathFingerprinter fingerprinter, FileCollectionFactory fileCollectionFactory) { 11 | return new PlayApplicationRunner(workerFactory, createPlayRunAdapter(playPlatform), fingerprinter, fileCollectionFactory); 12 | } 13 | 14 | public static VersionedPlayRunAdapter createPlayRunAdapter(PlayPlatform playPlatform) { 15 | switch (PlayMajorVersion.forPlatform(playPlatform)) { 16 | case PLAY_2_3_X: 17 | return new PlayRunAdapterV23X(); 18 | case PLAY_2_4_X: 19 | return new PlayRunAdapterV24X(); 20 | case PLAY_2_5_X: 21 | return new PlayRunAdapterV25X(); 22 | case PLAY_2_6_X: 23 | return new PlayRunAdapterV26X(); 24 | case PLAY_2_7_X: 25 | default: // assume unknown versions are like the latest one known 26 | return new PlayRunAdapterV27X(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunAdapterV23X.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.playframework.util.CollectionUtils; 4 | 5 | import java.io.File; 6 | import java.util.List; 7 | 8 | public class PlayRunAdapterV23X extends DefaultVersionedPlayRunAdapter { 9 | @Override 10 | protected Class getBuildLinkClass(ClassLoader classLoader) throws ClassNotFoundException { 11 | return classLoader.loadClass("play.core.BuildLink"); 12 | } 13 | 14 | @Override 15 | protected Class getBuildDocHandlerClass(ClassLoader classLoader) throws ClassNotFoundException { 16 | return classLoader.loadClass("play.core.BuildDocHandler"); 17 | } 18 | 19 | @Override 20 | protected Class getDocHandlerFactoryClass(ClassLoader docsClassLoader) throws ClassNotFoundException { 21 | return docsClassLoader.loadClass("play.docs.BuildDocHandlerFactory"); 22 | } 23 | 24 | @Override 25 | protected ClassLoader createAssetsClassLoader(File assetsJar, Iterable assetsDirs, ClassLoader classLoader) { 26 | List assetDirs = CollectionUtils.collect(assetsDirs, file -> { 27 | // TODO: This prefix shouldn't be hardcoded 28 | return new AssetsClassLoader.AssetDir("public", file); 29 | }); 30 | return new AssetsClassLoader(classLoader, assetDirs); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunAdapterV24X.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.playframework.tools.internal.reflection.JavaReflectionUtil; 4 | import org.gradle.playframework.tools.internal.scala.ScalaMethod; 5 | import org.gradle.playframework.tools.internal.scala.ScalaReflectionUtil; 6 | 7 | import java.net.InetSocketAddress; 8 | 9 | public class PlayRunAdapterV24X extends PlayRunAdapterV23X { 10 | @Override 11 | public InetSocketAddress runDevHttpServer(ClassLoader classLoader, ClassLoader docsClassLoader, Object buildLink, Object buildDocHandler, int httpPort) throws ClassNotFoundException { 12 | ScalaMethod runMethod = ScalaReflectionUtil.scalaMethod(classLoader, "play.core.server.DevServerStart", "mainDevHttpMode", getBuildLinkClass(classLoader), getBuildDocHandlerClass(docsClassLoader), int.class, String.class); 13 | Object reloadableServer = runMethod.invoke(buildLink, buildDocHandler, httpPort, "0.0.0.0"); 14 | return JavaReflectionUtil.method(reloadableServer, InetSocketAddress.class, "mainAddress").invoke(reloadableServer); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunAdapterV25X.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | public class PlayRunAdapterV25X extends PlayRunAdapterV24X { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunAdapterV26X.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.playframework.tools.internal.reflection.JavaReflectionUtil; 4 | import org.gradle.playframework.tools.internal.scala.ScalaMethod; 5 | import org.gradle.playframework.tools.internal.scala.ScalaReflectionUtil; 6 | 7 | import java.net.InetSocketAddress; 8 | 9 | public class PlayRunAdapterV26X extends PlayRunAdapterV24X { 10 | @Override 11 | public InetSocketAddress runDevHttpServer(ClassLoader classLoader, ClassLoader docsClassLoader, Object buildLink, Object buildDocHandler, int httpPort) throws ClassNotFoundException { 12 | ScalaMethod runMethod = ScalaReflectionUtil.scalaMethod(classLoader, "play.core.server.DevServerStart", "mainDevHttpMode", getBuildLinkClass(classLoader), int.class, String.class); 13 | Object reloadableServer = runMethod.invoke(buildLink, httpPort, "0.0.0.0"); 14 | return JavaReflectionUtil.method(reloadableServer, InetSocketAddress.class, "mainAddress").invoke(reloadableServer); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunAdapterV27X.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.gradle.playframework.tools.internal.run; 18 | 19 | public class PlayRunAdapterV27X extends PlayRunAdapterV26X { 20 | } -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.api.tasks.compile.BaseForkOptions; 4 | 5 | import java.io.File; 6 | 7 | public interface PlayRunSpec { 8 | 9 | BaseForkOptions getForkOptions(); 10 | 11 | Iterable getClasspath(); 12 | 13 | Iterable getChangingClasspath(); 14 | 15 | File getApplicationJar(); 16 | 17 | File getAssetsJar(); 18 | 19 | Iterable getAssetsDirs(); 20 | 21 | File getProjectPath(); 22 | 23 | int getHttpPort(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunWorkerClientProtocol.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | public interface PlayRunWorkerClientProtocol { 4 | void update(PlayAppLifecycleUpdate result); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/PlayRunWorkerServerProtocol.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import org.gradle.internal.concurrent.Stoppable; 4 | 5 | public interface PlayRunWorkerServerProtocol extends Stoppable { 6 | void currentStatus(Boolean hasChanged, Throwable throwable); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/Reloader.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | public interface Reloader { 4 | Result requireUpToDate() throws InterruptedException; 5 | 6 | class Result { 7 | Throwable failure; 8 | boolean changed; 9 | Result(boolean changed, Throwable failure) { 10 | this.changed = changed; 11 | this.failure = failure; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "Result{" 17 | + "failure=" + failure 18 | + ", changed=" + changed 19 | + '}'; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/run/VersionedPlayRunAdapter.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.run; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.net.InetSocketAddress; 6 | 7 | public interface VersionedPlayRunAdapter { 8 | Object getBuildLink(ClassLoader classLoader, Reloader reloader, File projectPath, File applicationJar, Iterable changingClasspath, File assetsJar, Iterable assetsDirs) throws ClassNotFoundException; 9 | 10 | Object getBuildDocHandler(ClassLoader docsClassLoader, Iterable classpath) throws NoSuchMethodException, ClassNotFoundException, IOException, IllegalAccessException; 11 | 12 | InetSocketAddress runDevHttpServer(ClassLoader classLoader, ClassLoader docsClassLoader, Object buildLink, Object buildDocHandler, int httpPort) throws ClassNotFoundException; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/scala/ScalaCodecMapper.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.scala; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ScalaCodecMapper implements Serializable { 6 | public static String getClassName() { 7 | return "scala.io.Codec"; 8 | } 9 | 10 | public static Object create(ClassLoader cl, String codec) { 11 | ScalaMethod method = ScalaReflectionUtil.scalaMethod(cl, getClassName(), "apply", String.class); 12 | return method.invoke(codec); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/scala/ScalaListBuffer.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.scala; 2 | 3 | import org.gradle.playframework.tools.internal.reflection.JavaReflectionUtil; 4 | 5 | import java.lang.reflect.Method; 6 | import java.util.List; 7 | 8 | public class ScalaListBuffer { 9 | public static Object fromList(ClassLoader cl, List list) { 10 | try { 11 | Class bufferClass = cl.loadClass("scala.collection.mutable.ListBuffer"); 12 | Object buffer = JavaReflectionUtil.newInstance(bufferClass); 13 | Method bufferPlusEq = bufferClass.getMethod("$plus$eq", Object.class); 14 | 15 | for (T elem : list) { 16 | bufferPlusEq.invoke(buffer, elem); 17 | } 18 | return buffer; 19 | } catch (Exception exception) { 20 | throw new RuntimeException(exception); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/scala/ScalaOptionInvocationWrapper.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.scala; 2 | 3 | import org.gradle.internal.Cast; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class ScalaOptionInvocationWrapper { 8 | private final Object obj; 9 | 10 | 11 | public ScalaOptionInvocationWrapper(Object obj) { 12 | this.obj = obj; 13 | } 14 | 15 | public boolean isDefined() { 16 | try { 17 | Method resultIsDefined = obj.getClass().getMethod("isDefined"); 18 | return (Boolean) resultIsDefined.invoke(obj); 19 | } catch (Exception e) { 20 | throw new RuntimeException(e); 21 | } 22 | } 23 | 24 | public T get() { 25 | try { 26 | return Cast.uncheckedCast(obj.getClass().getMethod("get").invoke(obj)); 27 | } catch (Exception e) { 28 | throw new RuntimeException(e); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/scala/ScalaReflectionUtil.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.scala; 2 | 3 | public class ScalaReflectionUtil { 4 | public static ScalaMethod scalaMethod(ClassLoader classLoader, String typeName, String methodName, Class... typeParameters) { 5 | return new ScalaMethod(classLoader, typeName, methodName, typeParameters); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/scala/ScalaSeq.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.scala; 2 | 3 | import org.gradle.playframework.tools.internal.reflection.JavaReflectionUtil; 4 | 5 | import java.lang.reflect.Method; 6 | import java.util.Collection; 7 | 8 | public class ScalaSeq { 9 | public static Object fromList(ClassLoader cl, Collection list) { 10 | try { 11 | Class bufferClass = cl.loadClass("scala.collection.mutable.ListBuffer"); 12 | Object buffer = JavaReflectionUtil.newInstance(bufferClass); 13 | Method bufferPlusEq = bufferClass.getMethod("$plus$eq", Object.class); 14 | for (T elem : list) { 15 | bufferPlusEq.invoke(buffer, elem); 16 | } 17 | Method toList = bufferClass.getMethod("toList"); 18 | return toList.invoke(buffer); 19 | } catch (Exception exception) { 20 | throw new RuntimeException(exception); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/twirl/TwirlCompileSpec.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.twirl; 2 | 3 | import org.gradle.playframework.sourcesets.TwirlImports; 4 | import org.gradle.playframework.sourcesets.TwirlTemplateFormat; 5 | import org.gradle.playframework.tools.internal.PlayCompileSpec; 6 | import org.gradle.api.internal.file.RelativeFile; 7 | 8 | import java.io.Serializable; 9 | import java.util.Collection; 10 | import java.util.List; 11 | 12 | public interface TwirlCompileSpec extends PlayCompileSpec, Serializable { 13 | Iterable getSources(); 14 | 15 | TwirlImports getDefaultImports(); 16 | 17 | Collection getUserTemplateFormats(); 18 | 19 | List getAdditionalImports(); 20 | 21 | List getConstructorAnnotations(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/tools/internal/twirl/VersionedPlayTwirlAdapter.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.tools.internal.twirl; 2 | 3 | import org.gradle.playframework.sourcesets.TwirlImports; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * Returns template info for a specifc Play version. 10 | */ 11 | public interface VersionedPlayTwirlAdapter extends Serializable { 12 | 13 | List getDefaultImports(TwirlImports language); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/gradle/playframework/util/PathUtil.java: -------------------------------------------------------------------------------- 1 | package org.gradle.playframework.util; 2 | 3 | import java.io.File; 4 | 5 | public class PathUtil { 6 | 7 | public static String relativePath(File from, File to) { 8 | String path = from.toPath().relativize(to.toPath()).toString(); 9 | return path.replace(File.separatorChar, '/'); 10 | } 11 | 12 | } 13 | --------------------------------------------------------------------------------