Skip to content

Commit

Permalink
Merge branch 'main' into fix-windows-SubprocessStdoutTests
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou committed Jul 24, 2024
2 parents 66cb8f2 + c74a3fa commit 2b55884
Show file tree
Hide file tree
Showing 86 changed files with 251 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .config/mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.7-17-17dea9
0.11.8
5 changes: 4 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,8 @@ object docs extends Module {
| title: Mill
| url: ${if (authorMode) s"${T.dest}/site" else Settings.docUrl}
| start_page: mill::Intro_to_Mill_for_Scala.adoc
| keys:
| google_analytics: 'G-1C582ZJR85'
|
|content:
| sources:
Expand Down Expand Up @@ -1783,7 +1785,7 @@ object docs extends Module {
| mill-github-url: ${Settings.projectUrl}
| mill-doc-url: ${if (authorMode) s"file://${T.dest}/site" else Settings.docUrl}
| mill-download-url: ${if (authorMode) s"file://${exampleZips().head.path / os.up}"
else s"${Settings.projectUrl}/releases/download/0.11.10"}
else s"${Settings.projectUrl}/releases/download/${millLastTag()}"}
| mill-example-url: ${if (authorMode) s"file://${T.workspace}"
else s"${Settings.projectUrl}/blob/main/"}
| utest-github-url: https://github.com/com-lihaoyi/utest
Expand Down Expand Up @@ -1966,6 +1968,7 @@ def exampleZips: T[Seq[PathRef]] = T {
val example = examplePath.subRelativeTo(T.workspace)
val exampleStr = millVersion() + "-" + example.segments.mkString("-")
os.copy(examplePath, T.dest / exampleStr, createFolders = true)
os.write(T.dest / exampleStr / ".mill-version", millLastTag())
os.copy(bootstrapLauncher().path, T.dest / exampleStr / "mill")
val zip = T.dest / s"$exampleStr.zip"
os.proc("zip", "-r", zip, exampleStr).call(cwd = T.dest)
Expand Down
14 changes: 0 additions & 14 deletions docs/modules/ROOT/pages/Intro_to_Mill_for_Scala.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@

:page-aliases: index.adoc, Intro_to_Mill.adoc


{mill-github-url}[Mill] is your shiny new Scala build tool! Mill aims for
simplicity by reusing concepts you are already familiar with, borrowing ideas
from modern tools like https://maven.apache.org/[Maven], https://gradle.org/[Gradle],
https://bazel.build/[Bazel] and https://www.scala-sbt.org/[SBT]. It lets you build
your projects in a way that's simple, fast, and predictable.


{mill-github-url}[Mill] is your shiny new Scala build tool! Mill aims for
simplicity by reusing concepts you are already familiar with, borrowing ideas
from modern tools like https://maven.apache.org/[Maven], https://gradle.org/[Gradle],
Expand All @@ -45,12 +37,6 @@ how Mill attempts to do better:
- https://www.lihaoyi.com/post/SowhatswrongwithSBT.html[So, what's wrong with SBT?]
- https://www.lihaoyi.com/post/MillBetterScalaBuilds.html[Mill: Better Scala Builds]

If you are using Mill, you will find the following book by the Author useful in
using Mill and its supporting libraries to the fullest:

* https://handsonscala.com/[Hands-on Scala Programming]


If you are using Mill, you will find the following book by the Author useful in
using Mill and its supporting libraries to the fullest:

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/Java_Module_Config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ for `JavaModule`.

Many of the APIs covered here are listed in the API documentation:

* {mill-doc-url}/api/latest/mill/scalalib/JavaModule.html[mill.scalalib.JavaModule]
* {mill-doc-url}/api/latest/mill/scalalib/JavaModule.html[mill.javaalib.JavaModule]
== Compilation & Execution Flags
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/Java_Web_Build_Examples.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Web Build Examples
= Java Web Build Examples

This page contains examples of using Mill as a build tool for web-applications.
It covers setting up a basic backend server with a variety of server frameworks
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/Web_Build_Examples.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Web Build Examples
= Scala Web Build Examples

This page contains examples of using Mill as a build tool for web-applications.
It covers setting up a basic backend server, Todo-MVC app, topics like cache
Expand Down
4 changes: 3 additions & 1 deletion example/basic/2-custom-build-logic/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ Inputs:

// Above, `def lineCount` is a new build target we define, which makes use of
// `allSourceFiles` (an existing target) and is in-turn used in our override of
// `resources` (also an existing target). This generated file can then be
// `resources` (also an existing target). `os.read.lines` and `os.write `come
// from the https://github.com/com-lihaoyi/os-lib[OS-Lib] library, which is
// bundled with Mill. This generated file can then be
// loaded and used at runtime, as see in the output of `mill run`
//
// While this is a toy example, it shows how easy it is to customize your Mill
Expand Down
2 changes: 1 addition & 1 deletion example/basic/4-builtin-commands/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Inputs:
> mill show foo.allSourceFiles
[
".../foo/src/Foo..."
".../foo/src.../Foo..."
]
*/
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions example/basicjava/3-multi-module/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ object bar extends MyModule{
// build.sc
// foo/
// src/
// Foo.java
// foo/
// Foo.java
// resources/
// ...
// bar/
// src/
// Bar.java
// bar/
// Bar.java
// resources/
// ...
// out/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

public class Bar {
public static void main(String[] args) {
System.out.println(hello());
System.out.println(new Bar().hello());
}

public static String hello() {
public String hello() {
return "Hello World";
}
}
19 changes: 0 additions & 19 deletions example/javabuilds/5-test-suite/bar/test/src/BarTests.java

This file was deleted.

32 changes: 32 additions & 0 deletions example/javabuilds/5-test-suite/bar/test/src/bar/BarTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package bar;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
import org.junit.Test;

public class BarTests {

@Test
public void hello() {
String result = new Bar().hello();
assertTrue(result.startsWith("Hello"));
}

@Test
public void world() {
String result = new Bar().hello();
assertTrue(result.endsWith("World"));
}

@Test
public void testMockito() {
Bar mockBar = mock(Bar.class);

when(mockBar.hello()).thenReturn("Hello Mockito World");

String result = mockBar.hello();

assertTrue(result.equals("Hello Mockito World"));
verify(mockBar).hello();
}
}
24 changes: 17 additions & 7 deletions example/javabuilds/5-test-suite/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@ import mill._, javalib._
object foo extends JavaModule {
object test extends JavaTests {
def testFramework = "com.novocode.junit.JUnitFramework"
def ivyDeps = T {
super.ivyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11")
}
def ivyDeps = Agg(
ivy"com.novocode:junit-interface:0.11",
ivy"org.mockito:mockito-core:4.6.1"
)
}
}

// This build defines a single module with a test suite, configured to use
// "JUnit" as the testing framework, along with Mockito. Test suites are themselves
// ``JavaModule``s, nested within the enclosing module,
//// SNIPPET:BUILD2

object bar extends JavaModule {
object test extends JavaTests with TestModule.Junit4
object test extends JavaTests with TestModule.Junit4{
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.mockito:mockito-core:4.6.1"
)
}
}

//// SNIPPET:BUILD3
object qux extends JavaModule {
object test extends JavaTests with TestModule.Junit4
object integration extends JavaTests with TestModule.Junit4
object test extends JavaTests with TestModule.Junit5
object integration extends JavaTests with TestModule.Junit5
}

// This example also demonstrates using Junit 5 instead of Junit 4,
// with
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

public class Foo {
public static void main(String[] args) {
System.out.println(hello());
System.out.println(new Foo().hello());
}

public static String hello() {
public String hello() {
return "Hello World";
}
}
19 changes: 0 additions & 19 deletions example/javabuilds/5-test-suite/foo/test/src/FooTests.java

This file was deleted.

32 changes: 32 additions & 0 deletions example/javabuilds/5-test-suite/foo/test/src/foo/FooTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package foo;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
import org.junit.Test;

public class FooTests {

@Test
public void hello() {
String result = new Foo().hello();
assertTrue(result.startsWith("Hello"));
}

@Test
public void world() {
String result = new Foo().hello();
assertTrue(result.endsWith("World"));
}

@Test
public void testMockito() {
Foo mockFoo = mock(Foo.class);

when(mockFoo.hello()).thenReturn("Hello Mockito World");

String result = mockFoo.hello();

assertTrue(result.equals("Hello Mockito World"));
verify(mockFoo).hello();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package qux;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

public class QuxIntegrationTests {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package qux;

import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

public class QuxTests {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package baz;

import org.junit.Test;
import com.google.common.math.IntMath;

import static org.junit.Assert.*;

public class BazTests {

@Test
public void simple() {
BazTestUtils.bazAssertEquals(Baz.getValue(), 123);
BazTestUtils.bazAssertEquals(Baz.getValue(), IntMath.mean(122, 124));
}
}
5 changes: 4 additions & 1 deletion example/javamodule/4-test-deps/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ object qux extends JavaModule {

object test extends JavaTests with TestModule.Junit4 {
def moduleDeps = super.moduleDeps ++ Seq(baz.test)
def ivyDeps = super.ivyDeps() ++ Agg(ivy"com.google.guava:guava:33.2.1-jre")
}
}


object baz extends JavaModule {
object test extends JavaTests with TestModule.Junit4
object test extends JavaTests with TestModule.Junit4{
def ivyDeps = super.ivyDeps() ++ Agg(ivy"com.google.guava:guava:33.2.1-jre")
}
}
11 changes: 0 additions & 11 deletions example/javamodule/4-test-deps/qux/test/src/QuxTests.java

This file was deleted.

12 changes: 12 additions & 0 deletions example/javamodule/4-test-deps/qux/test/src/qux/QuxTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package qux;

import org.junit.Test;
import com.google.common.base.Ascii;

public class QuxTests {

@Test
public void simple() {
baz.BazTestUtils.bazAssertEquals(Ascii.toLowerCase("XYZ"), Qux.getValue());
}
}
2 changes: 1 addition & 1 deletion example/javaweb/1-hello-jetty/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object hello extends RootModule with JavaModule {
ivy"javax.servlet:javax.servlet-api:4.0.1"
)

object test extends JavaModuleTests with TestModule.Junit4
object test extends JavaTests with TestModule.Junit4
}

// This example demonstrates how to set up a simple Jetty webserver,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.example;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.example;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.HandlerList;
Expand Down
2 changes: 1 addition & 1 deletion example/javaweb/2-hello-spring-boot/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object hello extends RootModule with JavaModule {
ivy"org.springframework.boot:spring-boot-starter-actuator:2.5.6"
)

object test extends JavaModuleTests with TestModule.Junit5 {
object test extends JavaTests with TestModule.Junit5 {
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.springframework.boot:spring-boot-starter-test:2.5.6"
)
Expand Down
Loading

0 comments on commit 2b55884

Please sign in to comment.