Skip to content
CAI
Software that uses CAICheck a score

playframework/twirl

57.5

Adequate · 14 November 2026

4.8k

lines of production code

Scala

with Java

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add Maven plugin for compiling Twirl templates

Introduces the \maven-twirl\ plugin, providing \TwirlCompileMojo\ and \TwirlTestCompileMojo\ to compile Twirl templates into Scala sources during the Maven build lifecycle. The plugin supports configurable source/output directories, inclusion/exclusion filters, template formats, custom imports, constructor annotations, and source encoding, with a test suite verifying the end-to-end compilation of main and test templates.

maven-twirl · high confidence

Added Gradle wrapper and configuration files

The gradle-twirl directory now includes the Gradle wrapper scripts (gradlew, gradlew.bat), a .gitattributes file to enforce correct line endings for cross-platform compatibility, and a .gitignore file to exclude Gradle cache and build directories. This allows users to build the project using the bundled Gradle version without requiring a pre-installed Gradle environment.

gradle-twirl · high confidence

Added internal IO utility object for file and stream operations

The parser module now includes a new private \TwirlIO\ object that provides internal utilities for reading files, streams, and URLs as strings or byte arrays, writing strings to files, and deleting directories recursively. This object handles character encoding via a configurable codec and ensures resources are closed quietly, supporting the parser's underlying file I/O needs without exposing these capabilities as public API.

parser/src/main · high confidence

New Java API for Twirl template compilation

Added a new Java entry point class, \play.japi.twirl.compiler.TwirlCompiler\, which exposes Twirl template compilation capabilities to Java-based build tools like Maven and Gradle. This API allows users to compile Twirl templates programmatically from Java code, handling source encoding, formatter types, additional imports, and constructor annotations, while automatically resolving the correct Scala version and default imports at runtime.

compiler/src/main · high confidence

Removals

Removal of legacy Scala template parser and AST nodes

The \ScalaTemplateParser\ class and the \TreeNodes\ object, which defined the abstract syntax tree structures for the Play2 template language, have been removed from the codebase. This eliminates the recursive descent parser implementation and its associated data models, indicating a shift away from this specific template parsing mechanism.

src/main · high confidence

Behavioural changes

Automated CI test script for Play Framework components

A new shell script, scripts/test-code.sh, has been added to automate the testing and local publishing of the Play Framework's core components (API, parser, compiler, Maven plugin) and the Gradle plugin. The script orchestrates sbt commands to run full test suites for JVM and JS artifacts, publishes local artifacts with specific Scala versions, and executes Gradle checks, ensuring that the compiler and plugins are tested against the configured Scala matrix before final plugin verification.

scripts · high confidence

Gradle plugin now supports incremental compilation and Gradle 7.1+

The Gradle plugin for Twirl templates has been refactored to support incremental compilation and compatibility with Gradle 7.1 and later. This change introduces a new internal architecture using Gradle's WorkAction API (TwirlCompileAction) to handle template compilation and deletion individually, enabling better build performance through incremental builds. It also adds support for configuring template imports, constructor annotations, source encoding, and formatter types via the TwirlSourceDirectorySet, while maintaining backward compatibility with older Gradle versions through a deprecated Gradle7-specific implementation.

gradle-twirl/src/main/java/play/twirl/gradle/internal · high confidence

New Gradle plugin for compiling Twirl templates

The Gradle plugin for Twirl template compilation has been rewritten from scratch to support modern Gradle features. The new \TwirlPlugin\ (ID \com.playframework.twirl\) introduces a \twirl\ extension for configuring the Scala version, and allows per-source-set customization of template formats, imports, constructor annotations, and source encoding. Compilation is now handled by the \TwirlCompile\ task, which leverages Gradle's Worker API with process isolation for better performance and stability, and supports incremental builds and the Gradle Build Cache. The plugin automatically registers generated Scala code with the appropriate source sets and ensures the Twirl compiler dependency is managed via a dedicated, non-consumable configuration.

gradle-twirl/src/main/java/play/twirl/gradle · high confidence

