-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support doc
task with dottydoc
#4952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
> run | ||
> doc | ||
> 'set initialCommands := "1 + 1" ' | ||
# FIXME: does not work on the CI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's preventing this from being run on the CI? It would be nice to also check that this generates what it's supposed to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The REPL doesn't work in the CI. JLine doesn't work outside of a "real terminal" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be a way via some JLine option to support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default JLine spawns a "dumb" terminal if not able to create a terminal. But you can't do anything with it, not sure we can even use it for test purpose. So i disabled it: |
||
#> console |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ package dotty.tools.sbtplugin | |
|
||
import sbt._ | ||
import sbt.Keys._ | ||
// import sbt.inc.{ ClassfileManager, IncOptions } | ||
import sbt.librarymanagement.DependencyResolution | ||
import sbt.internal.inc.ScalaInstance | ||
import xsbti.compile._ | ||
import java.net.URLClassLoader | ||
import java.util.Optional | ||
|
||
object DottyPlugin extends AutoPlugin { | ||
|
@@ -151,6 +153,8 @@ object DottyPlugin extends AutoPlugin { | |
scalaOrganization.value | ||
}, | ||
|
||
scalacOptions in (Compile, doc) ++= Seq("-project", name.value), | ||
|
||
incOptions in Compile := { | ||
val inc = (incOptions in Compile).value | ||
if (isDotty.value) | ||
|
@@ -174,7 +178,43 @@ object DottyPlugin extends AutoPlugin { | |
scalaVersion.value.split("\\.").take(2).mkString(".") | ||
else | ||
scalaBinaryVersion.value | ||
} | ||
}, | ||
|
||
scalaInstance := Def.taskDyn { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
val si = scalaInstance.value | ||
if (isDotty.value) { | ||
Def.task { | ||
val dottydocArtifacts = fetchArtifactsOf("dotty-doc").value | ||
val includeArtifact = (f: File) => f.getName.endsWith(".jar") | ||
val dottydocJars = dottydocArtifacts.filter(includeArtifact).toArray | ||
val allJars = (si.allJars ++ dottydocJars).distinct | ||
val loader = new URLClassLoader(Path.toURLs(dottydocJars), si.loader) | ||
new ScalaInstance(si.version, loader, si.loaderLibraryOnly, si.libraryJar, si.compilerJar, allJars, si.explicitActual) | ||
} | ||
} else { | ||
Def.task { si } | ||
} | ||
}.value | ||
) | ||
} | ||
|
||
/** Fetch artefacts for scalaOrganization.value %% moduleName % scalaVersion.value */ | ||
private def fetchArtifactsOf(moduleName: String) = Def.task { | ||
val dependencyResolution = Keys.dependencyResolution.value | ||
val log = streams.value.log | ||
val scalaInfo = scalaModuleInfo.value | ||
val updateConfiguration = Keys.updateConfiguration.value | ||
val warningConfiguration = (unresolvedWarningConfiguration in update).value | ||
|
||
val moduleID = (scalaOrganization.value %% moduleName % scalaVersion.value).cross(CrossVersion.binary) | ||
val descriptor = dependencyResolution.wrapDependencyInModule(moduleID, scalaInfo) | ||
|
||
dependencyResolution.update(descriptor, updateConfiguration, warningConfiguration, log) match { | ||
case Right(report) => | ||
report.allFiles | ||
case _ => | ||
throw new MessageOnlyException( | ||
s"Couldn't retrieve `${scalaOrganization.value} %% $moduleName %% ${scalaVersion.value}`.") | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not run on PRs. Did you run it locally? I'll take your words for it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine on my machine at least.