Skip to content
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 simpler mill.scalalib.Dep serialization for common cases #3417

Closed
lihaoyi opened this issue Aug 24, 2024 · 1 comment · Fixed by #3490
Closed

Add simpler mill.scalalib.Dep serialization for common cases #3417

lihaoyi opened this issue Aug 24, 2024 · 1 comment · Fixed by #3490
Milestone

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Aug 24, 2024

Dep has a lot of fields, most of which are optional, but together it makes the serialized JSON impossible to skim. We should add some special casing to make the serialized form match the code string-literal form in the common case. e.g. instead of

$ cat /Users/lihaoyi/Github/mill/out/interation-tester-workdir/7385872308266233696/out/myplugin/test/testMill/ivyDeps.json
{
    "value": [
        {
            "dep": {
                "module": {
                    "organization": {
                        "value": "com.lihaoyi"
                    },
                    "name": {
                        "value": "mill-dist"
                    },
                    "attributes": {}
                },
                "version": "0.12.0-M0-42-581840-DIRTY17588c08",
                "configuration": {
                    "value": "default(compile)"
                },
                "minimizedExclusions": {
                    "data": "coursier.core.MinimizedExclusions.ExcludeNone"
                },
                "publication": {
                    "name": "",
                    "type": {
                        "value": ""
                    },
                    "ext": {
                        "value": ""
                    },
                    "classifier": {
                        "value": ""
                    }
                },
                "optional": false,
                "transitive": true
            },
            "cross": {
                "$type": "mill.scalalib.CrossVersion.Constant",
                "value": "",
                "platformed": false
            },
            "force": false
        }
    ],
    "valueHash": -1186909625,
    "inputsHash": -1440589820
}

We should serialize as

"com.lihaoyi:mill-dist:0.12.0-M0-42-581840-DIRTY17588c08"

We can preserve the existing verbose serialization for cases that fall outside the common case, but in most cases we should be able to get by with the short serialized form

@lefou
Copy link
Member

lefou commented Aug 28, 2024

I'd really love, if we could avoid to embed the corsier.Dependency class in our Dep class, once we can break compatibility. Beside the JSON representation which gets easier this way, we can fix other issues as well, e.g. the handling of excludes (since exclusions it's deprecated in coursier.Dependency in favor to minimizedExcludes which is a large data structure instead of high level meta data). It also brings us more close to an coursier-free API (#2071), where all coursier related stuff can live in workers.

Since I'm personally thinking of experimenting with alternative dependency resolvers, having a coursier free API in Mill would make it easier to drop-in alternatives, for whatever reasons.

Regarding the serialized format: Most typical dependency setups can be easily represented org:name:version with appended ; separated key=value pairs. And some other settings from coursier.Dependency are even unsupported for Maven-dependencies and likely untested in Mill. It's better to model explicitly what we support and convert to coursier when needed.

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 a pull request may close this issue.

2 participants