-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at first-class support for Java projects (#3261)
Most of the functionality necessary to support Java projects is already there, what's missing is a proper documentation and onboarding experience. This PR aims to make a first pass at writing that and setting up the supporting tooling necessary to do so. A Java programmer should be able to land on `Introduction to Mill for Java`, read through it, and competently make use of Mill for their Java project even without significant Scala expertise. * Since the Scala and Java modules are pretty tied together via Zinc, for now I decided to avoid trying to split out a proper `javalib` module and left everything in place inside `scalalib`. Instead, I defined a `package object javalib` with a bunch of aliases pointing at the various `scalalib` functionality; this should give us the UX benefits of letting users `import javalib._`, without needing to invasively refactor the codebase. There's some tradeoff with `scalalib` still appearing in stack traces etc., but for a first pass I think that's fine. * I added a new set of `example/basicjava/`, `javamodule`, and `javabuilds`. * These are duplicates of `example/basic/`, `scalamodule`, and `scalabuilds`, but for Java. I implemented a janky DIY `build`.sc templating/extension system, to allow me to share the bulk of the ascidoc between the Scala/Java versions while only specifying the differences: generally the build.sc Scala logic needs to be adapted, but the asciidoc text and the Usage command-blocks can mostly be re-used. * All of the Java versions of the examples have had their Scala code ported to Java. This includes third party libraries, e.g. replacing MainArgs with ArgParse4j, Scalatags with `escapeHtml4` from apache commons text. Most of the `Usage` command-blocks testing the builds are shared between the Java and Scala versions of each example, although some had to be generalized a bit, and a handful only apply to a single language * The word "*Scala*" does not appear anywhere in the new documentation pages. In general, a Java programmer should be comfortable running through the docs, learning to use Mill, all without being scared off by it being a "Scala" build tool * Moved the docs for the `example/thirdparty/jimfs/` folder to the new *Java Build Examples* section, and added a new `example/thirdparty/commons-io/` folder to also include in those docs With this PR, the docs have roughly the following sections: * Scala Quick Start: Scala Specific * Java Quick Start: Java Specific * Mill in Depth, Mill Plugins, Reference: Language Agnostic In future, if we include Kotlin support, we can have a `Kotlin Quick Start` section next to that of the other two languages. It should be pretty easy (O(days)) to duplicate all the work I did for Java for Kotlin. Doc changes can be reviewed locally via `./mill -i docs.localPages` Pull Request: #3261 --------- Co-authored-by: Tobias Roeser <[email protected]>
- Loading branch information
Showing
162 changed files
with
2,362 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
// Author Notes: | ||
// | ||
// This is the first page a user is expected to land on when learning about | ||
// Mill. It is designed to be a quick, broad overview to get someone started: | ||
// what is Mill, why should they care, and what some simple Mill builds look | ||
// like and how to use them. We intentionally touch shallowly on a lot of | ||
// topics without giving them a proper discussion, since the other pages have | ||
// plenty of space to go in-depth. | ||
// | ||
// By the end of this page, a prospective Mill user should be familiar with | ||
// what Mill is, hopefully have downloaded an example to try out, and be | ||
// interested in learning more about the Mill build tool | ||
|
||
= Introduction to Mill for Java | ||
|
||
include::partial$Intro_to_Mill_Header.adoc[] | ||
|
||
|
||
== Simple Java Module | ||
|
||
include::example/basicjava/1-simple.adoc[] | ||
|
||
== Custom Build Logic | ||
|
||
include::example/basicjava/2-custom-build-logic.adoc[] | ||
|
||
== Multi-Module Project | ||
|
||
include::example/basicjava/3-multi-module.adoc[] | ||
|
||
|
||
|
||
include::partial$Intro_to_Mill_Footer.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Author Notes: | ||
// | ||
// This is the first page a user is expected to land on when learning about | ||
// Mill. It is designed to be a quick, broad overview to get someone started: | ||
// what is Mill, why should they care, and what some simple Mill builds look | ||
// like and how to use them. We intentionally touch shallowly on a lot of | ||
// topics without giving them a proper discussion, since the other pages have | ||
// plenty of space to go in-depth. | ||
// | ||
// By the end of this page, a prospective Mill user should be familiar with | ||
// what Mill is, hopefully have downloaded an example to try out, and be | ||
// interested in learning more about the Mill build tool | ||
|
||
= Introduction to Mill for Scala | ||
|
||
:page-aliases: index.adoc | ||
|
||
include::partial$Intro_to_Mill_Header.adoc[] | ||
|
||
|
||
== Simple Scala Module | ||
|
||
include::example/basic/1-simple.adoc[] | ||
|
||
== Custom Build Logic | ||
|
||
include::example/basic/2-custom-build-logic.adoc[] | ||
|
||
== Multi-Module Project | ||
|
||
include::example/basic/3-multi-module.adoc[] | ||
|
||
|
||
include::partial$Intro_to_Mill_Footer.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
= Java Build Examples | ||
|
||
On this page, we will explore the Mill build tool via a series of simple Java | ||
example projects. Each project demonstrates one particular feature of the Mill | ||
build tool, and is also an executable codebase you can download and run. By the | ||
end of this page, you will be familiar with how to configure Mill to work with | ||
realistic Java codebases: cross-building, testing, and publishing them. | ||
|
||
|
||
Many of the APIs covered here are listed in the API documentation: | ||
|
||
* {mill-doc-url}/api/latest/mill/main/RootModule.html[`mill.scalalib.RootModule`] | ||
* {mill-doc-url}/api/latest/mill/scalalib/TestModule$.html[`mill.scalalib.TestModule`] | ||
* {mill-doc-url}/api/latest/mill/scalalib/PublishModule.html[`mill.scalalib.PublishModule`] | ||
* {mill-doc-url}/api/latest/mill/scalalib/CrossScalaModule.html[`mill.scalalib.CrossScalaModule`] | ||
* {mill-doc-url}/api/latest/mill/scalalib/MavenModule.html[`mill.scalalib.MavenModule`] | ||
* {mill-doc-url}/api/latest/mill/scalalib/CrossSbtModule.html[`mill.scalalib.CrossSbtModule`] | ||
* {mill-doc-url}/api/latest/mill/scalalib/JavaModule.html[`mill.scalalib.JavaModule`] | ||
== Common Configuration Overrides | ||
|
||
include::example/javabuilds/1-common-config.adoc[] | ||
|
||
== Custom Tasks | ||
|
||
include::example/javabuilds/2-custom-tasks.adoc[] | ||
|
||
== Overriding Tasks | ||
|
||
include::example/javabuilds/3-override-tasks.adoc[] | ||
|
||
== Nesting Modules | ||
|
||
include::example/javabuilds/4-nested-modules.adoc[] | ||
|
||
== Java Module With Test Suite | ||
|
||
include::example/javabuilds/5-test-suite.adoc[] | ||
|
||
== Publish Module | ||
|
||
include::example/javabuilds/6-publish-module.adoc[] | ||
|
||
|
||
== Maven-Compatible Modules | ||
|
||
include::example/javabuilds/8-compat-modules.adoc[] | ||
|
||
|
||
== Realistic Java Example Project | ||
|
||
include::example/javabuilds/9-realistic.adoc[] | ||
|
||
|
||
== Example Builds for Real Projects | ||
|
||
Mill comes bundled with example builds for real-world open-source projects, | ||
demonstrating how Mill can be used to build code outside of tiny example codebases: | ||
|
||
=== JimFS | ||
|
||
include::example/thirdparty/jimfs.adoc[] | ||
|
||
=== Apache Commons IO | ||
|
||
include::example/thirdparty/commons-io.adoc[] | ||
|
||
== Real World Mill Builds | ||
|
||
=== C3P0 | ||
|
||
https://github.com/swaldman/c3p0[C3P0] is a JDBC connection pooling library | ||
written in Java, built using the Mill build tool. |
Oops, something went wrong.