From b8a857537e7577f322342e90d6d63593e757c92b Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 16 May 2024 08:51:38 +0200 Subject: [PATCH 1/6] Some cleanup --- idea/src/mill/idea/GenIdea.scala | 2 +- idea/src/mill/idea/GenIdeaImpl.scala | 2 +- scalajslib/src/mill/scalajslib/ScalaJSModule.scala | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/idea/src/mill/idea/GenIdea.scala b/idea/src/mill/idea/GenIdea.scala index ec961a399b5..f3f70d990b1 100644 --- a/idea/src/mill/idea/GenIdea.scala +++ b/idea/src/mill/idea/GenIdea.scala @@ -12,7 +12,7 @@ object GenIdea extends ExternalModule { def idea(allBootstrapEvaluators: Evaluator.AllBootstrapEvaluators): Command[Unit] = T.command { try { Result.Success(GenIdeaImpl( - evaluators = Evaluator.allBootstrapEvaluators.value.value + evaluators = allBootstrapEvaluators.value ).run()) } catch { case GenIdeaImpl.GenIdeaException(m) => Result.Failure(m) diff --git a/idea/src/mill/idea/GenIdeaImpl.scala b/idea/src/mill/idea/GenIdeaImpl.scala index 1523f83dd87..e8a27a1d15f 100755 --- a/idea/src/mill/idea/GenIdeaImpl.scala +++ b/idea/src/mill/idea/GenIdeaImpl.scala @@ -258,7 +258,7 @@ case class GenIdeaImpl( val librariesProperties: Map[Path, Agg[Path]] = resolvedModules - .flatMap(x => x.libraryClasspath.map(_ -> x.compilerClasspath)) + .flatMap(rm => rm.libraryClasspath.map(_ -> rm.compilerClasspath)) .toMap val (wholeFileConfigs, configFileContributions) = diff --git a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala index 768c617e246..f609c3d110e 100644 --- a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala +++ b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala @@ -17,8 +17,6 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => def scalaJSVersion: T[String] - @deprecated("use ScalaJSTests", "0.11.0") - type ScalaJSModuleTests = ScalaJSTests trait ScalaJSTests extends ScalaTests with TestScalaJSModule { override def scalaJSVersion = outer.scalaJSVersion() override def moduleKind: Target[ModuleKind] = outer.moduleKind() @@ -27,6 +25,10 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => override def jsEnvConfig: Target[JsEnvConfig] = outer.jsEnvConfig() override def scalaJSOptimizer: Target[Boolean] = outer.scalaJSOptimizer() } + @deprecated("use ScalaJSTests", "0.11.0") + type ScalaJSModuleTests = ScalaJSTests + @deprecated("use ScalaJSTests", "0.11.0") + trait Tests extends ScalaJSTests def scalaJSBinaryVersion = T { ZincWorkerUtil.scalaJSBinaryVersion(scalaJSVersion()) } From b317848cdccf779bf4eeb72e2a93152e3319c777 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 16 May 2024 09:41:57 +0200 Subject: [PATCH 2/6] Made GenIdea testsuite more generic --- .../test/src/GenIdeaExtendedTests.scala | 22 ++++--------------- .../gen-idea/test/src/GenIdeaTests.scala | 14 ++++-------- .../gen-idea/test/src/GenIdeaUtils.scala | 20 +++++++++++------ 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/integration/feature/gen-idea/test/src/GenIdeaExtendedTests.scala b/integration/feature/gen-idea/test/src/GenIdeaExtendedTests.scala index 1738c9cbd65..fed9958b93e 100644 --- a/integration/feature/gen-idea/test/src/GenIdeaExtendedTests.scala +++ b/integration/feature/gen-idea/test/src/GenIdeaExtendedTests.scala @@ -10,31 +10,17 @@ object GenIdeaExtendedTests extends IntegrationTestSuite { override def scriptSourcePath: Path = super.scriptSourcePath / "extended" - private val scalaVersionLibPart = "2_13_6" - def tests: Tests = Tests { "genIdeaTests" - { val workspacePath = initWorkspace() + val expectedBase = workspacePath / "idea" + val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase)) + eval("mill.idea.GenIdea/idea") - val checks = Seq( - os.sub / "mill_modules" / "helloworld.iml", - os.sub / "mill_modules" / "helloworld.subscala3.iml", - os.sub / "mill_modules" / "helloworld.test.iml", - os.sub / "mill_modules" / "mill-build.iml", - os.sub / "mill_modules" / "mill-build.mill-build.iml", - os.sub / "libraries" / s"scala_library_${scalaVersionLibPart}_jar.xml", - // NOTE: on IntelliJ Scala Plugin side there is a cosmetic issue: scala suffix is added even for Java libraries (notice `_2_13` suffix) - // In future it might be fixed and `GenIdea` will need to be updated - os.sub / "libraries" / "SBT_ junit_junit_2_13_4_13_2_jar.xml", - os.sub / "libraries" / "SBT_ org_scalameta_munit_2_13_0_7_29_jar.xml", - os.sub / "modules.xml", - os.sub / "misc.xml", - os.sub / "compiler.xml" - ).map { resource => + val checks = resources.map { resource => Try { GenIdeaUtils.assertIdeaXmlResourceMatchesFile( - scriptSlug, workspacePath, resource ) diff --git a/integration/feature/gen-idea/test/src/GenIdeaTests.scala b/integration/feature/gen-idea/test/src/GenIdeaTests.scala index 6d51dbe4781..c93b4c99b6a 100644 --- a/integration/feature/gen-idea/test/src/GenIdeaTests.scala +++ b/integration/feature/gen-idea/test/src/GenIdeaTests.scala @@ -10,7 +10,6 @@ import os.Path object GenIdeaTests extends IntegrationTestSuite { override def scriptSourcePath: Path = super.scriptSourcePath / "hello-world" - private val scalaVersionLibPart = "2_12_5" def tests: Tests = Tests { test("helper assertPartialContentMatches works") { @@ -54,19 +53,14 @@ object GenIdeaTests extends IntegrationTestSuite { test("genIdeaTests") { val workspacePath = initWorkspace() + val expectedBase = workspacePath / "idea" + val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase)) + eval("mill.idea.GenIdea/idea") - val checks = Seq( - os.sub / "mill_modules" / "helloworld.iml", - os.sub / "mill_modules" / "helloworld.test.iml", - os.sub / "mill_modules" / "mill-build.iml", - os.sub / "libraries" / s"scala_library_${scalaVersionLibPart}_jar.xml", - os.sub / "modules.xml", - os.sub / "misc.xml" - ).map { resource => + val checks = resources.map { resource => Try { assertIdeaXmlResourceMatchesFile( - scriptSlug, workspacePath, resource ) diff --git a/integration/feature/gen-idea/test/src/GenIdeaUtils.scala b/integration/feature/gen-idea/test/src/GenIdeaUtils.scala index 8aeddba9f46..b7d5edaea8f 100644 --- a/integration/feature/gen-idea/test/src/GenIdeaUtils.scala +++ b/integration/feature/gen-idea/test/src/GenIdeaUtils.scala @@ -11,20 +11,26 @@ object GenIdeaUtils { * It may contain the `` String, to simulate wildcard-matches. */ def assertIdeaXmlResourceMatchesFile( - workspaceSlug: String, workspacePath: os.Path, - resource: os.RelPath + resource: os.SubPath ): Unit = { val expectedResourcePath = workspacePath / "idea" / resource val actualResourcePath = workspacePath / ".idea" / resource - val expectedResourceString = os.read.lines(expectedResourcePath).mkString("\n") - val actualResourceString = normaliseLibraryPaths(os.read(actualResourcePath), workspacePath) + val check = Try { + val expectedResourceString = os.read.lines(expectedResourcePath).mkString("\n") + val actualResourceString = normaliseLibraryPaths(os.read(actualResourcePath), workspacePath) - assertPartialContentMatches( - found = actualResourceString, - expected = expectedResourceString + assertPartialContentMatches( + found = actualResourceString, + expected = expectedResourceString + ) + } + println( + s"Checking ${expectedResourcePath.relativeTo(workspacePath)} ... ${if (check.isSuccess) "OK" + else "FAILED"}" ) + check.get } def assertPartialContentMatches(found: String, expected: String): Unit = { From fc6f8c1a2a248b934ad9fcdc707c02ac59312a8c Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 16 May 2024 10:26:26 +0200 Subject: [PATCH 3/6] Try to make more IDEA paths relative to user home directory --- idea/src/mill/idea/GenIdeaImpl.scala | 89 ++++++++++++------- .../SBT_ junit_junit_2_13_4_13_2_jar.xml | 4 +- ...T_ org_scalameta_munit_2_13_0_7_29_jar.xml | 4 +- .../libraries/scala_library_2_13_6_jar.xml | 14 +-- .../libraries/scala_library_2_12_5_jar.xml | 12 +-- 5 files changed, 73 insertions(+), 50 deletions(-) diff --git a/idea/src/mill/idea/GenIdeaImpl.scala b/idea/src/mill/idea/GenIdeaImpl.scala index e8a27a1d15f..365a97c712f 100755 --- a/idea/src/mill/idea/GenIdeaImpl.scala +++ b/idea/src/mill/idea/GenIdeaImpl.scala @@ -1,7 +1,7 @@ package mill.idea import scala.collection.immutable -import scala.util.Try +import scala.util.{Success, Try} import scala.xml.{Elem, MetaData, Node, NodeSeq, Null, UnprefixedAttribute} import coursier.core.compatibility.xmlParseDom import coursier.maven.Pom @@ -15,7 +15,6 @@ import mill.scalalib.GenIdeaModule.{IdeaConfigFile, JavaFacet} import mill.scalalib.internal.JavaModuleUtils import mill.util.Classpath import mill.{T, scalalib} -import os.{Path, SubPath} import mill.scalalib.{GenIdeaImpl => _, _} case class GenIdeaImpl( @@ -23,8 +22,8 @@ case class GenIdeaImpl( )(implicit ctx: Ctx) { import GenIdeaImpl._ - val workDir: Path = evaluators.head.rootModule.millSourcePath - val ideaDir: Path = workDir / ".idea" + val workDir: os.Path = evaluators.head.rootModule.millSourcePath + val ideaDir: os.Path = workDir / ".idea" val ideaConfigVersion = 4 @@ -34,7 +33,7 @@ case class GenIdeaImpl( .getOrElse(("JDK_1_8", "1.8 (1)")) ctx.log.info("Analyzing modules ...") - val layout: Seq[(SubPath, Node)] = + val layout: Seq[(os.SubPath, Node)] = xmlFileLayout(evaluators, jdkInfo) ctx.log.debug("Cleaning obsolete IDEA project files ...") @@ -102,7 +101,7 @@ case class GenIdeaImpl( // .toSeq // .distinct - val buildLibraryPaths: immutable.Seq[Path] = { + val buildLibraryPaths: immutable.Seq[os.Path] = { if (!fetchMillModules) Nil else { val moduleRepos = modulesByEvaluator.toSeq.flatMap { case (ev, modules) => @@ -197,7 +196,7 @@ case class GenIdeaImpl( } T.task { - val resolvedCp: Agg[Scoped[Path]] = + val resolvedCp: Agg[Scoped[os.Path]] = externalDependencies().map(_.path).map(Scoped(_, None)) ++ extCompileIvyDeps() .map(_.path) @@ -251,12 +250,12 @@ case class GenIdeaImpl( val moduleLabels = modules.map { case (s, m, e) => (m, s) }.toMap - val allResolved: Seq[Path] = + val allResolved: Seq[os.Path] = (resolvedModules.flatMap(_.classpath).map(_.value) ++ buildLibraryPaths ++ buildDepsPaths) .distinct .sorted - val librariesProperties: Map[Path, Agg[Path]] = + val librariesProperties: Map[os.Path, Agg[os.Path]] = resolvedModules .flatMap(rm => rm.libraryClasspath.map(_ -> rm.compilerClasspath)) .toMap @@ -267,20 +266,20 @@ case class GenIdeaImpl( .partition(_.asWholeFile.isDefined) // whole file - val ideaWholeConfigFiles: Seq[(SubPath, Elem)] = + val ideaWholeConfigFiles: Seq[(os.SubPath, Elem)] = wholeFileConfigs.flatMap(_.asWholeFile).map { wf => os.sub / wf._1 -> ideaConfigElementTemplate(wf._2) } - type FileComponent = (SubPath, Option[String]) + type FileComponent = (os.SubPath, Option[String]) /** Ensure, the additional configs don't collide. */ def collisionFreeExtraConfigs( confs: Seq[IdeaConfigFile] - ): Map[SubPath, Seq[IdeaConfigFile]] = { + ): Map[os.SubPath, Seq[IdeaConfigFile]] = { var seen: Map[FileComponent, Seq[GenIdeaModule.Element]] = Map() - var result: Map[SubPath, Seq[IdeaConfigFile]] = Map() + var result: Map[os.SubPath, Seq[IdeaConfigFile]] = Map() confs.foreach { conf => val key = conf.subPath -> conf.component seen.get(key) match { @@ -307,7 +306,7 @@ case class GenIdeaImpl( result } - val fileComponentContributions: Seq[(SubPath, Elem)] = + val fileComponentContributions: Seq[(os.SubPath, Elem)] = collisionFreeExtraConfigs(configFileContributions).toSeq.map { case (file, configs) => val map: Map[Option[String], Seq[GenIdeaModule.Element]] = @@ -340,7 +339,7 @@ case class GenIdeaImpl( type ArtifactAndVersion = (String, String) def guessJarArtifactNameAndVersionFromPath( - path: Path + path: os.Path ): Option[ArtifactAndVersion] = Try { // in a local maven repo or a local Coursier repo, @@ -444,7 +443,7 @@ case class GenIdeaImpl( r + (key -> (r.getOrElse(key, Vector()) :+ q.module)) } - val fixedFiles: Seq[(SubPath, Elem)] = Seq( + val fixedFiles: Seq[(os.SubPath, Elem)] = Seq( Tuple2(os.sub / "misc.xml", miscXmlTemplate(jdkInfo)), Tuple2(os.sub / "scala_settings.xml", scalaSettingsTemplate()), Tuple2( @@ -471,7 +470,7 @@ case class GenIdeaImpl( name.replaceAll("""[-.:]""", "_") } - val libraries: Seq[(SubPath, Elem)] = + val libraries: Seq[(os.SubPath, Elem)] = resolvedLibraries(allResolved).flatMap { resolved => val names = libraryNames(resolved) val sources = resolved match { @@ -481,7 +480,7 @@ case class GenIdeaImpl( } for (name <- names) yield { - val compilerCp: Agg[Path] = librariesProperties.getOrElse(resolved.path, Agg.empty) + val compilerCp: Agg[os.Path] = librariesProperties.getOrElse(resolved.path, Agg.empty) val languageLevel = name match { case _ if compilerCp.iterator.isEmpty => None case _ if name.startsWith("scala3-library_3-3.3.") => Some("Scala_3_3") @@ -509,7 +508,7 @@ case class GenIdeaImpl( } } - val moduleFiles: Seq[(SubPath, Elem)] = resolvedModules.map { + val moduleFiles: Seq[(os.SubPath, Elem)] = resolvedModules.map { case ResolvedModule( path, resolvedDeps, @@ -557,7 +556,7 @@ case class GenIdeaImpl( val sanizedDeps: Seq[ScopedOrd[String]] = { resolvedDeps - .map((s: Scoped[Path]) => pathToLibName(s.value) -> s.scope) + .map((s: Scoped[os.Path]) => pathToLibName(s.value) -> s.scope) .iterator .toSeq .groupBy(_._1) @@ -727,31 +726,55 @@ case class GenIdeaImpl( } - /** Try to make the file path a relative JAR URL (to PROJECT_DIR). */ + /** Try to make the file path a relative JAR URL (to PROJECT_DIR or HOME_DIR). */ def relativeJarUrl(path: os.Path): String = { // When coursier cache dir is on different logical drive than project dir // we can not use a relative path. See issue: https://github.com/lihaoyi/mill/issues/905 - val relPath = relForwardPath(path, "$PROJECT_DIR$/") + val relPath = relForwardPath(path) if (path.ext == "jar") "jar://" + relPath + "!/" else "file://" + relPath } - /** Try to make the file path a relative URL (to PROJECT_DIR). */ - def relativeFileUrl(path: Path): String = { + /** Try to make the file path a relative URL (to PROJECT_DIR or HOME_DIR). */ + def relativeFileUrl(path: os.Path): String = { // When coursier cache dir is on different logical drive than project dir // we can not use a relative path. See issue: https://github.com/lihaoyi/mill/issues/905 - "file://" + relForwardPath(path, "$PROJECT_DIR$/") + "file://" + relForwardPath(path) } - private def relForwardPath(path: os.Path, prefix: String): String = { + private def relProjectForwardPath(path: os.Path): String = { def forward(p: os.FilePath): String = p.toString().replace("""\""", "/") - Try(prefix + forward(path.relativeTo(workDir))).getOrElse(forward(path)) + Try(projectDir._2 + forward(path.relativeTo(projectDir._1))).getOrElse(forward(path)) + } + + private val projectDir = (workDir, "$PROJECT_DIR$/") + private val homeDir = (os.home, "$USER_HOME$/") + + private def relForwardPath(path: os.Path): String = { + + def forward(p: os.FilePath): String = p.toString().replace("""\""", "/") + + val relToProjectDir = Try(projectDir._2 + forward(path.relativeTo(projectDir._1))) + val relToHomeDir = Try(homeDir._2 + forward(path.relativeTo(homeDir._1))) + + (relToProjectDir, relToHomeDir) match { + // We seem to be outside of project-dir but inside home dir, so use releative path to home dir + case (Success(p1), Success(p2)) if p1.contains("..") && !p2.contains("..") => p2 + // default to project-dir-relative + case (Success(p), _) => p + // if that fails, use home-dir-relative, which might fix cases on Windows + // where the home-dir is not on the same drive as the project-dir + case (_, Success(p)) => p + // Use the absolute path + case _ => forward(path) + } + } } def libraryXmlTemplate( name: String, path: os.Path, sources: Option[os.Path], - scalaCompilerClassPath: Agg[Path], + scalaCompilerClassPath: Agg[os.Path], languageLevel: Option[String] ): Elem = { val isScalaLibrary = scalaCompilerClassPath.iterator.nonEmpty @@ -990,15 +1013,15 @@ object GenIdeaImpl { final case class ResolvedModule( path: Segments, - classpath: Agg[Scoped[Path]], + classpath: Agg[Scoped[os.Path]], module: JavaModule, - pluginClasspath: Agg[Path], + pluginClasspath: Agg[os.Path], scalaOptions: Seq[String], - compilerClasspath: Agg[Path], - libraryClasspath: Agg[Path], + compilerClasspath: Agg[os.Path], + libraryClasspath: Agg[os.Path], facets: Seq[JavaFacet], configFileContributions: Seq[IdeaConfigFile], - compilerOutput: Path, + compilerOutput: os.Path, evaluator: Evaluator ) diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ junit_junit_2_13_4_13_2_jar.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ junit_junit_2_13_4_13_2_jar.xml index c6bc930b141..9e643eaf6ab 100644 --- a/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ junit_junit_2_13_4_13_2_jar.xml +++ b/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ junit_junit_2_13_4_13_2_jar.xml @@ -1,10 +1,10 @@ - + - + \ No newline at end of file diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ org_scalameta_munit_2_13_0_7_29_jar.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ org_scalameta_munit_2_13_0_7_29_jar.xml index 68fe9634f79..7c8b3a6a294 100644 --- a/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ org_scalameta_munit_2_13_0_7_29_jar.xml +++ b/integration/feature/gen-idea/repo/extended/idea/libraries/SBT_ org_scalameta_munit_2_13_0_7_29_jar.xml @@ -1,10 +1,10 @@ - + - + \ No newline at end of file diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml index 5bdcd1522ff..d69a1376af8 100644 --- a/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml +++ b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml @@ -3,18 +3,18 @@ Scala_2_13 - - - - - + + + + + - + - + diff --git a/integration/feature/gen-idea/repo/hello-world/idea/libraries/scala_library_2_12_5_jar.xml b/integration/feature/gen-idea/repo/hello-world/idea/libraries/scala_library_2_12_5_jar.xml index f557f8fad27..893b4133025 100644 --- a/integration/feature/gen-idea/repo/hello-world/idea/libraries/scala_library_2_12_5_jar.xml +++ b/integration/feature/gen-idea/repo/hello-world/idea/libraries/scala_library_2_12_5_jar.xml @@ -3,17 +3,17 @@ Scala_2_12 - - - - + + + + - + - + From b1e14a9efca1c34a67371bf5194ef55936b58de0 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 16 May 2024 10:34:31 +0200 Subject: [PATCH 4/6] Renamed test module name to acoid too yet another "hello world" --- .../repo/{hello-world => hello-idea}/build.sc | 6 +++--- .../idea/libraries/scala_library_2_12_5_jar.xml | 0 .../repo/hello-idea/idea/mill_modules/helloidea.iml | 13 +++++++++++++ .../idea/mill_modules/helloidea.test.iml} | 10 +++++----- .../idea/mill_modules/mill-build.iml | 0 .../repo/{hello-world => hello-idea}/idea/misc.xml | 0 .../{hello-world => hello-idea}/idea/modules.xml | 4 ++-- .../hello-world/idea/mill_modules/helloworld.iml | 13 ------------- .../feature/gen-idea/test/src/GenIdeaTests.scala | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) rename integration/feature/gen-idea/repo/{hello-world => hello-idea}/build.sc (81%) rename integration/feature/gen-idea/repo/{hello-world => hello-idea}/idea/libraries/scala_library_2_12_5_jar.xml (100%) create mode 100644 integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml rename integration/feature/gen-idea/repo/{hello-world/idea/mill_modules/helloworld.test.iml => hello-idea/idea/mill_modules/helloidea.test.iml} (60%) rename integration/feature/gen-idea/repo/{hello-world => hello-idea}/idea/mill_modules/mill-build.iml (100%) rename integration/feature/gen-idea/repo/{hello-world => hello-idea}/idea/misc.xml (100%) rename integration/feature/gen-idea/repo/{hello-world => hello-idea}/idea/modules.xml (69%) delete mode 100644 integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.iml diff --git a/integration/feature/gen-idea/repo/hello-world/build.sc b/integration/feature/gen-idea/repo/hello-idea/build.sc similarity index 81% rename from integration/feature/gen-idea/repo/hello-world/build.sc rename to integration/feature/gen-idea/repo/hello-idea/build.sc index 69c1482bd75..dba62aebefb 100644 --- a/integration/feature/gen-idea/repo/hello-world/build.sc +++ b/integration/feature/gen-idea/repo/hello-idea/build.sc @@ -3,7 +3,7 @@ import mill.define.Target import mill._ import mill.scalalib.{Dep, DepSyntax, TestModule} -trait HelloWorldModule extends scalalib.ScalaModule { +trait HelloIdeaModule extends scalalib.ScalaModule { def scalaVersion = "2.12.5" object test extends ScalaTests with TestModule.Utest { override def compileIvyDeps: Target[Agg[Dep]] = Agg( @@ -20,8 +20,8 @@ trait HelloWorldModule extends scalalib.ScalaModule { } } -object HelloWorld extends HelloWorldModule +object HelloIdea extends HelloIdeaModule -object HiddenWorld extends HelloWorldModule { +object HiddenIdea extends HelloIdeaModule { override def skipIdea = true } diff --git a/integration/feature/gen-idea/repo/hello-world/idea/libraries/scala_library_2_12_5_jar.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_12_5_jar.xml similarity index 100% rename from integration/feature/gen-idea/repo/hello-world/idea/libraries/scala_library_2_12_5_jar.xml rename to integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_12_5_jar.xml diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml new file mode 100644 index 00000000000..8b91460b799 --- /dev/null +++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.test.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml similarity index 60% rename from integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.test.iml rename to integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml index ee320609f2f..b0920fbba37 100644 --- a/integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.test.iml +++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml @@ -1,10 +1,10 @@ - + - - - + + + @@ -13,6 +13,6 @@ - + diff --git a/integration/feature/gen-idea/repo/hello-world/idea/mill_modules/mill-build.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/mill-build.iml similarity index 100% rename from integration/feature/gen-idea/repo/hello-world/idea/mill_modules/mill-build.iml rename to integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/mill-build.iml diff --git a/integration/feature/gen-idea/repo/hello-world/idea/misc.xml b/integration/feature/gen-idea/repo/hello-idea/idea/misc.xml similarity index 100% rename from integration/feature/gen-idea/repo/hello-world/idea/misc.xml rename to integration/feature/gen-idea/repo/hello-idea/idea/misc.xml diff --git a/integration/feature/gen-idea/repo/hello-world/idea/modules.xml b/integration/feature/gen-idea/repo/hello-idea/idea/modules.xml similarity index 69% rename from integration/feature/gen-idea/repo/hello-world/idea/modules.xml rename to integration/feature/gen-idea/repo/hello-idea/idea/modules.xml index cab10e5c482..d079cc48d82 100644 --- a/integration/feature/gen-idea/repo/hello-world/idea/modules.xml +++ b/integration/feature/gen-idea/repo/hello-idea/idea/modules.xml @@ -1,8 +1,8 @@ - - + + diff --git a/integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.iml b/integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.iml deleted file mode 100644 index f3159dda104..00000000000 --- a/integration/feature/gen-idea/repo/hello-world/idea/mill_modules/helloworld.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/integration/feature/gen-idea/test/src/GenIdeaTests.scala b/integration/feature/gen-idea/test/src/GenIdeaTests.scala index c93b4c99b6a..74799815d91 100644 --- a/integration/feature/gen-idea/test/src/GenIdeaTests.scala +++ b/integration/feature/gen-idea/test/src/GenIdeaTests.scala @@ -9,7 +9,7 @@ import os.Path object GenIdeaTests extends IntegrationTestSuite { - override def scriptSourcePath: Path = super.scriptSourcePath / "hello-world" + override def scriptSourcePath: Path = super.scriptSourcePath / "hello-idea" def tests: Tests = Tests { test("helper assertPartialContentMatches works") { From 272dc4ff38f0aed9af1ba57e06c36f2d1bf7e5c3 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 16 May 2024 10:40:52 +0200 Subject: [PATCH 5/6] . --- idea/src/mill/idea/GenIdeaImpl.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/idea/src/mill/idea/GenIdeaImpl.scala b/idea/src/mill/idea/GenIdeaImpl.scala index 365a97c712f..752d642afd7 100755 --- a/idea/src/mill/idea/GenIdeaImpl.scala +++ b/idea/src/mill/idea/GenIdeaImpl.scala @@ -768,7 +768,6 @@ case class GenIdeaImpl( case _ => forward(path) } } - } def libraryXmlTemplate( name: String, From c327a8a4b691759900e1082c2132e740d08cc1c9 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 16 May 2024 13:04:30 +0200 Subject: [PATCH 6/6] Removed obsolete def --- idea/src/mill/idea/GenIdeaImpl.scala | 5 ----- 1 file changed, 5 deletions(-) diff --git a/idea/src/mill/idea/GenIdeaImpl.scala b/idea/src/mill/idea/GenIdeaImpl.scala index 752d642afd7..f2d17b6bf6d 100755 --- a/idea/src/mill/idea/GenIdeaImpl.scala +++ b/idea/src/mill/idea/GenIdeaImpl.scala @@ -741,11 +741,6 @@ case class GenIdeaImpl( "file://" + relForwardPath(path) } - private def relProjectForwardPath(path: os.Path): String = { - def forward(p: os.FilePath): String = p.toString().replace("""\""", "/") - Try(projectDir._2 + forward(path.relativeTo(projectDir._1))).getOrElse(forward(path)) - } - private val projectDir = (workDir, "$PROJECT_DIR$/") private val homeDir = (os.home, "$USER_HOME$/")