Skip to content

Remove workarounds needed for Scala 2.12.17 / scala-xml 2.1.0 / sbt#11441

Merged
mkurz merged 7 commits into
playframework:mainfrom
mkurz:rm_sbt_workarounds
Feb 9, 2023
Merged

Remove workarounds needed for Scala 2.12.17 / scala-xml 2.1.0 / sbt#11441
mkurz merged 7 commits into
playframework:mainfrom
mkurz:rm_sbt_workarounds

Conversation

@mkurz

@mkurz mkurz commented Sep 27, 2022

Copy link
Copy Markdown
Member

Introduced in #11435

Can be dropped as soon as sbt releases a version with it's Scala version upgraded (= 2.12.17+, where scala-xml 2.x gets pulled in), see sbt/sbt#7021, probably this will be sbt 1.8.0-M1

@mkurz

mkurz commented Nov 7, 2022

Copy link
Copy Markdown
Member Author

sbt 1.8 breaks our scripted tests, see #11527

Comment thread .github/workflows/build-test.yml Outdated
Comment thread .github/workflows/build-test.yml Outdated
Comment thread documentation/manual/hacking/Translations.md Outdated
Comment thread documentation/manual/releases/release29/migration29/Migration29.md Outdated
Comment thread documentation/manual/releases/release29/migration29/Migration29.md Outdated
Comment thread documentation/project/build.properties Outdated
Comment thread project/build.properties Outdated

@felipebonezi felipebonezi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any migration needed for SBT 1.8? If so, we could provide a link to help some who needs to migrate from 1.7 to 1.8.

@mkurz

mkurz commented Feb 9, 2023

Copy link
Copy Markdown
Member Author

This pull request is finished, however depends on sbt/sbt#7147. Locally everything works for me (including scripted tests).

Last commit also implements bgRun:

$ sbt
[info] welcome to sbt 1.8.3-SNAPSHOT (Eclipse Adoptium Java 11.0.17)
...
[play-scala-seed] $ bgRun
Starting server

--- (Running the application, auto-reloading is enabled) ---

INFO  p.c.s.AkkaHttpServer - Listening for HTTP on /127.0.0.1:9000
[success] Total time: 1 s, completed Feb 9, 2023, 12:25:09 PM
[play-scala-seed] $ 

# App is running in the background now

[play-scala-seed] $ 

# Making first request to localhost:9000, following log appears:

INFO  p.a.h.HttpErrorHandlerExceptions - Registering exception handler: guice-provision-exception-handler
2023-02-09 12:25:14 INFO  play.api.http.EnabledFilters  Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):

    play.filters.csrf.CSRFFilter
    play.filters.headers.SecurityHeadersFilter
    play.filters.hosts.AllowedHostsFilter
2023-02-09 12:25:14 INFO  play.api.Play  Application started (Dev) (no global state)
[play-scala-seed] $ 

# Let's see the running processes:

[play-scala-seed] $ ps
[info] JobHandle(1, bgRun, ProjectRef(uri("file:/home/mkurz/work/play-scala-seed/"), "root") / Compile / bgRun)
[success] Total time: 0 s, completed Feb 9, 2023, 12:25:21 PM
[play-scala-seed] $ 

# Again but with bgList:

[play-scala-seed] $ show bgList
[info] * JobHandle(1, bgRun, ProjectRef(uri("file:/home/mkurz/work/play-scala-seed/"), "root") / Compile / bgRun)
[success] Total time: 0 s, completed Feb 9, 2023, 12:25:28 PM
[play-scala-seed] $ 

# Now let's change a file and see if re-compiling works:

[play-scala-seed] $ 
[info] compiling 1 Scala source to /home/mkurz/work/play-scala-seed/target/scala-2.13/classes ...
                    
--- (RELOAD) ---
                    
2023-02-09 12:25:48 INFO  p.a.http.HttpErrorHandlerExceptions  Registering exception handler: guice-provision-exception-handler
2023-02-09 12:25:48 INFO  play.api.http.EnabledFilters  Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):

    play.filters.csrf.CSRFFilter
    play.filters.headers.SecurityHeadersFilter
    play.filters.hosts.AllowedHostsFilter
2023-02-09 12:25:48 INFO  play.api.Play  Application started (Dev) (no global state)
[play-scala-seed] $ 

# Worked :) Again check the processes:

[play-scala-seed] $ ps
[info] JobHandle(1, bgRun, ProjectRef(uri("file:/home/mkurz/work/play-scala-seed/"), "root") / Compile / bgRun)
[success] Total time: 0 s, completed Feb 9, 2023, 12:25:52 PM

# Now let's shutdown process 1

[play-scala-seed] $ bgStop 1
Stopping server
[success] Total time: 0 s, completed Feb 9, 2023, 12:25:54 PM
2023-02-09 12:25:54 INFO  p.a.i.l.c.CoordinatedShutdownSupport  Starting synchronous coordinated shutdown with ServerStoppedReason reason and 35000 milliseconds timeout
2023-02-09 12:25:54 INFO  play.core.server.AkkaHttpServer  Stopping Akka HTTP server...
2023-02-09 12:25:54 INFO  play.core.server.AkkaHttpServer  Terminating server binding for /127.0.0.1:9000
2023-02-09 12:25:54 INFO  play.core.server.AkkaHttpServer  Running provided shutdown stop hooks

# Start app again:

[play-scala-seed] $  bgRun
Starting server

--- (Running the application, auto-reloading is enabled) ---

INFO  p.c.s.AkkaHttpServer - Listening for HTTP on /127.0.0.1:9000
[success] Total time: 1 s, completed Feb 9, 2023, 12:29:20 PM

# Let's try to start a second app:

[play-scala-seed] $ bgRun
Not starting server since one is already started
[success] Total time: 0 s, completed Feb 9, 2023, 12:29:23 PM

# Only one app allowed. Let's check if only one process is running (the second bgRun needs to be ignored)

[play-scala-seed] $ ps
[info] JobHandle(2, bgRun, ProjectRef(uri("file:/home/mkurz/work/play-scala-seed/"), "root") / Compile / bgRun)
[success] Total time: 0 s, completed Feb 9, 2023, 12:29:23 PM
[play-scala-seed] $ 

# Worked!

mkurz added 2 commits February 9, 2023 17:21
When a request hits Play and causes a re-compilation there needs to be
an open LoggerContext sbt can use for logging. Since sbt 1.8.0 the
LoggerContext gets closed after a user triggered command/task is finished,
but re-compilation takes place _after_ a command ran (e.g. "run")
@mkurz mkurz force-pushed the rm_sbt_workarounds branch from b9458b8 to f958f5f Compare February 9, 2023 20:48
@mkurz mkurz marked this pull request as ready for review February 9, 2023 20:48
@mkurz

mkurz commented Feb 9, 2023

Copy link
Copy Markdown
Member Author

Instead of opening up methods and keys in sbt (sbt/sbt#7147), I moved PlayRun to the sbt package. Originally I wanted to move the object to sbt.play.run, but because of Scala's relative import feature there were too many clashes, so sbt.PlayRun will be fine.
I am not 100% happy, but ok with that now.

@mkurz mkurz merged commit 6753f9e into playframework:main Feb 9, 2023
@mkurz mkurz deleted the rm_sbt_workarounds branch February 9, 2023 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants