From c0fa03259c5d7954e0bdd095c121aa6ab3d5317e Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Tue, 2 Aug 2022 17:32:55 +0200 Subject: [PATCH 1/8] feat: add support for the Mill build tool This PR adds in support for the Mill build tool by utilizing https://github.com/ckipp01/mill-scip. It's a pretty thin wrapper. You can find more details about mill-scip in the repo but the general workflow is: - It's an external Mill plugin that gathers everything needed to do a compile via Mill, but then adds some extra plugins/scalacOptions to ensure semanticDB gets produced - Once produced it uses `scip-java` as a library to actually produce the scip file. The plugin isn't actually a dependency here which ensures we don't have any cyclical dependency on anything, but rather just utilizes the `--import` functionality of Mill and external plugins. I'll leave a couple more comments on various parts of the PR. _NOTE_ This only currently supports Scala and Scala 3 projects. There are some issues with Java projects which will need some upstream work. You can track that in https://github.com/com-lihaoyi/mill/issues/1983. Refs #306 --- build.sbt | 6 +- docs/getting-started.md | 14 ++- .../scip_java/buildtools/BuildTool.scala | 3 +- .../scip_java/buildtools/MillBuildTool.scala | 103 ++++++++++++++++++ .../test/scala/tests/MillBuildToolSuite.scala | 32 ++++++ 5 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala create mode 100644 tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala diff --git a/build.sbt b/build.sbt index 238a2ccc..74b01d9a 100644 --- a/build.sbt +++ b/build.sbt @@ -22,6 +22,8 @@ lazy val V = def semanticdbKotlinc = "0.2.0" def testcontainers = "0.39.3" def requests = "0.6.5" + def minimalMillVersion = "0.10.3" + def millScipVersion = "0.2.2" } inThisBuild( @@ -166,7 +168,9 @@ lazy val cli = project "scala213" -> V.scala213, "scala3" -> V.scala3, "bloopVersion" -> V.bloop, - "bspVersion" -> V.bsp + "bspVersion" -> V.bsp, + "minimalMillVersion" -> V.minimalMillVersion, + "millScipVersion" -> V.millScipVersion ), buildInfoPackage := "com.sourcegraph.scip_java", libraryDependencies ++= diff --git a/docs/getting-started.md b/docs/getting-started.md index 9e09fd13..42f47717 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -243,7 +243,7 @@ free to subscribe to the tracking issues to receive updates on your build tool. | Ant | ❌ | ❌ | ❌ | [sourcegraph/scip-java#305](https://github.com/sourcegraph/scip-java/issues/305) | | Bazel | ✅ | ✅ | ❌ | | | Buck | ❌ | ❌ | ❌ | [sourcegraph/scip-java#99](https://github.com/sourcegraph/scip-java/issues/99) | -| Mill | ❌ | ❌ | ❌ | [sourcegraph/scip-java#306](https://github.com/sourcegraph/scip-java/issues/306) | +| Mill | ❌ | ✅ | ❌ | **✅**: automatic indexing is fully supported. Please report a bug if the `scip-java index` command does not work on your codebase. @@ -292,13 +292,23 @@ The following Maven integrations are not yet supported: ### sbt -The `scip-java index` build should be able to automatically index most Maven +The `scip-java index` build should be able to automatically index most sbt projects, with the following caveats: | Integration | Supported | Recommendation | | ------------- | --------- | ----------------------- | | sbt = v0.10.3 | + + ### Bazel Bazel is supported by scip-java but it requires custom configuration to work diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala index da3f5206..335f284c 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala @@ -24,7 +24,8 @@ object BuildTool { new GradleBuildTool(index), new MavenBuildTool(index), new ScipBuildTool(index), - new SbtBuildTool(index) + new SbtBuildTool(index), + new MillBuildTool(index) ) def allNames: String = all(IndexCommand()).filterNot(_.isHidden).map(_.name).mkString(", ") diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala new file mode 100644 index 00000000..fa0988a7 --- /dev/null +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala @@ -0,0 +1,103 @@ +package com.sourcegraph.scip_java.buildtools + +import java.nio.file.Files +import java.nio.file.StandardCopyOption + +import scala.jdk.CollectionConverters._ + +import com.sourcegraph.scip_java.commands.IndexCommand +import com.sourcegraph.scip_java.BuildInfo + +class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) { + + override def usedInCurrentDirectory(): Boolean = + Files.isRegularFile(index.workingDirectory.resolve("build.sc")) + + override def generateScip(): Int = + millVersion() match { + case Some(version) if isSupportedMillVersion(version) => + unconditionallyGenerateScip() + case Some(version) => + failFast( + s"Unsupported Mill version '${version}'. " + + s"To fix this problem, upgrade Mill to at least ${minimalMillVersion} and try again." + ) + case None => + failFast( + s"No Mill version detected. " + + s"To fix this problem, run the following command and try again: " + + s"echo '${minimalMillVersion}' >> .mill-version" + ) + } + + private def failFast(message: String): Int = { + index.app.error(message) + 1 + } + + private def unconditionallyGenerateScip(): Int = { + val localMill = Files.isRegularFile(millFile) + val command = + if (localMill) { + "./mill" + } else { + "mill" + } + val millProcess = index.process( + List( + command, + "--import", + s"ivy:io.chris-kipp::mill-scip::${BuildInfo.millScipVersion}", + "io.kipp.mill.scip.Scip/generate" + ) + ) + val scipFile = index + .workingDirectory + .resolve("out") + .resolve("io") + .resolve("kipp") + .resolve("mill") + .resolve("scip") + .resolve("Scip") + .resolve("generate.dest") + .resolve("index.scip") + + if (millProcess.exitCode == 0 && Files.isRegularFile(scipFile)) { + val output = index.workingDirectory.resolve("index.scip") + Files.copy(scipFile, output, StandardCopyOption.REPLACE_EXISTING) + index.app.info(output.toString) + } + millProcess.exitCode + } + + private lazy val minimalMillVersion = BuildInfo.minimalMillVersion + + private lazy val millFile = index.workingDirectory.resolve("mill") + + private def isSupportedMillVersion(version: String): Boolean = + if (version.startsWith("0.1")) + true + else + false + + /** + * Try to grab the Mill version from the .mill-version file. If not found we + * fall back to the mill file which could be the official mill launcher or the + * millw launcher renamed as mill, both which will have a DEFAULT_MILL_VERSION + * line. + */ + private def millVersion(): Option[String] = { + val millVersionFile = index.workingDirectory.resolve(".mill-version") + if (Files.isRegularFile(millVersionFile)) { + Files.readAllLines(millVersionFile).asScala.headOption + } else if (Files.isRegularFile(millFile)) { + Files + .readAllLines(millFile) + .asScala + .find(_.startsWith("DEFAULT_MILL_VERSION")) + .map(line => line.dropWhile(!_.isDigit)) + } else { + None + } + } +} diff --git a/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala b/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala new file mode 100644 index 00000000..44bcac4f --- /dev/null +++ b/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala @@ -0,0 +1,32 @@ +package tests + +class MillBuildToolSuite extends BaseBuildToolSuite { + checkBuild( + s"minimal", + s"""|/.mill-version + |0.10.5 + |/build.sc + |import mill._, scalalib._ + |object minimal extends ScalaModule { + | def scalaVersion = "2.13.8" + | object test extends Tests with TestModule.Munit { + | def ivyDeps = Agg(ivy"org.scalameta::munit:1.0.0-M6") + | } + |} + |/minimal/src/Main.scala + |package minimal + |object Main extends App + |/minimal/test/src/MainSuite.scala + |package minimal + |class MainSpec extends munit.FunSuite { + | test("numbers") { + | assertEquals(1, 1) + | } + |} + |""".stripMargin, + expectedSemanticdbFiles = 2, + expectedPackages = + """|maven:munit:munit:1.0.0-M6 + |""".stripMargin + ) +} From fe2c71c8a131a025c1c9bbc1519509e05dd74897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Tue, 16 Aug 2022 10:03:38 +0200 Subject: [PATCH 2/8] Use millFile instead of ./mill --- .../com/sourcegraph/scip_java/buildtools/MillBuildTool.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala index fa0988a7..f5df2026 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala @@ -39,7 +39,7 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) { val localMill = Files.isRegularFile(millFile) val command = if (localMill) { - "./mill" + millFile.toString() } else { "mill" } From 870685d253b38c651c4fb62221bffd3db248efc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Tue, 16 Aug 2022 10:11:45 +0200 Subject: [PATCH 3/8] Fix import ordering --- .../com/sourcegraph/scip_java/buildtools/MillBuildTool.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala index f5df2026..19234a50 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala @@ -5,8 +5,8 @@ import java.nio.file.StandardCopyOption import scala.jdk.CollectionConverters._ -import com.sourcegraph.scip_java.commands.IndexCommand import com.sourcegraph.scip_java.BuildInfo +import com.sourcegraph.scip_java.commands.IndexCommand class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) { From 60daded3930d39e0268546cccf33496949358e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Tue, 16 Aug 2022 10:14:57 +0200 Subject: [PATCH 4/8] Fix MissingBuildToolSuite --- .../buildTools/src/test/scala/tests/MissingBuildToolSuite.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/buildTools/src/test/scala/tests/MissingBuildToolSuite.scala b/tests/buildTools/src/test/scala/tests/MissingBuildToolSuite.scala index 65e81201..ed55b9b3 100644 --- a/tests/buildTools/src/test/scala/tests/MissingBuildToolSuite.scala +++ b/tests/buildTools/src/test/scala/tests/MissingBuildToolSuite.scala @@ -6,7 +6,7 @@ class MissingBuildToolSuite extends BaseBuildToolSuite { "basic", List("index"), expectedOutput = - s"""|error: No build tool detected in workspace '${java.io.File.separator}workingDirectory'. At the moment, the only supported build tools are: Gradle, Maven, sbt. + s"""|error: No build tool detected in workspace '${java.io.File.separator}workingDirectory'. At the moment, the only supported build tools are: Gradle, Maven, sbt, mill. |""".stripMargin, workingDirectoryLayout = "" ) From bee918d095a1b21fd337a71965a3d519a027e3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Tue, 16 Aug 2022 10:15:05 +0200 Subject: [PATCH 5/8] Revert "Use millFile instead of ./mill" This reverts commit fe2c71c8a131a025c1c9bbc1519509e05dd74897. This change was not needed since the working directory of the process is already `index.app.env.workingDirectory` --- .../com/sourcegraph/scip_java/buildtools/MillBuildTool.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala index 19234a50..ce9ea473 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala @@ -39,7 +39,7 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) { val localMill = Files.isRegularFile(millFile) val command = if (localMill) { - millFile.toString() + "./mill" } else { "mill" } From 41171357012c8aac4876b4255b7e31c0d0c225bb Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Tue, 16 Aug 2022 12:40:44 +0200 Subject: [PATCH 6/8] refactor(test): add millw into test resources --- tests/buildTools/src/test/resources/mill | 171 ++++++++++++++++++ .../test/scala/tests/MillBuildToolSuite.scala | 85 ++++++--- 2 files changed, 228 insertions(+), 28 deletions(-) create mode 100644 tests/buildTools/src/test/resources/mill diff --git a/tests/buildTools/src/test/resources/mill b/tests/buildTools/src/test/resources/mill new file mode 100644 index 00000000..62e5e186 --- /dev/null +++ b/tests/buildTools/src/test/resources/mill @@ -0,0 +1,171 @@ +#!/usr/bin/env sh + +# This is a wrapper script, that automatically download mill from GitHub release pages +# You can give the required mill version with --mill-version parameter +# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION +# +# Project page: https://github.com/lefou/millw +# Script Version: 0.4.2 +# +# If you want to improve this script, please also contribute your changes back! +# +# Licensed under the Apache License, Version 2.0 + + +DEFAULT_MILL_VERSION=0.10.0 + +set -e + +MILL_REPO_URL="https://github.com/com-lihaoyi/mill" + +if [ -z "${CURL_CMD}" ] ; then + CURL_CMD=curl +fi + +# Explicit commandline argument takes precedence over all other methods +if [ "$1" = "--mill-version" ] ; then + shift + if [ "x$1" != "x" ] ; then + MILL_VERSION="$1" + shift + else + echo "You specified --mill-version without a version." 1>&2 + echo "Please provide a version that matches one provided on" 1>&2 + echo "${MILL_REPO_URL}/releases" 1>&2 + false + fi +fi + +# Please note, that if a MILL_VERSION is already set in the environment, +# We reuse it's value and skip searching for a value. + +# If not already set, read .mill-version file +if [ -z "${MILL_VERSION}" ] ; then + if [ -f ".mill-version" ] ; then + MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" + fi +fi + +if [ -n "${XDG_CACHE_HOME}" ] ; then + MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download" +else + MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download" +fi + +# If not already set, try to fetch newest from Github +if [ -z "${MILL_VERSION}" ] ; then + # TODO: try to load latest version from release page + echo "No mill version specified." 1>&2 + echo "You should provide a version via '.mill-version' file or --mill-version option." 1>&2 + + mkdir -p "${MILL_DOWNLOAD_PATH}" + LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || ( + # we might be on OSX or BSD which don't have -d option for touch + # but probably a -A [-][[hh]mm]SS + touch "${MILL_DOWNLOAD_PATH}/.expire_latest"; touch -A -010000 "${MILL_DOWNLOAD_PATH}/.expire_latest" + ) || ( + # in case we still failed, we retry the first touch command with the intention + # to show the (previously suppressed) error message + LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" + ) + + # POSIX shell variant of bash's -nt operator, see https://unix.stackexchange.com/a/449744/6993 + # if [ "${MILL_DOWNLOAD_PATH}/.latest" -nt "${MILL_DOWNLOAD_PATH}/.expire_latest" ] ; then + if [ -n "$(find -L "${MILL_DOWNLOAD_PATH}/.latest" -prune -newer "${MILL_DOWNLOAD_PATH}/.expire_latest")" ]; then + # we know a current latest version + MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) + fi + + if [ -z "${MILL_VERSION}" ] ; then + # we don't know a current latest version + echo "Retrieving latest mill version ..." 1>&2 + LANG=C ${CURL_CMD} -s -i -f -I ${MILL_REPO_URL}/releases/latest 2> /dev/null | grep --ignore-case Location: | sed s'/^.*tag\///' | tr -d '\r\n' > "${MILL_DOWNLOAD_PATH}/.latest" + MILL_VERSION=$(head -n 1 "${MILL_DOWNLOAD_PATH}"/.latest 2> /dev/null) + fi + + if [ -z "${MILL_VERSION}" ] ; then + # Last resort + MILL_VERSION="${DEFAULT_MILL_VERSION}" + echo "Falling back to hardcoded mill version ${MILL_VERSION}" 1>&2 + else + echo "Using mill version ${MILL_VERSION}" 1>&2 + fi +fi + +MILL="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}" + +try_to_use_system_mill() { + MILL_IN_PATH="$(command -v mill || true)" + + if [ -z "${MILL_IN_PATH}" ]; then + return + fi + + UNIVERSAL_SCRIPT_MAGIC="@ 2>/dev/null # 2>nul & echo off & goto BOF" + + if ! head -c 128 "${MILL_IN_PATH}" | grep -qF "${UNIVERSAL_SCRIPT_MAGIC}"; then + if [ -n "${MILLW_VERBOSE}" ]; then + echo "Could not determine mill version of ${MILL_IN_PATH}, as it does not start with the universal script magic2" 1>&2 + fi + return + fi + + # Roughly the size of the universal script. + MILL_VERSION_SEARCH_RANGE="2403" + MILL_IN_PATH_VERSION=$(head -c "${MILL_VERSION_SEARCH_RANGE}" "${MILL_IN_PATH}" |\ + sed -n 's/^.*-DMILL_VERSION=\([^\s]*\) .*$/\1/p' |\ + head -n 1) + + if [ -z "${MILL_IN_PATH_VERSION}" ]; then + echo "Could not determine mill version, even though ${MILL_IN_PATH} has the universal script magic" 1>&2 + return + fi + + if [ "${MILL_IN_PATH_VERSION}" = "${MILL_VERSION}" ]; then + MILL="${MILL_IN_PATH}" + fi +} +try_to_use_system_mill + +# If not already downloaded, download it +if [ ! -s "${MILL}" ] ; then + + # support old non-XDG download dir + MILL_OLD_DOWNLOAD_PATH="${HOME}/.mill/download" + OLD_MILL="${MILL_OLD_DOWNLOAD_PATH}/${MILL_VERSION}" + if [ -x "${OLD_MILL}" ] ; then + MILL="${OLD_MILL}" + else + VERSION_PREFIX="$(echo $MILL_VERSION | cut -b -4)" + case $VERSION_PREFIX in + 0.0. | 0.1. | 0.2. | 0.3. | 0.4. ) + DOWNLOAD_SUFFIX="" + ;; + *) + DOWNLOAD_SUFFIX="-assembly" + ;; + esac + unset VERSION_PREFIX + + DOWNLOAD_FILE=$(mktemp mill.XXXXXX) + # TODO: handle command not found + echo "Downloading mill ${MILL_VERSION} from ${MILL_REPO_URL}/releases ..." 1>&2 + MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') + ${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}" + chmod +x "${DOWNLOAD_FILE}" + mkdir -p "${MILL_DOWNLOAD_PATH}" + mv "${DOWNLOAD_FILE}" "${MILL}" + + unset DOWNLOAD_FILE + unset DOWNLOAD_SUFFIX + fi +fi + +unset MILL_DOWNLOAD_PATH +unset MILL_OLD_DOWNLOAD_PATH +unset OLD_MILL +unset MILL_VERSION +unset MILL_VERSION_TAG +unset MILL_REPO_URL + +exec "${MILL}" "$@" diff --git a/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala b/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala index 44bcac4f..f22027b4 100644 --- a/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala +++ b/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala @@ -1,32 +1,61 @@ package tests +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.nio.file.attribute.PosixFilePermission + +import scala.jdk.CollectionConverters._ + class MillBuildToolSuite extends BaseBuildToolSuite { - checkBuild( - s"minimal", - s"""|/.mill-version - |0.10.5 - |/build.sc - |import mill._, scalalib._ - |object minimal extends ScalaModule { - | def scalaVersion = "2.13.8" - | object test extends Tests with TestModule.Munit { - | def ivyDeps = Agg(ivy"org.scalameta::munit:1.0.0-M6") - | } - |} - |/minimal/src/Main.scala - |package minimal - |object Main extends App - |/minimal/test/src/MainSuite.scala - |package minimal - |class MainSpec extends munit.FunSuite { - | test("numbers") { - | assertEquals(1, 1) - | } - |} - |""".stripMargin, - expectedSemanticdbFiles = 2, - expectedPackages = - """|maven:munit:munit:1.0.0-M6 - |""".stripMargin - ) + + def setupMill() = { + val mill = workingDirectory.resolve("mill") + val resource = getClass().getResource("/mill") + val in = Paths.get(resource.toURI) + + Files.createDirectories(mill.getParent) + Files.copy(in, mill, StandardCopyOption.REPLACE_EXISTING) + Files.setPosixFilePermissions( + mill, + Set( + PosixFilePermission.OWNER_READ, + PosixFilePermission.OWNER_WRITE, + PosixFilePermission.OWNER_EXECUTE + ).asJava + ) + List("./mill", "--version") + } + + List("0.10.0").foreach { version => + checkBuild( + s"minimal", + s"""|/.mill-version + |${version} + |/build.sc + |import mill._, scalalib._ + |object minimal extends ScalaModule { + | def scalaVersion = "2.13.8" + | object test extends Tests with TestModule.Munit { + | def ivyDeps = Agg(ivy"org.scalameta::munit:1.0.0-M6") + | } + |} + |/minimal/src/Main.scala + |package minimal + |object Main extends App + |/minimal/test/src/MainSuite.scala + |package minimal + |class MainSpec extends munit.FunSuite { + | test("numbers") { + | assertEquals(1, 1) + | } + |} + |""".stripMargin, + expectedSemanticdbFiles = 2, + expectedPackages = + """|maven:munit:munit:1.0.0-M6 + |""".stripMargin, + initCommand = setupMill() + ) + } } From 2d1ca93c5aeb060a40b241f9459ef571fb51a357 Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Tue, 16 Aug 2022 12:43:41 +0200 Subject: [PATCH 7/8] docs: change minimal mill to 0.10.0 --- build.sbt | 2 +- docs/getting-started.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 74b01d9a..7fefd6d1 100644 --- a/build.sbt +++ b/build.sbt @@ -22,7 +22,7 @@ lazy val V = def semanticdbKotlinc = "0.2.0" def testcontainers = "0.39.3" def requests = "0.6.5" - def minimalMillVersion = "0.10.3" + def minimalMillVersion = "0.10.0" def millScipVersion = "0.2.2" } diff --git a/docs/getting-started.md b/docs/getting-started.md index 42f47717..c6460918 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -306,7 +306,7 @@ projects, with the following caveats: | Integration | Supported | Recommendation | | ------------- | --------- | -------------------------- | -| Mill = v0.10.3 | +| Mill = v0.10.0 | ### Bazel From 156a6dc26811c0167aedc86863500a369acca772 Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Tue, 16 Aug 2022 13:10:28 +0200 Subject: [PATCH 8/8] refactor(test): add in customizable targetRoot --- .../src/test/scala/tests/BaseBuildToolSuite.scala | 6 ++++-- .../src/test/scala/tests/MillBuildToolSuite.scala | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala b/tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala index 490f1bcd..57c0e11f 100644 --- a/tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala +++ b/tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala @@ -57,14 +57,16 @@ abstract class BaseBuildToolSuite extends MopedSuite(ScipJava.app) { extraArguments: List[String] = Nil, expectedError: Option[String => Unit] = None, expectedPackages: String = "", - initCommand: => List[String] = Nil + initCommand: => List[String] = Nil, + targetRoot: Option[String] = None ): Unit = { test(options.withTags(options.tags ++ tags)) { if (initCommand.nonEmpty) { os.proc(Shellable(initCommand)).call(os.Path(workingDirectory)) } FileLayout.fromString(original, root = workingDirectory) - val targetroot = workingDirectory.resolve("targetroot") + val targetroot = workingDirectory + .resolve(targetRoot.getOrElse("targetroot")) val arguments = List[String]( "index", diff --git a/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala b/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala index f22027b4..fa149288 100644 --- a/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala +++ b/tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala @@ -53,9 +53,15 @@ class MillBuildToolSuite extends BaseBuildToolSuite { |""".stripMargin, expectedSemanticdbFiles = 2, expectedPackages = - """|maven:munit:munit:1.0.0-M6 + """|maven:junit:junit:4.13.2 + |maven:org.hamcrest:hamcrest-core:1.3 + |maven:org.scala-lang:scala-library:2.13.8 + |maven:org.scala-sbt:test-interface:1.0 + |maven:org.scalameta:junit-interface:1.0.0-M6 + |maven:org.scalameta:munit_2.13:1.0.0-M6 |""".stripMargin, - initCommand = setupMill() + initCommand = setupMill(), + targetRoot = Some("out/io/kipp/mill/scip/Scip/generate.dest") ) } }