Skip to content

Use standard sbt#28599

Merged
alexduf merged 2 commits intomainfrom
adu-standard-sbt
Feb 13, 2026
Merged

Use standard sbt#28599
alexduf merged 2 commits intomainfrom
adu-standard-sbt

Conversation

@alexduf
Copy link
Contributor

@alexduf alexduf commented Feb 12, 2026

Why?

When retracing the history of the ./sbt script, we can go back to May 2012

Back in 2012 it was good practice to embed the SBT jar in the repo as well as having a running script that could be customised to have specific JVM and SBT options.

The best practices have moved-on long ago: it is now common to assume that sbt will be installed on the engineers machine and the CI, and SBT itself is capable of fetching the right version based on the project/build.properties.

SBT has also added support for the .jvmopts file back in 2019, meaning the last valid reason to keep the custom ./sbt script is now gone, and we can achieve the same feature using the latest best practices.

What's the value?

An engineer first starting on this project will be able to use "muscle memory" and type sbt directly in their terminal without having to remember that this project is a special case.

It also greatly simplifies plugging a debugger in our app from IntelliJ

Habits

I've re-introduced an ./sbt script that informs of this change to ensure as smooth a transition as possible. It displays the following:

❯ ./sbt
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️  NOTICE: Using the `./sbt` wrapper is no longer necessary.

   You can now run 'sbt' directly instead of './sbt'
   JVM options are configured in the .jvmopts file
   See: https://github.com/guardian/frontend/pull/28599
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

@alexduf alexduf requested a review from a team as a code owner February 12, 2026 08:41
@alexduf alexduf added the maintenance Departmental tracking: maintenance work, not a fix or a feature label Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

@alexduf alexduf changed the title Move to using standard sbt Use standard sbt Feb 12, 2026
So no-one gets blocked
Copy link
Member

@rtyley rtyley left a comment

Choose a reason for hiding this comment

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

Sounds like this fixes #28075 - yay, well done! 👍 🥇

-Xmx8G
-XX:ReservedCodeCacheSize=128m
-XX:NewRatio=4
-Duser.timezone=Australia/Sydney
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to add a comment to this file explaining why we're using an Australian timezone – I'm guessing it's to make sure we don't make assumptions in the logic that the reader is always in the UK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find a description of the format for .jvmopts and therefore I'm feeling a little worried about adding a comment in there (I did think about it)

Yes the timezone set to australia is specifically to mess with the timezone so nobody makes assumptions about the timezones

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we can add it as a comment! Done in #28607

sbt
. ~/.sbtconfig
fi
# sleep for a few seconds to ensure the user sees the message
sleep 10
Copy link
Contributor

Choose a reason for hiding this comment

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

😴

Copy link
Contributor

@SiAdcock SiAdcock left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @alexduf 👏

@alexduf alexduf merged commit 72e6e4b into main Feb 13, 2026
11 checks passed
@alexduf alexduf deleted the adu-standard-sbt branch February 13, 2026 10:17
@gu-prout
Copy link

gu-prout bot commented Feb 13, 2026

Seen on ADMIN-PROD (merged by @alexduf 9 minutes and 4 seconds ago)

@gu-prout
Copy link

gu-prout bot commented Feb 13, 2026

Seen on FRONTS-PROD (merged by @alexduf 9 minutes and 25 seconds ago)

rtyley added a commit that referenced this pull request Feb 13, 2026
…t timezone

Grant Klopper first made this change to the Frontend codebase in June 2014 with
#4713 - he explained:

> "dev machines will now run in a far away timezone so it is more obvious when you get a timezone wrong"

With the wonderful work to drop the custom `sbt` script in #28599
in January 2026, we weren't sure (#28599 (comment))
if we could keep the helpful comment explaining why the timezone was used - can the `.jvmopts` file, where
the setting now lives, accept comments!?

It turns out `sbt` takes the input from `.jvmopts` here, calling `$(loadConfigFile .jvmopts)`:

https://github.com/sbt/sbt/blob/v1.12.2/sbt#L869

The `loadConfigFile()` function reads in each line of the file, and crucially calls `eval` on it:

```
eval echo $line
```

https://github.com/sbt/sbt/blob/v1.12.2/sbt#L771

The definition of `eval` is:

> "The eval utility shall construct a command by concatenating arguments together, separating each with a <space>. The constructed command shall be read and executed by the shell."

The upshot is that this line of input:

```
-Duser.timezone=Australia/Sydney # because it is too easy for devs
```

...becomes the shell evaluation of:

```
echo -Duser.timezone=Australia/Sydney # because it is too easy for devs
```

...which as far as the shell is concerned, is just:

```
echo -Duser.timezone=Australia/Sydney
```

...so we _are_ allowed comments!

This behaviour was added to the sbt launcher script with this commit in
June 2013, as part of sbt/sbt#6458:

sbt/sbt@1835225

We can double-check it works by running `sbt -v` to see the arguments the launcher script passed to Java:

```
% sbt -v
[sbt_options] declare -a sbt_options='()'
[process_args] java_version = '11'
[copyRt] java9_rt = '/Users/roberto_tyley/.sbt/1.0/java9-rt-ext-amazon_com_inc__11_0_22/rt.jar'
# Executing command line:
java
-Xmx8G
-XX:ReservedCodeCacheSize=128m
-XX:NewRatio=4
-Duser.timezone=Australia/Sydney
-DSTAGE=DEV
-DAPP_SECRET=this_is_not_a_real_secret_just_for_tests
-Dsbt.script=/opt/homebrew/Cellar/sbt/1.12.0/libexec/bin/sbt
-Dscala.ext.dirs=/Users/roberto_tyley/.sbt/1.0/java9-rt-ext-amazon_com_inc__11_0_22
-jar
/opt/homebrew/Cellar/sbt/1.12.0/libexec/bin/sbt-launch.jar

[info] welcome to sbt 1.12.2 (Amazon.com Inc. Java 11.0.22)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature Seen-on-ADMIN-PROD Seen-on-FRONTS-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants