Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] POC Opts (Args) concept#6129

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
lefou wants to merge64 commits intocom-lihaoyi:main
base:main
Choose a base branch
Loading
fromlefou:tr-poc-args-type

Conversation

@lefou
Copy link
Member

@lefoulefou commentedNov 5, 2025
edited
Loading

This PR is still Work in progress, mostly because not all examples are migrated and the API may change. Nevertheless the concept is open for discussion. Please engage!

Summary

BINARY BREAKING CHANGES!

Related to:

This PR contains:

  1. The newmill.api.opt API containing the classesOpts,Opt andOptGroup.

  2. A refactoring of various modules that contain configuration data potentially containing paths - this is a API breaking change to just proof the concept

In contrast to the proposal (#6057) the class is namedOpts, notArgs, since we already have amill.api.Args class used for other purposes.

While this PR can be applied as-is, it's real effect only emerges when also PR#6031 is merged, since otherwise, the paths stored as part of the configuration data will not be relocatable.

API changes in detail

All tasks containing configuration data that also may contain file or directory paths should useOpts instead ofSeq. In case, some non-Seq-like structures are needed, likeMap, the single-elementOpt can be used for values.

Most prominent tasks are:

  • javacOptions: T[Seq[String]] -->T[Opts]
  • scalacOptions: T[Seq[String]] -->T[Opts]
  • kotlincOptions: T[Seq[String]] -->T[Opts]
  • forkArgs: T[Seq[String]] -->T[Opts]
  • forkEnv: T[Map[String, String]] -->T[Map[String, Opt]]

More types?

Feel free to discuss, if more data structure are needed. E.g. theMap[String, Opt] could also be represented asOptsMap, so more value types could be accepted on the rhs, eliminating one error source and resulting in more concise code.

JSON serialization

The JSON sturcture is more complex that the previousSeq[String] equivalent, because it needs to support options, option groups and multi-parts options, which may itself consist of many strings and paths.

A rather complexOpts JSON serialization may look like this:

Opts("-deprecated",OptGroup("-classpath",Opt.mkPath(classpath, sep=":")))
["-deprecated",  ["-classpath",    [      {"path":"/path/to/jar1.jar" },":",      {"path":"/path/to/jar2.jar" },":",      {"path":"/path/to/jar3.jar" }    ]  ]]

Since the JSON serialization for paths re-use the respective upickle-serializers, the root path mapping of PR#6031 may also work here (Resulting is paths like$MILL_OUT/task/to/jar.dest/out.jar).

YAML convenience

In addition, the json reader supports reading of flat json arrays, which means, that allSeq[String] can easily be read asOpts. This was done to make working withOpts as convenient asSeq[String] not only in Scala code but also inYAML configuration code.

This means,build.mill YAML frontmatter andbuild.mill.yaml don't need any changes.

mill-build:scalacOptions:["-verbose"]forkEnv:{ "MY_CUSOTM_ENV": "my-env-value" }

Although the full encoding is also supported but seldomly required.

mill-build:forkArgs:[[["-javaagent:", {"path": "$WORKSPACE/agent.jar"}]]]forkEnv:{ "MY_WORK_DIR": [{"path": "$HOME/workDir"}] }

Caveats

In this current POC, we need to addimport mill.api.opt.*. I'm glad for ideas, how to improve this and make it a single import.

@lefoulefou added laterThe issue is still relevant, but has now high priority right now compat-breakerA PR breaks compatibility and needs to wait till we prepare a major release labelsNov 14, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

compat-breakerA PR breaks compatibility and needs to wait till we prepare a major releaselaterThe issue is still relevant, but has now high priority right now

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@lefou

[8]ページ先頭

©2009-2025 Movatter.jp