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

Support pure JavaModules #155

Merged
merged 12 commits into from
May 30, 2024
Merged

Support pure JavaModules #155

merged 12 commits into from
May 30, 2024

Conversation

lefou
Copy link
Collaborator

@lefou lefou commented May 30, 2024

Looks like there is no need for being a ScalaModule at all.
There is some sanity check, but it looks like not really needed.

Fix #154

I also fixed an unrelated issue with ExtraCoursierSupport, which was inheriting ScalaModule. Instead of extending ScalaModule it should use the bindDependency task provided for exactly that use case by CoursierSupport. Without this fix, extending ExtraCoursierSupport can be problematic in downstream modules.

lefou added 3 commits May 30, 2024 10:41
Looks like there is no need for being a `ScalaModule` at all.
There is some sanity check, but it looks like not really needed.

Fix #154
@lolgab
Copy link
Owner

lolgab commented May 30, 2024

Can you add a test that checks some java code?

@lefou lefou marked this pull request as draft May 30, 2024 08:57
Comment on lines 120 to 122
case _ =>
// FIXME: ask Mill, but `mill.main.BuildInfo` isn't available in older versions
T.task("2.13")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
case _ =>
// FIXME: ask Mill, but `mill.main.BuildInfo` isn't available in older versions
T.task("2.13")
case _ => T.task("3")

I would set as "3" so it will continue to work for at least two decades. We don't even need to change it to mill.main.BuildInfo

Copy link
Owner

Choose a reason for hiding this comment

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

Actually, it can be null. Let me push a commit on top

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could also remove the whole sanity check or make it optional by using an Option[String] for the Scala version.

Copy link
Owner

Choose a reason for hiding this comment

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

I used String or null since Option can't be used directly with the Java API, and I didn't want to use java's Optional.
I pushed a commit on top

@lolgab
Copy link
Owner

lolgab commented May 30, 2024

Very cool that MiMa can be used to test Java projects! It's a very useful tool, maybe this can be another differentiator for Java folks to move to Mill! :)

@lolgab lolgab marked this pull request as ready for review May 30, 2024 09:12
@lefou
Copy link
Collaborator Author

lefou commented May 30, 2024

Yeah, I think we could even drop the need to be a PublishModule, since we already have all targets to configure the jars to compare. Being a PublishModule just brings some nice defaults, but we could match this dynamically, like I did for the scalaBinVersion task. That way, users can use MiMa in arbitrary modules, without messing with mill __.publish targets.

@lefou lefou mentioned this pull request May 30, 2024

val errorOrNull: String =
mimaWorker().reportBinaryIssues(
scalaBinVersionOrNullTask().getOrElse(null),
Copy link
Owner

Choose a reason for hiding this comment

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

I think Option has a .orNull method

Suggested change
scalaBinVersionOrNullTask().getOrElse(null),
scalaBinVersionOrNullTask().orNull,

@lefou
Copy link
Collaborator Author

lefou commented May 30, 2024

Huh, itest for Mill 0.11.0 fails with:

Publishing Artifact(com.github.lolgab,mill-mima_mill0.11_2.13,0.1.0-11-b9e295-DIRTYfe46ad38) to ivy repo /home/lefou/work/opensource/lolgab-mill-mima/out/itest/0.11.0/test.dest/ivyRepo/local
Publishing Artifact(com.github.lolgab,mill-mima-worker-api_2.13,0.1.0-11-b9e295-DIRTYfe46ad38) to ivy repo /home/lefou/work/opensource/lolgab-mill-mima/out/itest/0.11.0/test.dest/ivyRepo/local
Publishing Artifact(com.github.lolgab,mill-mima-worker-impl_2.13,0.1.0-11-b9e295-DIRTYfe46ad38) to ivy repo /home/lefou/work/opensource/lolgab-mill-mima/out/itest/0.11.0/test.dest/ivyRepo/local
Starting integration test [5/5]: java
Invoking integration test [5/5]: java: Targets(targets=List(prepare),expectedExitCode=0,env=Map(),noServer=true)
Failed integration test [5/5]: java

Details for 1 failed tests: 
Output of failed test: java
---------- Output for Invocation: TestInvocationResult(Targets(targets=List(prepare),expectedExitCode=0,env=Map(),noServer=true),Failed,Vector(),Vector(),Some(/home/lefou/work/opensource/lolgab-mill-mima/out/itest/0.11.0/test.dest/java/out-532035302293496723.log))
[info] compiling 2 Scala sources to /home/lefou/work/opensource/lolgab-mill-mima/out/itest/0.11.0/test.dest/java/out/mill-build/compile.dest/classes ...
[error] /home/lefou/work/opensource/lolgab-mill-mima/out/itest/0.11.0/test.dest/java/build.sc:14:8: object creation impossible.
[error] Missing implementation for member of trait ScalaModule:
[error]   def scalaVersion: mill.T[String] = ???
[error] object curr extends Common with Mima {
[error]        ^
[error] one error found
1 targets failed
compile Compilation failed

---------- End of output

But I fail to see where we still require ScalaModule

@lefou
Copy link
Collaborator Author

lefou commented May 30, 2024

Oh, there is an issue with the ExtraCoursierSupport for Mill 0.11

Instead of extending `ScalaModule` it should use the `bindDependency` task provided by `CoursierSupport`. Otherwise, it can be problematic in downstream modules.
@lefou
Copy link
Collaborator Author

lefou commented May 30, 2024

This is good for a next review now. Once merged, a new release would be nice.

@lolgab lolgab merged commit 283e145 into main May 30, 2024
2 checks passed
@lolgab lolgab deleted the lefou/java-support branch May 30, 2024 10:05
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.

Support JavaModules
2 participants