Replies: 1 comment
-
|
I added a draft implementation of the Here is the gist: https://gist.github.com/lefou/4ab9e44c119559ff5e31e1e761d552a4 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This proposal add details how configuration could be made more relocateable in context of
out/folder contents (more) reproducible and filesystem layout agnostic #3660Intro
If we assume, that all paths represented via
os.PathorPathRefare handled by Mill in a relocateable ways (as implemented in PR #6031), we still have the issue that various other String-typed confguration may also contain paths.Where else may absolute path be a problem?
The most prominent occurences are tool options like
javacOptionsorscalacOptions, which may refer to additional plugins or agent jars via a argument string like-Xplugin path/to/plugin.jar.Another cause is stored absolute paths in the produced output of tools. I think, for this kind of issue, there is no generic solution. Either a tool supports some reproducibility options (e.g.
bnd -reproducible=true), supports some virtual environment configuration (like zinc'sVitualFile) or some post-processing is needed. Sometimes it also helps to sanitize inputs/outputs likeMANIFEST.MFfiles and remove timestamps and exact tools versions (if they are not significant).Here I try to address 1.
The problem
Mill's JSON serialization is based on statically typing. To reliably encode and map paths, we need to encode them in types like
os.Path.Seq[String]isn't well suited to hold mixed typed data and can therefore not be used to encode path semantics in a type-safe and robust way.Proposal
I propose a new data type for configs:
Args, which should be used instead of theSeq[String]type we use currently. That type is designed to specifically handle paths as part of otherwise stringly typed configuration data.The proposed new case classes are:
Args- aSeq-like container representing all config parameters.Argscan holdArgandArgGroups. It can be easily converted toSeq[String]and supports bidirectional JSON serializationArg- a single config parameter like-deprecatedor-f.An
Argcan hold aString, aos.Pathor multiple of these representing parts. Those parts will effectively be merged into a single arg (once converted to aString), but can be handled separately in serialization, allowing us to apply path-mappings without falling back to string-manipulations. This allows us to represent parameters like-Xplugin=<file>asArg("-Xplugin=", os.home / "libs/plugin.jar")ArgGroup(kind likeArgs, but we don't want to support recursive nesting) - a group ofArgs that are contextually bound and should not used separately, e.g.-sourceand17. By binding these options, we can easily override some settings without any special parsing, e.g. to override a default to-source21, we could just search for groups starting with-sourceand replace it.Raw Example
Syntactic sugar
How
Argscan be defined in Scala isn't finally set in stone and depends largely on experimentation and tradeoffs of easy-writing vs. easy-reading.I haven't finished my experimentation, but I think we can come up with enough Scala-like convenience to make reading and writing easy enough and a good replacement for
Seq[String].We could use implicit conversion, to use
Stringoros.Pathwhere we expect anArg. I could imagine to also implicitly convert tuples toArgGroups, but that might be not trivial without a lot of boilerplate code. And hopefully, we can use aStringContextto easily write multi-part args via string interpolation, but I haven't tested that yet.Compatibility
Using the new type in existing tasks would be an binary breaking change, so converting existing tasks to it would mean, we need to wait for Mill 2.0.
On the other hand, the new type can hold the same data as
Seq[String], so it can be immediately used internally and in new API.Beta Was this translation helpful? Give feedback.
All reactions