Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Oct 4, 2024
1 parent 86606fb commit 2f3ce63
Show file tree
Hide file tree
Showing 30 changed files with 179 additions and 203 deletions.
2 changes: 0 additions & 2 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,6 @@ object dist0 extends MillPublishJavaModule {
build.contrib.jmh.testDep(),
build.contrib.playlib.testDep(),
build.contrib.playlib.worker("2.8").testDep(),
build.contrib.errorprone.testDep(),
build.contrib.checkstyle.testDep(),
build.bsp.worker.testDep(),
build.testkit.testDep()
)
Expand Down
128 changes: 0 additions & 128 deletions contrib/checkstyle/readme.adoc

This file was deleted.

31 changes: 0 additions & 31 deletions contrib/errorprone/readme.adoc

This file was deleted.

14 changes: 0 additions & 14 deletions contrib/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,4 @@ object `package` extends RootModule {
def compileModuleDeps = Seq(build.scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(build.scalalib)
}

object errorprone extends ContribModule with BuildInfo {
def compileModuleDeps = Seq(build.scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(build.scalalib)
def buildInfoPackageName = "mill.contrib.errorprone"
def buildInfoObjectName = "BuildInfo"
def buildInfoMembers =
Seq(BuildInfo.Value("errorProneVersion", Deps.RuntimeDeps.errorProneCore.version))
}

object checkstyle extends ContribModule {
def compileModuleDeps = Seq(build.scalalib)
def testModuleDeps = super.testModuleDeps ++ Seq(build.scalalib)
}
}
36 changes: 32 additions & 4 deletions example/javalib/linting/1-error-prone/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@


package build
import mill._, javalib._
import mill.contrib.errorprone._
import mill._, javalib._, errorprone._

import $ivy.`com.lihaoyi::mill-contrib-errorprone:`

object `package` extends RootModule with JavaModule with ErrorProneModule {
def errorProneOptions = Seq("-XepAllErrorsAsWarnings")
Expand All @@ -29,4 +27,34 @@ object `package` extends RootModule with JavaModule with ErrorProneModule {
[warn] ^
*/

// Find more details on the xref:contrib/errorprone.adoc[ErrorProne plugin page].
// :page-aliases: Plugin_ErrorProne.adoc
//
// https://errorprone.info/index[Error Prone] augments the Java compiler's type checker and detect common mistakes at compile time.
//
// You just need to mix the `ErrorProneModule` into your `JavaModule` and it will automatically run with every compilation.
//
// .`build.mill.scala`: Enable `ErrorProne` in a module
// [source,scala]
// ----
// package build
// import mill._, scalalib._
//
// import $ivy.`com.lihaoyi::mill-contrib-errorprone:`
// import mill.contrib.errorprone.ErrorProneModule
//
// object foo extends JavaModule with ErrorProneModule {
// }
// ----
//
// == Configuration
//
// The following configuration options exist:
//
// `def errorProneVersion: T[String]`::
// The `error-prone` version to use. Defaults to [[BuildInfo.errorProneVersion]], the version used to build and test the module.
// Find the latest at https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core[mvnrepository.com]
//
// `def errorProneOptions: T[Seq[String]]`::
// Options directly given to the `error-prone` processor.
// Those are documented as "flags" at https://errorprone.info/docs/flags
//
132 changes: 127 additions & 5 deletions example/javalib/linting/2-checkstyle/build.mill
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package build
import mill._, javalib._
import $ivy.`com.lihaoyi::mill-contrib-checkstyle:`

import mill.contrib.checkstyle._
import mill._, javalib._, checkstyle._

object `package` extends RootModule with CheckstyleModule {
def checkstyleVersion = "9.3"
Expand Down Expand Up @@ -34,4 +31,129 @@ Audit done.

> ./mill checkstyle # after fixing the violations, checkstyle no longer errors
Audit done.
*/
*/

// Performs quality checks on Java source files using https://checkstyle.org[Checkstyle] and generates reports from these checks.
//
// To use this plugin in a Java/Scala module,
//
// 1. Extend `mill.contrib.checkstyle.CheckstyleModule`.
// 2. Define a https://checkstyle.org/config.html[configuration] file `checkstyle-config.xml`.
// 3. Run the `checkstyle` command.
//
// === checkstyle
//
// - flags
// [source,sh]
// ----
//
// // if an exception should be raised when violations are found
// checkstyle --check
//
// // if Checkstyle output report should be written to System.out
// checkstyle --stdout
// ----
//
// - sources (optional)
// [source,sh]
// ----
// // incorrect paths will cause a command failure
// // checkstyle a/b
//
// // you can specify paths relative to millSourcePath
// checkstyle src/a/b
//
// // process a single file
// checkstyle src/a/B.java
//
// // process multiple sources
// checkstyle src/a/b src/c/d src/e/F.java
//
// // process with flags
// checkstyle --check --stdout src/a/b src/c/d
//
// // process all module sources
// checkstyle
// ----
//
// === Shared configuration
//
// To share `checkstyle-config.xml` across modules, adapt the following example.
// [source,scala]
// ----
// import mill._
// import mill.contrib.checkstyle.CheckstyleModule
// import mill.scalalib._
//
// object foo extends Module {
//
// object bar extends MyModule
// object baz extends Module {
// object fizz extends MyModule
// object buzz extends MyModule
// }
//
// trait MyModule extends JavaModule with CheckstyleModule {
//
// override def checkstyleConfig = Task {
// api.PathRef(T.workspace / "checkstyle-config.xml")
// }
// }
// }
// ----
//
//
// === Limitations
//
// - Version `6.3` or above is required for `plain` and `xml` formats.
// - Setting `checkstyleOptions` might cause failures with legacy versions.
//
// == CheckstyleXsltModule
//
// This plugin extends the `mill.contrib.checkstyle.CheckstyleModule` with the ability to generate reports by applying https://www.w3.org/TR/xslt/[XSL Transformations] on a Checkstyle output report.
//
// === Auto detect XSL Transformations
//
// XSLT files are detected automatically provided a prescribed directory structure is followed.
// [source,scala]
// ----
// /**
// * checkstyle-xslt
// * ├─ html
// * │ ├─ xslt0.xml
// * │ └─ xslt1.xml
// * └─ pdf
// * ├─ xslt1.xml
// * └─ xslt2.xml
// *
// * html/xslt0.xml -> xslt0.html
// * html/xslt1.xml -> xslt1.html
// * pdf/xslt1.xml -> xslt1.pdf
// * pdf/xslt2.xml -> xslt2.pdf
// */
// ----
//
// === Specify XSL Transformations manually
//
// For a custom setup, adapt the following example.
// [source,scala]
// ----
// import mill._
// import mill.api.PathRef
// import mill.contrib.checkstyle.CheckstyleXsltModule
// import mill.contrib.checkstyle.CheckstyleXsltReport
// import mill.scalalib._
//
// object foo extends JavaModule with CheckstyleXsltModule {
//
// override def checkstyleXsltReports = Task {
// Set(
// CheckstyleXsltReport(
// PathRef(millSourcePath / "checkstyle-no-frames.xml"),
// PathRef(T.dest / "checkstyle-no-frames.html"),
// )
// )
// }
// }
// ----
//
3 changes: 2 additions & 1 deletion scalalib/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ object `package` extends RootModule with build.MillStableScalaModule {
s"${d.dep.module.organization.value}:${d.dep.module.name.value}:${d.version}"
},
"Dependency to jupiter-interface"
)
),
BuildInfo.Value("errorProneVersion", build.Deps.RuntimeDeps.errorProneCore.version)
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mill.contrib.checkstyle
package mill.javalib.checkstyle

import mainargs.{Leftover, ParserForClass, main}

Expand Down
Loading

0 comments on commit 2f3ce63

Please sign in to comment.