Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions project/ProjectBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ object ProjectBuild extends Build {
.configs(config("it") extend Runtime)
.settings(commonSettings ++ itSettings:_*)
.settings(
scalaVersion := "2.10.4",
scalaVersion := "2.11.8",
resolvers += Resolver.bintrayRepo("nyavro", "sbt-plugins"),
name := "sbt-spi-plugin",
description := "Automates exporting implementation lists for later use with ServiceLoader",
sbtPlugin := true,
publishArtifact in Test := false,
libraryDependencies ++= Seq(
"org.clapper" % "classutil_2.10" % "1.0.6",
"org.scalatest" % "scalatest_2.10" % "3.0.0-M14" % "it, test",
"org.scalamock" % "scalamock-scalatest-support_2.10" % "3.2.2" % "test"
"org.clapper" %% "classutil" % "1.0.13",
"org.scalatest" %% "scalatest" % "3.0.0" % "it, test",
"org.scalamock" %% "scalamock-scalatest-support" % "3.3.0" % "test"
),
// Bintray publishing
publishMavenStyle := false,
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.8
sbt.version=0.13.13
2 changes: 1 addition & 1 deletion spi-plugin-sample/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.8
sbt.version = 0.13.13
10 changes: 7 additions & 3 deletions src/main/scala/com/eny/plugin/spi/MapImplementations.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.eny.plugin.spi

import java.io.File

import org.clapper.classutil.ClassFinder

/**
* Represents correspondence between interface name and its implementations
* @param spiPaths - Optional Collection of interfaces (traits) packages
Expand All @@ -17,8 +21,8 @@ class MapImplementations(spiPaths: Seq[String], traits: Seq[String], implPath: S
* @return Map of interface name to collection of it's implementation class names
*/
def run() = {
(spiPaths.flatMap(new InterfacesList(_).interfaces) ++ traits)
.map(item => item -> new ImplementationsList(Set(item), implPath).implementations())
.toMap
def finder(f: Seq[File] = Seq.empty) = ClassFinder(f).getClasses().withFilter(_.isInterface).map(_.name).toSet
val names: Seq[String] = if (spiPaths.isEmpty) finder().toSeq else spiPaths.flatMap(path => finder(Seq(new File(path))))
(names ++ traits).map(item => item -> new ImplementationsList(Set(item), implPath).implementations()).toMap
}
}