-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mill 0.12.8 build support #438
base: 0.23-mill
Are you sure you want to change the base?
Conversation
Hi, thanks for your work! I am not necessary against adding another build tool to the template. So this looks fine to me, but I would appreciate opinions from other maintainers. The one thing that I am unsure about, is whether scala steward can update mill dependencies inside of an g8 template(for sbt this works only if the top level build.sbt file depends on the same libs as the template one). If this does not work, this pull request adds the burden to update dependencies manually. Currently maintaining this template is really low effort and I would like to keep it that way ;) |
@froth sure, I will check the scala steward update of deps because if not this change does not make sense. UPDATE: |
@froth I could not verify Scala Steward run for this but these changes 881f02da might be enough to get automatic dependencies updates in the new UPDATE: |
I'm not so sure we want the template to generate two builds. This is potentially confusing to new users, and leaves experienced users one to clean up as a first chore. I could maybe instead see this as a branch, an alternate repo that we link to, or perhaps use g8's conditionals and prompt for which build system to generate. |
e2c9d44
to
53f4f4b
Compare
@rossabaker very good points. I vote for having a
sbt template field: Conditional generation of build files is implemented in 1326e2065 however this breaks Scala Steward updates because they are based on file extension, build files are now
might configure the update for those conditional files. |
src/main/g8/default.properties
Outdated
@@ -1,3 +1,5 @@ | |||
name = quickstart | |||
organization = com.example | |||
package = $organization$.$name;format="norm,word"$ | |||
|
|||
scala_version = 3.3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never used Mill, but we've solved the problem of duplicate constants in templates at work with a technique similar to this FAQ. I don't know whether Scala Steward would be able to find a 3.3.3 in a template across SBT and Mill.
I'm good with whatever @froth thinks here. It would be nice if there's one source of truth, but it's also not the worst duplication in the world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is exactly the heuristic I haven't been able to determine, if Scala Steward will update Mill from SBT update dependencies. I will try to configure and run Scala Steward in a repo with some outdated deps,
UPDATE
Already got some trace logs:
2025-02-19 00:13:03,848 INFO Process update ch.epfl.scala:sbt-bloop : 1.4.12 -> 1.6.0
2025-02-19 00:13:03,864 DEBUG Execute /opt/scala-steward/pass.sh Password for 'https://[email protected]':
2025-02-19 00:13:04,193 DEBUG Execute git -c core.hooksPath=/dev/null grep -I --fixed-strings --files-with-matches 1.4.12
2025-02-19 00:13:04,208 TRACE project/metals.sbt
2025-02-19 00:13:04,209 TRACE project/project/metals.sbt
2025-02-19 00:13:04,210 TRACE project/project/project/metals.sbt
I am going to remove dependencies until I get one update for both SBT and Mill.
Bingo! Here is the http4s version update. Only build.sbt
is being update so I am going to adjust steward config:
2025-02-19 00:28:05,238 INFO Process update org.http4s:{(http4s-circe, http4s-circe_2.12), (http4s-dsl, http4s-dsl_2.12), (http4s-ember-client, http4s-ember-client_2.12), (http4s-ember-server, http4s-ember-server_2.12)} : 0.23.27 -> 0.23.30
2025-02-19 00:28:05,488 DEBUG Execute git -c core.hooksPath=/dev/null grep -I --fixed-strings --files-with-matches 0.23.27
2025-02-19 00:28:05,498 TRACE build.sbt
2025-02-19 00:28:05,498 TRACE src/main/g8/$if(!sbt.truthy)$build.mill$endif$
2025-02-19 00:28:05,499 TRACE src/main/g8/$if(sbt.truthy)$build.sbt$endif$
2025-02-19 00:28:05,501 TRACE
2025-02-19 00:28:05,609 DEBUG Execute git -c core.hooksPath=/dev/null grep -I --fixed-strings --files-with-matches org.http4s
2025-02-19 00:28:05,616 TRACE build.sbt
2025-02-19 00:28:05,618 TRACE src/main/g8/$if(!sbt.truthy)$build.mill$endif$
2025-02-19 00:28:05,619 TRACE src/main/g8/$if(sbt.truthy)$build.sbt$endif$
2025-02-19 00:28:05,619 TRACE src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala
2025-02-19 00:28:05,620 TRACE src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala
2025-02-19 00:28:05,620 TRACE src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala
2025-02-19 00:28:05,620 TRACE src/main/g8/src/main/scala/$package__packaged$/Jokes.scala
2025-02-19 00:28:05,620 TRACE src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala
2025-02-19 00:28:05,622 TRACE
2025-02-19 00:28:05,678 INFO Create branch update/0.23-scala3-mill/http4s-circe-0.23.30
2025-02-19 00:28:05,680 DEBUG Execute git -c core.hooksPath=/dev/null checkout -b update/0.23-scala3-mill/http4s-circe-0.23.30
2025-02-19 00:28:05,687 TRACE Switched to a new branch 'update/0.23-scala3-mill/http4s-circe-0.23.30'
2025-02-19 00:28:05,690 TRACE
2025-02-19 00:28:05,719 DEBUG Write /opt/scala-steward/workspace/repos/carlosrogue/http4s.g8/build.sbt
2025-02-19 00:28:05,755 DEBUG Execute git -c core.hooksPath=/dev/null status --porcelain --untracked-files=no --ignore-submodules
2025-02-19 00:28:05,765 TRACE M build.sbt
2025-02-19 00:28:05,768 TRACE
2025-02-19 00:28:05,784 DEBUG Execute git -c core.hooksPath=/dev/null commit --all --no-gpg-sign --no-signoff -m Update http4s-circe, http4s-dsl, ... to 0.23.30 in 0.23-scala3-mill
2025-02-19 00:28:05,801 TRACE [update/0.23-scala3-mill/http4s-circe-0.23.30 1b5b237] Update http4s-circe, http4s-dsl, ... to 0.23.30 in 0.23-scala3-mill
2025-02-19 00:28:05,804 TRACE 1 file changed, 1 insertion(+), 1 deletion(-)
2025-02-19 00:28:05,806 TRACE
2025-02-19 00:28:05,810 DEBUG Execute git -c core.hooksPath=/dev/null rev-parse --verify HEAD
2025-02-19 00:28:05,820 TRACE 1b5b237bc35854f0eeda3acfb76742105cfc3316
2025-02-19 00:28:05,822 TRACE
2025-02-19 00:28:05,877 DEBUG Execute git -c core.hooksPath=/dev/null diff --name-only 0.23-scala3-mill update/0.23-scala3-mill/http4s-circe-0.23.30 --
2025-02-19 00:28:05,883 TRACE build.sbt
2025-02-19 00:28:05,885 TRACE
2025-02-19 00:28:05,890 INFO Push 1 commit(s)
ℹ️ configuring Scala Steward file extensions modified the expected files:
updates.fileExtensions = [".sbt",".sc",".scala",".sbt$endif$",".mill$endif$"]
Here is the logs, after custom config 848968a where the 3 giter8 template files were modified:
2025-02-19 00:39:54,349 DEBUG Execute git -c core.hooksPath=/dev/null commit --all --no-gpg-sign --no-signoff -m Update http4s-circe, http4s-dsl, ... to 0.23.30 in 0.23-scala3-mill
2025-02-19 00:39:54,367 TRACE [update/0.23-scala3-mill/http4s-circe-0.23.30 6bbf22f] Update http4s-circe, http4s-dsl, ... to 0.23.30 in 0.23-scala3-mill
2025-02-19 00:39:54,368 TRACE 3 files changed, 3 insertions(+), 3 deletions(-)
2025-02-19 00:39:54,428 DEBUG Execute git -c core.hooksPath=/dev/null diff --name-only 0.23-scala3-mill update/0.23-scala3-mill/http4s-circe-0.23.30 --
2025-02-19 00:39:54,438 TRACE build.sbt
2025-02-19 00:39:54,438 TRACE src/main/g8/$if(!sbt.truthy)$build.mill$endif$
2025-02-19 00:39:54,439 TRACE src/main/g8/$if(sbt.truthy)$build.sbt$endif$
2025-02-19 00:39:54,440 TRACE
2025-02-19 00:39:54,445 INFO Push 1 commit(s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never used Mill, but we've solved the problem of duplicate constants in templates at work with a technique similar to this FAQ. I don't know whether Scala Steward would be able to find a 3.3.3 in a template across SBT and Mill.
I'm good with whatever @froth thinks here. It would be nice if there's one source of truth, but it's also not the worst duplication in the world.
Can live with both :) but are are duplicating the dependency versions anyways, so I would prefer it to not be added to the default.properties
. That way scala version and dependency versions are handled the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree is better to remove it from default.properties
.
7e062c4
to
848968a
Compare
Just now saw that this pull request targets 0.23-scala3. The current workflow is making changes on 0.23 and then merging to 0.23-scala3. This makes maintaining the scala3 template really easy. Could you target 0.23? |
@froth sure, I changed the base to UPDATE: I rebased the branch. |
0d96c3d
to
2794c2c
Compare
I think you have to cherry pick (or whatever) your changes to the |
I am a little unhappy about the usability of this. If someone doesn't know that the template supports mill, they might be confused about what actually happens if you opt out of sbt(and what would happen if we would choose to also support scala-cli?). Maybe a separate branch would be more easy? I am really unsure what would be the easiest solution for the user (and also maintainers). |
3f735dd
to
9271708
Compare
@froth what about adding a property per build tool?
If not then having a separate branch would be O.K. UPDATE:
ANOTHER IMPORTANT UPDATE:
|
def pomSettings = PomSettings( | ||
description = artifactName(), | ||
organization = "$organization$", | ||
url = "https://http4s.org/v0.23/docs/quickstart.html#giter8-template", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the following lines should be dropped, that's the info from the outer build.sbt and not what we want to generate in the template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All PomSettings fields are required. The idea was to add support for publishing this dependency as a jar, when removed there is no more publish tasks available (mill publishLocal
) and the default output from mill jar
is out/jar.dest/out.jar
. I am removing it.
I believe I would actually prefer the separate branch version because it keeps the repo cleaner and in my opinion slighly easier for the user. I am feeling guilty however, because you already invested lot's of effort into this and this would mean throwing away part of of that good work. I really appreciate you contributing and hope this does not comes across overly nitpicky. If you want I can take over from here if you are "done" :) |
@froth no worries, there was a lot of learnings while doing it so no hard feelings, hehehe. If you instruct me on how to create the separate branch, which name, I can publish the separate changes. Also, I agree is a cleaner approach. |
e822c4c
to
43eecbc
Compare
I created a branch 0.23-mill which is currently on the same commit as 0.23. If you base your pull request against it, it should work. After we merged it, we need another PR against 0.23 which documents it's existence in the Readme. |
@froth I created a branch 0.23-build in my account that will contain all these commit (for future reference). I am going to clean up and publish this MR with mill generation files only. |
43eecbc
to
a33f959
Compare
README.md
Outdated
- Scala 2: `sbt new http4s/http4s.g8` | ||
- Scala 3: `sbt new http4s/http4s.g8 --branch 0.23-scala3` | ||
- Java 8: `sbt new http4s/http4s.g8 --branch 0.23-java8` | ||
- Scala 2: `mill -i init http4s/http4s.g8` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Scala 2: `mill -i init http4s/http4s.g8` | |
- Scala 2: `mill -i init http4s/http4s.g8 --branch 0.23-mill` |
README.md
Outdated
- Scala 3: `sbt new http4s/http4s.g8 --branch 0.23-scala3` | ||
- Java 8: `sbt new http4s/http4s.g8 --branch 0.23-java8` | ||
- Scala 2: `mill -i init http4s/http4s.g8` | ||
- Scala 3: `mill -i init http4s/http4s.g8 --branch 0.23-scala3` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two won't work as expected I think, remove them?
Looks good, thanks for your work. The only thing missing is that the pipeline fails. Line 42 in 6ffeb57
I am unsure whether we can get this to work for mill, I can live with removing the test for the mill branch if there is no easy solution for this. |
Yes, I was working on adding mill support for the main project and fixing CI. I will push those changes when getting a green pipeline. (I am on holidays so out for some weeks). You could also add a dummy test and I fix it in another PR: val g8TestMill := taskKey[Unit]("Test generated template for Mill")
// empty project setting
g8TestMill := {} |
Add initial mill build support. Some commands to execute are:
mill run
to execute the applicationmill -w compile
for incremental compilation (watching sources).mill test
to execute the test suitemill assembly
to generate uber jar:out/assembly.dest/out.jar