Skip to content
Browse files

Fixed unconditional loading of class play.api.Logger that died horrib…

…ly on projects lacking a Play dependency. Bumped version to 2012.09.20.1886ca6-v5. Changed publishing to go to CORE repo.
  • Loading branch information...
1 parent cd5174d commit 8d98ccf9d34876e9fda94d23504ef672f16da741 Dean Thompson committed Feb 13, 2013
Showing with 40 additions and 15 deletions.
  1. +16 −2 plugin/src/main/scala/NGPlugin.scala
  2. +24 −13 project/Build.scala
View
18 plugin/src/main/scala/NGPlugin.scala
@@ -25,10 +25,16 @@ object NGPlugin extends Plugin {
def ngSettings: Seq[Setting[_]] = super.settings ++ Seq(
testOptions in Test := Seq(),
testOptions in Test += Tests.Setup { loader =>
- loader.loadClass("play.api.Logger").getMethod("init", classOf[java.io.File]).invoke(null, new java.io.File("."))
+ val loggerClass = playLoggerClass(loader)
+ if (loggerClass != null) {
+ loggerClass.getMethod("init", classOf[java.io.File]).invoke(null, new java.io.File("."))
+ }
},
testOptions in Test += Tests.Cleanup { loader =>
- loader.loadClass("play.api.Logger").getMethod("shutdown").invoke(null)
+ val loggerClass = playLoggerClass(loader)
+ if (loggerClass != null) {
+ loggerClass.getMethod("shutdown").invoke(null)
+ }
},
//testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "sequential", "true"),
testOptions in Test += Tests.Argument(TestFrameworks.JUnit,"junitxml", "console")
@@ -40,6 +46,14 @@ object NGPlugin extends Plugin {
// If changing this, be sure to change in Build.scala also.
"de.johoop" %% "sbt-testng-interface" % "2.0.3" % "test"))
)
+
+ private def playLoggerClass(loader: ClassLoader) = {
+ try {
+ loader.loadClass("play.api.Logger")
+ } catch {
+ case e: ClassNotFoundException => null
+ }
+ }
}
import org.scalatools.testing.{Fingerprint, SubclassFingerprint, Framework, Logger, EventHandler}
View
37 project/Build.scala
@@ -5,15 +5,21 @@ import sbt.Keys._
object NGPluginBuild extends Build {
object Repos {
- val pattern = Patterns(
- Seq("[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).ivy"),
- Seq("[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]"),
- true
- )
+ val LinkedInPatterns = Patterns(
+ Seq("[organization]/[module]/[revision]/[module]-[revision].ivy"),
+ Seq("[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"),
+ isMavenCompatible = true)
- val artifactory = "http://artifactory.corp.linkedin.com:8081/artifactory/"
- val mavenLocal = Resolver.file("file", new File(Path.userHome.absolutePath + "/Documents/mvn-repo/snapshots"))
- val sandbox = Resolver.url("Artifactory sandbox", url(artifactory + "ext-sandbox"))(pattern)
+ val LocalRepoName = "~/local-repo"
+ val LocalRepoPath = file(System.getProperty("user.home") + "/local-repo")
+ val localRepo = Resolver.file(LocalRepoName, LocalRepoPath)(LinkedInPatterns)
+
+ val ArtifactoryBaseUrl = "http://artifactory.corp.linkedin.com:8081/artifactory/"
+ val sandbox = Resolver.url("Artifactory sandbox",
+ url(ArtifactoryBaseUrl + "ext-sandbox"))(LinkedInPatterns)
+ val core = Resolver.url("Artifactory CORE",
+ url(ArtifactoryBaseUrl + "CORE"))(LinkedInPatterns)
+
val typeSafeReleases = "TypeSafeRelease" at "http://repo.typesafe.com/typesafe/releases/"
}
@@ -47,17 +53,22 @@ object NGPluginBuild extends Build {
lazy val commonSettings: Seq[Setting[_]] = Project.defaultSettings ++ publishSettings ++ Seq(
organization := "com.linkedin",
scalaVersion := "2.9.2",
- version := "2012.09.20.1886ca6",
- resolvers ++= Seq(Repos.sandbox, Repos.typeSafeReleases))
+ version := "2012.09.20.1886ca6-v5",
+ resolvers ++= Seq(Repos.localRepo, Repos.sandbox, Repos.typeSafeReleases))
lazy val publishSettings: Seq[Setting[_]] = Seq(
// publishTo <<= version { (v: String) =>
// if (v.trim.endsWith("SNAPSHOT"))
// Some(Repos.snapshots)
- // else
- // Some(Repos.releases)
+ // else
+ // Some(Repos.releases)
+ //},
+ // publishLocalConfiguration <<= (packagedArtifacts, publishMavenStyle, deliverLocal, ivyLoggingLevel) map {
+ // (artifacts, mavenStyle, ivyFile, loggingLevel) =>
+ // Classpaths.publishConfig(artifacts, if (mavenStyle) None else Some(ivyFile), Seq("sha1", "md5"),
+ // Repos.LocalRepoName, loggingLevel)
// },
- publishTo := Some(Repos.sandbox),
+ publishTo := Some(Repos.core),
credentials ++= Seq(
Credentials(Path.userHome / ".sbt" / ".licredentials")
),

0 comments on commit 8d98ccf

Please sign in to comment.
Something went wrong with that request. Please try again.