Skip to content

Commit 74834e1

Browse files
authored
Fleshing out docs for config-based modules (#6036)
Adds `Testing`, `Linting`, and `Example Web Project` and sections for Java/Scala/Kotlin. These mostly mirror the top-level pages for each language, and each gives a summary of performing each task with Mill's config-based module definitions while delegating further reading to their respective dedicated pages
1 parent 2285f28 commit 74834e1

File tree

103 files changed

+859
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+859
-827
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ktlint_standard_no-wildcard-imports = disabled
2121
[example/kotlinlib/linting/**/*]
2222
ktlint = disabled
2323

24+
[example/kotlinlib/config/3-linting/**/*]
25+
ktlint = disabled
26+
2427
[kotlinlib/test/resources/contrib/ktfmt/**/*]
2528
ktlint = disabled
2629

.scalafmt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ project {
2626
"glob:**/mill/out/**",
2727
# don't try to format files that are purposefully malformed / misformatted
2828
"glob:**/example/scalalib/linting/1-scalafmt/src/Foo.scala",
29+
"glob:**/example/scalalib/config/3-linting/src/Foo.scala",
2930
"glob:**/example/**/*-spotless*/**",
3031
"glob:**/javalib/test/resources/checkstyle/**",
3132
"glob:**/init/test/resources/giter8/hello.g8/src/main/g8/build.mill",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// SNIPPET:USAGE
2+
/** Usage
3+
4+
> ./mill '{test,integration}' # run both test suites
5+
Test qux.QuxTests#hello() finished...
6+
Test qux.QuxTests#world() finished...
7+
Test qux.QuxIntegrationTests#helloworld() finished...
8+
9+
> ./mill __.integration # run all integration test suites
10+
11+
> ./mill __.test # run all normal test suites
12+
13+
> ./mill __.testForked # run all test suites of any kind
14+
15+
*/
16+
//// SNIPPET:TEST
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extends: [mill.javalib.JavaModule]
2+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extends: [build.JavaTests, mill.javalib.TestModule.Junit5]
2+
mvnDeps: [org.junit.jupiter:junit-jupiter:5.8.2]
3+
moduleDeps: [test]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package qux;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class QuxIntegrationTests {
6+
7+
@Test
8+
public void helloworld() {
9+
String result = Qux.hello();
10+
QuxTests.assertHello(result);
11+
QuxTests.assertWorld(result);
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package qux;
2+
3+
public class Qux {
4+
public static void main(String[] args) {
5+
System.out.println(hello());
6+
}
7+
8+
public static String hello() {
9+
return "Hello World";
10+
}
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extends: [build.JavaTests, mill.javalib.TestModule.Junit5]
2+
mvnDeps: [org.junit.jupiter:junit-jupiter:5.8.2]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package qux;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
public class QuxTests {
8+
9+
public static void assertHello(String result) {
10+
assertTrue(result.startsWith("Hello"));
11+
}
12+
13+
public static void assertWorld(String result) {
14+
assertTrue(result.endsWith("World"));
15+
}
16+
17+
@Test
18+
public void hello() {
19+
String result = Qux.hello();
20+
assertHello(result);
21+
}
22+
23+
@Test
24+
public void world() {
25+
String result = Qux.hello();
26+
assertWorld(result);
27+
}
28+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//// SNIPPET:LINT
2+
// === Autoformatting
3+
//
4+
// To autoformat your Java code with
5+
// https://github.com/palantir/palantir-java-format[Palantir Java Format], you
6+
// can run `./mill mill.javalib.palantirformat/` as shown below:
7+
8+
/** Usage
9+
10+
> cat src/foo/Foo.java
11+
package foo;
12+
public class Foo {
13+
public static void main(String[] args) {
14+
System.out.println("Hello World");
15+
new java.util.HashSet<Short>().remove(1);
16+
}
17+
}
18+
19+
> ./mill mill.javalib.palantirformat/
20+
formatting 1 java sources ...
21+
22+
> cat src/foo/Foo.java
23+
package foo;
24+
public class Foo {
25+
public static void main(String[] args) {
26+
System.out.println("Hello World");
27+
new java.util.HashSet<Short>().remove(1);
28+
}
29+
}
30+
31+
*/
32+
33+
// See xref:javalib/linting.adoc#_autoformatting_with_palantir_java_format[Autoformatting with Palantir Java Format] for more information.
34+
// Apart from Palantir Format, Mill also comes with
35+
// xref:javalib/linting.adoc#_auto_formatting_with_spotless[mill.javalib.spotless.SpotlessModule]
36+
// that can also be used
37+
38+
// === Autofixing
39+
40+
// To lint your code with https://errorprone.info/index[ErrorProne], you can
41+
// make yor module extend `mill.javalib.errorprone.ErrorProneModule`, which will
42+
// run errorprone lint checks every time you `compile` that module.
43+
44+
/** See Also: build.mill.yaml */
45+
/** Usage
46+
47+
> ./mill compile
48+
.../src/foo/Foo.java:6:42: [CollectionIncompatibleType]...
49+
...Argument '1' should not be passed to this method...
50+
...its type int is not compatible with its collection's type argument Short
51+
[warn] (see https://errorprone.info/bugpattern/CollectionIncompatibleType)
52+
[warn] new java.util.HashSet<Short>().remove(1)
53+
[warn] ^
54+
55+
*/
56+
57+
// See xref:javalib/linting.adoc#_linting_with_errorprone[Linting with ErrorProne] for more
58+
// details on how ErrorProne can be configured. Apart from ErrorProne, Mill also comes with
59+
// xref:javalib/linting.adoc#_linting_with_checkstyle[mill.contrib.checkstyle.CheckstyleModule] and
60+
// xref:javalib/linting.adoc#_static_analysis_with_pmd[mill.javalib.pmd.PmdModule]

0 commit comments

Comments
 (0)