New parser and compiler architecture with Scala 3 support

The template engine has been rebuilt with a new recursive-descent parser (TwirlParser) and updated compiler (TwirlCompiler) that replace the legacy implementation. This change introduces native support for Scala 3, including specific syntax adjustments like the 'using' keyword for implicit parameters and handling of vararg splices. The new parser enforces stricter grammar rules, such as allowing imports, variables, and sub-templates within 'if'/'else' blocks, and provides more accurate source position mapping for error reporting. The compiler now generates code compatible with both Scala 2 and Scala 3, ensuring consistent behavior across versions.

repository · high confidence

SbtTwirl plugin refactored for Scala 3 and sbt 1.x compatibility

The sbt-twirl plugin source has been restructured to support Scala 3 and modern sbt versions. A new \SbtTwirlCompat\ object provides a \Def.uncached\ shim for Scala 2 (where it is missing) while remaining empty for Scala 3, ensuring consistent behavior across versions. The main \SbtTwirl\ plugin and \TemplateCompiler\ have been updated to use the \sbt.{given, \_}\ import syntax required by sbt 1.x, and the compiler now explicitly accepts a \scalaVersion\ parameter to generate correct code for both Scala 2 and Scala 3. Additionally, the plugin's package has moved from \play.twirl.sbt\ to \play.twirl.sbt\ (consistent with the new groupId \org.playframework.twirl\), and the template compilation logic now correctly handles the \inclusiveDot\ setting and source encoding configuration.

sbt-twirl/src/main · high confidence

Twirl API core rewritten for Scala 2.12, 2.13, and 3

The Twirl template engine API in \api/shared/src/main\ has been completely rewritten to support Scala 2.12, 2.13, and 3. This introduces version-specific implementations of \BaseScalaTemplate\, \TwirlHelperImports\, and \package.scala\ to leverage idiomatic features of each Scala version (e.g., \scala.jdk.CollectionConverters\ in 2.13/3 vs \scala.collection.JavaConverters\ in 2.12, and Scala 3 syntax). The core template rendering logic in \BaseScalaTemplate\ now uses a dedicated \$twirl\_\_format\ parameter to avoid variable name clashes, and the \StringInterpolation\ class provides \html\, \xml\, and \js\ interpolators. New helper imports include \TwirlRichDate\ for date formatting, \TwirlRichString\ for conditional rendering, and \TwirlFeatureImports\ for language features like \@defining\, \@using\, and truthiness checks. The \Template\ traits now support up to 22 parameters, and \Html\ escaping is implemented via a custom \StringEscapeUtils\ to prevent XSS.

api/shared/src/main · high confidence

Test coverage

Added Scala 2-specific test helper for Twirl compiler integration; Added Scala 3 test helper for Twirl template compilation; Added Scala.js compilation test suite for Twirl templates; Added compiler test suite and benchmarking tool; Added comprehensive parser test suite; Added functional and unit tests for the Twirl Gradle plugin; Added parser test resources for case expressions, imports, and else-if logic; Added scripted test for Twirl compilation with Scala 3; Added scripted test for compiling templates with sbt plugin; Added scripted test for template compilation; Added test coverage for Twirl API content equality, formatting, and string interpolation; Added test for Scala.js compilation; Added tests for TemplateMapping and TemplatePosition; Added tests for the Java Twirl compiler API; Expanded compiler test suite for Twirl template features; Removal of TemplateParserSpec and test template.

Dependencies

Build infrastructure migrated to sbt 2.x with updated tooling and Scala versions

The project's build system has been upgraded to sbt 2.x (specifically the 2.1.0 nightly build), replacing the previous sbt 1.x environment. This migration includes updating core plugins such as sbt-scalajs to 1.22.0, sbt-mima-plugin to 1.2.1, and sbt-header to 5.11.0, alongside adding sbt-maven-plugin 0.0.4. The build now targets Java 17 and supports Scala versions 2.12.21, 2.13.18, and 3.3.8, with specific compiler flags configured for cross-compilation and binary compatibility checks.

