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

Fix issues with _3 and _2.13 dependencies #1301

Merged
merged 7 commits into from
Oct 16, 2022
Merged

Fix issues with _3 and _2.13 dependencies #1301

merged 7 commits into from
Oct 16, 2022

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Oct 11, 2022

Fixes #1241
Having a sane classpath using the Scala 2.13 compiler to compile a Scala 3 project is hard.
This uses some tricks to compile using Scala 2.13 dependencies (since we need the Scala 2.13 macros) and then change the artifacts with Scala 3 artifacts so the Ammonite runtime can compile the macros using the Scala 3 compiler.

Fansi 0.4.0 uses Scala 2.13.8 instead of 2.13.4 for Scala 2.13.
This seems to have a good effect with Scala 3 compatibility, since
now we can swap the artifacts and our tests are not failing anymore.
@lolgab lolgab marked this pull request as ready for review October 12, 2022 14:35
@lolgab lolgab requested review from alexarchambault, lefou and lihaoyi and removed request for lihaoyi October 12, 2022 14:37
@mpollmeier
Copy link
Contributor

Just tested: @main entrypoints don't quite work for scala3 yet with this branch.
With #1298 it works, so maybe you can compare the runtime dependency trees..?

@main def main(name: String) = {
  println(s"Hello, $name!")
}
mill -i "amm[3.2.0].assembly" && out/amm/3.2.0/assembly.dest/out.jar test.sc --name Michael

Script test.sc does not take arguments: "--name" "Michael"

N.b. removing the --name argument doesn't change anything - the @main isn't found either.

@lolgab
Copy link
Member Author

lolgab commented Oct 13, 2022

I didn't fix the @main entrypoints here. The idea was to fix the classpath first and then after this is merged you can rebase #1298 and it works out of the box without having to touch the build.sc file :)
Tried to merge your branch with this locally (excluding the build.sc changes) and your example correctly prints "Hello, Michael!" :)

@mpollmeier
Copy link
Contributor

Oh right, sorry I didn't get that. Yes I can confirm, merging this and then a slightly modified version of #1298 gives us @main entrypoint support for Scala 3 🎉

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Interesting approach. I think we can incorporate this, but I find the new use_3 object quite confusing right now. I hope I find more time later to better understand the code. Would be nice, if we could avoid the many indirections and lookups and the inner deps method in favor of some more explicit defs each resulting in single concrete ivy dependency.

@lolgab
Copy link
Member Author

lolgab commented Oct 14, 2022

I get the dependencies via string so it's impossible to add a dependency without also adding it to the depsNames list which is used to patch the compile-time versions.

@lefou
Copy link
Member

lefou commented Oct 14, 2022

I get the dependencies via string so it's impossible to add a dependency without also adding it to the depsNames list which is used to patch the compile-time versions.

@lolgab I tried hack down what I had in mind. Can you please have a look at #1302 and let me know, whether this improves readability of the dependency setup?

@lolgab lolgab requested a review from lefou October 15, 2022 14:52
@lolgab
Copy link
Member Author

lolgab commented Oct 15, 2022

Thank you @lefou. I merged your changes. As you said, few people touch this repo and we can add the dependencies manually to the list.
It's ready to merge from my side.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Looks good to me. The final goal should be still to support Scala 3 directly, but it's a nice trick to get it work now. Thank you!

@lefou lefou merged commit 5a06226 into master Oct 16, 2022
@lefou lefou deleted the fix-3-213-deps branch October 16, 2022 19:19
@lefou lefou added this to the after 2.5.5 milestone Oct 16, 2022
mpollmeier added a commit to mpollmeier/Ammonite that referenced this pull request Oct 17, 2022
mainargs 0.2.3 added support for scala3 🎉
com-lihaoyi/mainargs#18

The first attempt to upgrade and enable mainargs was
com-lihaoyi#1298, but the build
changes were better handled by com-lihaoyi#1301

So the only thing left is reenabling mainargs for Scala 3.
@mpollmeier
Copy link
Contributor

The only thing left now is to reenable mainargs for Scala 3:
#1303

Thanks for sorting out the build dependencies @lolgab and @lefou!

lolgab pushed a commit that referenced this pull request Oct 17, 2022
mainargs 0.2.3 added support for scala3 🎉
com-lihaoyi/mainargs#18

The first attempt to upgrade and enable mainargs was
#1298, but the build
changes were better handled by #1301

So the only thing left is reenabling mainargs for Scala 3.
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 this pull request may close these issues.

Issues using Ammonite 2.5 in SBT Project
3 participants