From ff12c87367736fb1ed4d0fd728998471805e9f68 Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Tue, 23 Feb 2021 16:24:49 +0100 Subject: [PATCH] fix scaladoc resolution without JCenter --- main/src/main/scala/sbt/Defaults.scala | 8 ++++---- sbt/src/sbt-test/actions/doc-scala3/build.sbt | 12 ++++++++---- .../{ => m3}/src/main/scala/foo/A.scala | 0 .../doc-scala3/rc1/src/main/scala/foo/A.scala | 10 ++++++++++ sbt/src/sbt-test/actions/doc-scala3/test | 18 ++++++++---------- 5 files changed, 30 insertions(+), 18 deletions(-) rename sbt/src/sbt-test/actions/doc-scala3/{ => m3}/src/main/scala/foo/A.scala (100%) create mode 100644 sbt/src/sbt-test/actions/doc-scala3/rc1/src/main/scala/foo/A.scala diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index f9d659789..7baf14d5d 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -2087,18 +2087,17 @@ object Defaults extends BuildCommon { val runDoc = Doc.scaladoc(label, s.cacheStoreFactory sub "scala", cs.scalac match { case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scaladoc")) }, fiOpts) - val isScala3 = ScalaArtifacts.isScala3(sv) def isScala3Doc(module: ModuleID): Boolean = { module.configurations.exists(_.startsWith(Configurations.ScalaDocTool.name)) && module.name == ScalaArtifacts.Scala3DocID } - if (isScala3 && !allDeps.exists(isScala3Doc)) { + if (ScalaArtifacts.isScala3M123(sv) && !allDeps.exists(isScala3Doc)) { Array( "Unresolved scala3doc artifact", "add 'ThisBuild / resolvers += Resolver.JCenterRepository'" ).foreach(m => s.log.error(m)) } - val docSrcs = if (isScala3) tFiles else srcs + val docSrcs = if (ScalaArtifacts.isScala3(sv)) tFiles else srcs runDoc(docSrcs, cp, out, options, maxErrors.value, s.log) case (_, true) => val javadoc = @@ -3188,10 +3187,11 @@ object Classpaths { val sbtOrg = scalaOrganization.value val version = scalaVersion.value val extResolvers = externalResolvers.value + val isScala3M123 = ScalaArtifacts.isScala3M123(version) val allToolDeps = if (scalaHome.value.isDefined || scalaModuleInfo.value.isEmpty || !managedScalaInstance.value) Nil - else if (extResolvers.contains(Resolver.JCenterRepository)) { + else if (!isScala3M123 || extResolvers.contains(Resolver.JCenterRepository)) { ScalaArtifacts.toolDependencies(sbtOrg, version) ++ ScalaArtifacts.docToolDependencies(sbtOrg, version) } else ScalaArtifacts.toolDependencies(sbtOrg, version) diff --git a/sbt/src/sbt-test/actions/doc-scala3/build.sbt b/sbt/src/sbt-test/actions/doc-scala3/build.sbt index 60e38b5ca..583a736e0 100644 --- a/sbt/src/sbt-test/actions/doc-scala3/build.sbt +++ b/sbt/src/sbt-test/actions/doc-scala3/build.sbt @@ -1,7 +1,11 @@ -ThisBuild / scalaVersion := "3.0.0-M4-bin-20210212-0273336-NIGHTLY" -// ThisBuild / scalaVersion := "3.0.0-M3", - -lazy val root = (project in file(".")) +lazy val m3 = (project in file("m3")) .settings( + scalaVersion := "3.0.0-M3", resolvers += Resolver.JCenterRepository ) + +lazy val rc1 = (project in file("rc1")) + .settings( + scalaVersion := "3.0.0-RC1" + ) + diff --git a/sbt/src/sbt-test/actions/doc-scala3/src/main/scala/foo/A.scala b/sbt/src/sbt-test/actions/doc-scala3/m3/src/main/scala/foo/A.scala similarity index 100% rename from sbt/src/sbt-test/actions/doc-scala3/src/main/scala/foo/A.scala rename to sbt/src/sbt-test/actions/doc-scala3/m3/src/main/scala/foo/A.scala diff --git a/sbt/src/sbt-test/actions/doc-scala3/rc1/src/main/scala/foo/A.scala b/sbt/src/sbt-test/actions/doc-scala3/rc1/src/main/scala/foo/A.scala new file mode 100644 index 000000000..c4496c701 --- /dev/null +++ b/sbt/src/sbt-test/actions/doc-scala3/rc1/src/main/scala/foo/A.scala @@ -0,0 +1,10 @@ +package foo + +final val foo="Foo" + +object A: + /** + * @param i An argument + */ + def x(i:Int)=3 + diff --git a/sbt/src/sbt-test/actions/doc-scala3/test b/sbt/src/sbt-test/actions/doc-scala3/test index 20241bff4..c13e97789 100644 --- a/sbt/src/sbt-test/actions/doc-scala3/test +++ b/sbt/src/sbt-test/actions/doc-scala3/test @@ -1,17 +1,15 @@ -> doc +> rc1 / doc # there shouldn't be two api/ directories # see https://github.com/lampepfl/dotty/issues/11412 -$ exists target/scala-3.0.0-M4/api/api/index.html -$ exists target/scala-3.0.0-M4/api/api/foo/A$.html -$ exists target/scala-3.0.0-M4/api/api/foo.html +$ exists rc1/target/scala-3.0.0-RC1/api/api/index.html +$ exists rc1/target/scala-3.0.0-RC1/api/api/foo/A$.html +$ exists rc1/target/scala-3.0.0-RC1/api/api/foo.html -> ++3.0.0-M3! -> clean -> doc +> m3 / doc # there shouldn't be two api/ directories # see https://github.com/lampepfl/dotty/issues/11412 -$ exists target/scala-3.0.0-M3/api/index.html -$ exists target/scala-3.0.0-M3/api/api/foo/A$.html -$ exists target/scala-3.0.0-M3/api/api/foo.html +$ exists m3/target/scala-3.0.0-M3/api/index.html +$ exists m3/target/scala-3.0.0-M3/api/api/foo/A$.html +$ exists m3/target/scala-3.0.0-M3/api/api/foo.html