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 a Netty example build.sc and write about it #3326

Merged
merged 16 commits into from
Aug 3, 2024

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Jul 31, 2024

No description provided.

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.

Great case study.

Comment on lines 39 to 41
$ time ./mvnw -DskipTests -Dcheckstyle.skip -Denforcer.skip=true clean install

$ time ./mill clean __.compile
Copy link
Member

@lefou lefou Jul 31, 2024

Choose a reason for hiding this comment

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

I think these are not fair comparisions. We either also run jar in Mill or we don't install in Maven.

Suggested change
$ time ./mvnw -DskipTests -Dcheckstyle.skip -Denforcer.skip=true clean install
$ time ./mill clean __.compile
$ time ./mvnw -DskipTests -Dcheckstyle.skip -Denforcer.skip=true clean compile testCompile
$ time ./mill clean __.compile

Running just compile sometimes works in a Maven reactor build, sometimes not. Need to check.

Alternatively, we need to run jar in Mill.

Suggested change
$ time ./mvnw -DskipTests -Dcheckstyle.skip -Denforcer.skip=true clean install
$ time ./mill clean __.compile
$ time ./mvnw -DskipTests -Dcheckstyle.skip -Denforcer.skip=true clean install
$ time ./mill clean __.jar

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is, in Mill the common workflow is running compile, while in Maven the equivalent workflow is running install. AFAICT, this is because Maven uses ~/.m2/local for passing dependencies between subprojects, while Mill doesn't.

Part of the reason Mill is faster is because it does less work, but I don't think that makes the comparison unfair. In the end, nobody runs compile in Maven or jar in Mill. mvn install and mill compile are equivalent user workflows

docs/modules/ROOT/pages/Java_Case_Study.adoc Outdated Show resolved Hide resolved
In general, the Mill snippet contains all the same information as the Maven snippet: the name
of the module and its dependency on `common`. Much of the other information in the Maven XML
is inherited from the `trait NettyModule` we defined earlier in the file, where it can be
shared with the rest of the modules rather than being duplicated for each one. This means
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
shared with the rest of the modules rather than being duplicated for each one. This means
shared with the rest of the modules rather than being duplicated for each one.


While Mill cannot make the complexity of your build disappear, what it can do is give you
the tools necessary to manage it. In this case, it means the JNI-related logic can be defined
once and re-used, rather than duplicating it as is often done in Maven `pom.xml`s.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
once and re-used, rather than duplicating it as is often done in Maven `pom.xml`s.
once and re-used, rather than duplicating it as is often done in Maven ``pom.xml``s.

Comment on lines 253 to 260
val context = new java.util.HashMap[String, Object]

context.put("collection.template.dir", "common/src/main/templates")
context.put("collection.template.test.dir", "common/src/test/templates")
context.put("collection.src.dir", (T.dest / "src").toString)
context.put("collection.testsrc.dir", (T.dest / "testsrc").toString)

shell.setProperty("properties", context)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
val context = new java.util.HashMap[String, Object]
context.put("collection.template.dir", "common/src/main/templates")
context.put("collection.template.test.dir", "common/src/test/templates")
context.put("collection.src.dir", (T.dest / "src").toString)
context.put("collection.testsrc.dir", (T.dest / "testsrc").toString)
shell.setProperty("properties", context)
val context = Map[String, Object](
"collection.template.dir" -> "common/src/main/templates",
"collection.template.test.dir" -> "common/src/test/templates",
"collection.src.dir" -> (T.dest / "src").toString,
"collection.testsrc.dir" -> (T.dest / "testsrc").toString
)
import scala.jdk.CollectionConverters._
shell.setProperty("properties", context.asJava)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to leave this as is, since we're interoping with Java libraries, and this example is meant to be readable to Java programmers. Scala is more idiomatic Mill, but staying in java.util.HashMap-land will be much more familiar and less scary

Copy link
Member

Choose a reason for hiding this comment

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

I almost expected this answer as I had the same thought. ;)

@@ -16,46 +16,334 @@ To do this, we have written a Mill `build.sc` file for the Netty project. This c
with Mill to build and test the various submodules of the Netty project without needing to
change any other files in the repository:

- ???[Netty `build.sc` file]
- https://github.com/com-lihaoyi/mill/blob/main/example/thirdparty/netty/build.sc[Netty `build.sc` file]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- https://github.com/com-lihaoyi/mill/blob/main/example/thirdparty/netty/build.sc[Netty `build.sc` file]
- {mill-github-url}/blob/main/example/thirdparty/netty/build.sc[Netty `build.sc` file]

@lihaoyi lihaoyi merged commit 5aa41b9 into com-lihaoyi:main Aug 3, 2024
39 checks passed
@lefou lefou changed the title [WIP] Add a Netty example build.sc and write about it Add a Netty example build.sc and write about it Aug 4, 2024
@lefou lefou modified the milestones: 0.11.12, 0.11.11 Aug 4, 2024
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.

2 participants