Skip to content

Commit 0782232

Browse files
committed
Add selectable classpath project scope
1 parent 72e0dc5 commit 0782232

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/main/scala/com/lightbend/paradox/apidoc/ApidocKeys.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ package com.lightbend.paradox.apidoc
1919
import sbt._
2020

2121
trait ApidocKeys {
22-
val apidocRootPackage = settingKey[String]("")
22+
val apidocRootPackage = settingKey[String]("Root package for all candidate classes")
23+
val apidocProjects = settingKey[Seq[ProjectReference]]("Projects which will be queried for classes to link to")
24+
val apidocClasses = taskKey[Seq[URL]]("All of the classes that will be queried")
2325
}

src/main/scala/com/lightbend/paradox/apidoc/ApidocPlugin.scala

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,24 @@ object ApidocPlugin extends AutoPlugin {
2929
object autoImport extends ApidocKeys
3030
import autoImport._
3131

32-
val version = ParadoxPlugin.readProperty("akka-paradox.properties", "akka.paradox.version")
33-
34-
override def requires: Plugins = ParadoxPlugin
35-
32+
override def requires: Plugins = ParadoxPlugin
3633
override def trigger: PluginTrigger = AllRequirements
3734

38-
override def projectSettings: Seq[Setting[_]] = apidocSettings(Compile)
35+
override def projectSettings: Seq[Setting[_]] = apidocParadoxZeroSettings
3936

40-
def apidocParadoxGlobalSettings: Seq[Setting[_]] = Seq(
37+
def apidocParadoxZeroSettings: Seq[Setting[_]] = Seq(
4138
apidocRootPackage := "scala",
39+
apidocClasses := Def.taskDyn {
40+
val classpathProjects = apidocProjects.?.value
41+
.map(inProjects)
42+
.getOrElse {
43+
inAggregates(LocalRootProject, includeRoot = true)
44+
}
45+
val filter = ScopeFilter(classpathProjects, inConfigurations(Compile))
46+
fullClasspath.all(filter).map(_.flatMap(_.files).map(_.toURI.toURL))
47+
}.value,
4248
paradoxDirectives ++= Def.taskDyn {
43-
val classpath = (fullClasspath in Compile).value.files.map(_.toURI.toURL).toArray
44-
val classLoader = new java.net.URLClassLoader(classpath, this.getClass.getClassLoader)
49+
val classLoader = new java.net.URLClassLoader(apidocClasses.value.toArray, this.getClass.getClassLoader)
4550
val scanner = new ClassGraph()
4651
.whitelistPackages(apidocRootPackage.value)
4752
.addClassLoader(classLoader)
@@ -56,11 +61,4 @@ object ApidocPlugin extends AutoPlugin {
5661
}
5762
}.value
5863
)
59-
60-
def apidocSettings(config: Configuration): Seq[Setting[_]] =
61-
apidocParadoxGlobalSettings ++ inConfig(config)(
62-
Seq(
63-
// scoped settings here
64-
)
65-
)
6664
}

0 commit comments

Comments
 (0)