Commits
Tarun Sukhani authored c0f485c35d9
feat: playNewApp scaffolding + certs/.env auto-loading (PF-90)
Phase 5 of PF-90. Two related additions:
1. playNewApp task at the framework root. Run as
`./gradlew playNewApp -Pname=foo -Pdest=path` from /opt/play1.
- Validates dest doesn't exist.
- Copies resources/application-skel/ recursively (including the
.gitignore, which copy_directory in Python had to special-case).
- Creates app/models/ and lib/ (mirrors the Python new()).
- Substitutes %APPLICATION_NAME% in conf/application.conf.
- Generates a 64-char SecureRandom secret, writes certs/.env
with PLAY_SECRET=<secret> (chmod 0600 on POSIX), writes
certs/.env.example as a committed template.
- Generates settings.gradle.kts (with includeBuild to the
framework path) and build.gradle.kts (plugin applied + play1
DSL block with frameworkPath/frameworkVersion).
- git init in the new app so playDist works immediately.
- Registered inline in /opt/play1/build.gradle.kts (not in the
plugin) because the plugin's apply() configures source sets
for app/, conf/, test/ — wrong shape for the framework root.
2. certs/.env auto-loading in registerPlayJvmTask and PlayAutotestTask.
Mirrors framework/pym/play/utils.py:loadDotEnv called from
application.py:32. Reads <projectDir>/certs/.env, parses each
KEY=VAL line (strips quotes, skips comments and blanks), feeds
into JavaExec.environment / ProcessBuilder.environment with
putIfAbsent (host env wins). Without this, scaffolded apps fail
at boot because application.secret=${PLAY_SECRET} per fork
hardening can't resolve.
Verified end-to-end: scaffolded fresh app at /tmp/playNewApp-verify
via playNewApp. Generated app has correct file structure, valid
build.gradle.kts, certs/.env with secret, certs/.env.example
template, git initialized. Then ran gradle playRun in the new app
WITHOUT setting PLAY_SECRET in the env — Play booted cleanly and
"Application 'verify-app' is now started !" appeared in the log.
The 404 on the welcome page is an application-skel quirk
(template references /public/playmanual/logo.png which doesn't
exist in the app's public/) unrelated to the plugin.
Note: scaffolded build.gradle.kts uses frameworkVersion =
"1.13.0-SNAPSHOT" (from /opt/play1/build.gradle.kts version).
Until the framework's Ant build cuts a 1.13.0 jar, users of
playNewApp must override to whatever play-X.Y.Z.jar exists in
framework/ (currently 1.12.40).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>