project · high confidence

Introduce Gradle wrapper for the Twirl plugin project

The project now includes a Gradle wrapper configuration (gradle-wrapper.properties) that pins the build tool to version 9.8.0 (all distribution). This ensures that all developers and CI environments use the same Gradle version, improving build reproducibility and removing the dependency on a globally installed Gradle.

gradle-twirl/gradle · high confidence

New Gradle plugin and build infrastructure for Twirl

This change introduces a new Gradle plugin for compiling Twirl templates, located in the \gradle-twirl\ directory. The plugin is configured via \build.gradle.kts\ and \gradle/libs.versions.toml\, utilizing Gradle Version Catalogs to manage dependencies such as Spotless 8.10.2, AssertJ 3.27.7, and Freemarker 2.3.35. It publishes under the ID \org.playframework.twirl\ and includes signing and Nexus publishing support. Additionally, the root \build.sbt\ has been significantly refactored to support Scala 3, cross-compilation for JVM and JS platforms, and binary compatibility checks via MiMa, while the \docs\ project now uses a separate \build.sbt\ to handle Play documentation generation.

(dependencies) · high confidence

Housekeeping

Project initialization and tooling configuration

The repository has been initialized with a new Apache 2.0 license, a comprehensive README documenting the Twirl template engine for both sbt and Maven, and a .gitignore file updated to exclude IDE and build artifacts. Additionally, the project is now configured with scalafmt version 3.11.5 for code formatting, and a .git-blame-ignore-revs file has been added to ignore automated reformatting commits.

(repo-wide) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 60 → 57 (-2.7)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 61 → 57 (-3.9)
  • Architecture 93 → 93 (+0.0)
  • Maturity 48 → 48 (+0.0)
  • Readiness 79 → 70 (-8.2)
  • Security 79 → 72 (-6.4)

Resolved (1)

  • Off-boarding risk: anonymized user #1

New (8)

  • Edited copies of one member (3 members, 23+ corresponding lines) (api/shared/src/main/scala-2.12/play/twirl/api/BaseScalaTemplate.scala)
  • Edited copy of a member (14 corresponding lines) (api/shared/src/main/scala-2.12/play/twirl/api/package.scala)
  • Edited copy of a member (24 corresponding lines) (api/shared/src/main/scala/play/twirl/api/utils/StringEscapeUtils.scala)
  • Edited copy of a member (38 corresponding lines) (parser/src/main/scala/play/twirl/parser/TwirlParser.scala)
  • Edited copy of a member (5 corresponding lines) (maven-twirl/src/main/java/play/twirl/maven/TwirlCompileMojo.java)
  • Edited copy of a member (7 corresponding lines) (gradle-twirl/src/main/java/play/twirl/gradle/internal/DefaultTwirlSourceDirectorySet.java)
  • Edited copy of a member (8 corresponding lines) (compiler/src/main/scala/play/twirl/compiler/TwirlCompiler.scala)
  • Off-boarding risk: anonymized user #1

Changes since last survey

  • 6 commits — 6 feature/other, 0 fixes

By area

  • (repo) — 3 commits
  • docs/build.sbt — 1 commit
  • gradle-twirl/gradle — 1 commit
  • project/plugins.sbt — 1 commit

Notable commits

  • change: Bump com.diffplug.spotless from 8.10.4 to 8.11.0 in /gradle-twirl
  • change: Merge pull request #1356 from playframework/dependabot/gradle/gradle-twirl/gradle-wrapper-9.8.2
  • change: Merge pull request #1357 from scala-steward/update/patches
  • change: Merge pull request #1360 from playframework/dependabot/gradle/gradle-twirl/com.diffplug.spotless-8.11.0
  • change: sbt-bloop 2.1.3 (was 2.1.2)
  • change: scala3-compiler 3.3.9 (was 3.3.8)

Architecture

  • Unchanged — 0 containers · 3 contexts · 0 edges

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

playframework/twirl was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 53e6024dce612c89ee535dfd2c7de0b6a2858a02 — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-e1a3b69fc8ee.