Skip to content

Commit

Permalink
fix: adding package path to classGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeQuadrat committed Aug 12, 2022
1 parent 79c6276 commit 1847da4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sbt.Compile

val releaseVersion = sys.env.getOrElse("TAG", "0.0.0")
val releaseVersion = sys.env.getOrElse("TAG", "0.2.2-1")

val token = sys.env.getOrElse("GITHUB_TOKEN", "")
val githubSettings = Seq(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.innfactory.smithy4play

import io.github.classgraph.{ ClassGraph, ScanResult }
import com.typesafe.config.Config
import io.github.classgraph.{ClassGraph, ScanResult}
import play.api.Application
import play.api.mvc.ControllerComponents
import play.api.routing.Router.Routes
Expand All @@ -9,16 +10,21 @@ import javax.inject.Inject
import scala.concurrent.ExecutionContext
import scala.jdk.CollectionConverters.CollectionHasAsScala

@Singleton
class AutoRouter @Inject(
) (implicit
cc: ControllerComponents,
app: Application,
ec: ExecutionContext
ec: ExecutionContext,
config: Config
) extends BaseRouter {

override val controllers: Seq[Routes] = {
val classGraphScanner: ScanResult = new ClassGraph().verbose().enableAllInfo().scan()
val pkg = config.getString("smithy4play.autoRoutePackage")
val classGraphScanner: ScanResult = new ClassGraph().enableAllInfo().acceptPackages(pkg).scan()
val controllers = classGraphScanner.getClassesImplementing(classOf[AutoRoutableController])
logger.debug(s"[AutoRouter] found ${controllers.size()} Controllers")
classGraphScanner.close()
controllers.asScala.map(_.loadClass(true)).map(clazz => createFromClass(clazz)).toSeq
}

Expand Down

0 comments on commit 1847da4

Please sign in to comment.