This repository has been archived by the owner on Mar 14, 2019. It is now read-only.
/
Build.scala
104 lines (93 loc) · 3.57 KB
/
Build.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2013 zhongl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import sbt._
import sbt.Keys._
import ProguardPlugin._
object Build extends sbt.Build {
import Dependencies._
import Unmanaged._
val VERSION = "0.3.0"
val javaHome = sys.props("java.home")
lazy val proguard = proguardSettings ++ Seq(
proguardOptions := Seq(
"-keepclasseswithmembers public class * { public static void main(java.lang.String[]); }",
"-keep class * implements org.xml.sax.EntityResolver",
"-keep class com.github.zhongl.housemd.** { *;} ",
"-keep class com.github.zhongl.yascli.** { *;} ",
"-keep class scala.** { *;} ",
"-keep class akka.** { *;} ",
"-keepclassmembers class * { ** MODULE$;}"
),
proguardLibraryJars := { (jdkJarPath: PathFinder).get }
)
private def jdkJarPath = {
val home = new java.io.File(javaHome)
val rtJar = home / "lib" / "rt.jar"
val toolsJar = home.getParentFile / "lib" / "tools.jar"
val classesJar = home.getParentFile / "Classes" / "classes.jar"
if (classesJar.asFile.exists()) // it means current os is Mac OSX
Seq(classesJar.asFile)
else if (rtJar.asFile.exists())
Seq(rtJar.asFile, toolsJar.asFile)
else
throw new IllegalStateException("Unknown location for rt.jar")
}
lazy val root = Project(
id = "housemd",
base = file("."),
settings = Defaults.defaultSettings ++ classpathSettings ++ proguard ++ Seq(
name := "housemd",
organization := "com.github.zhongl",
version := VERSION,
scalaVersion := "2.10.2",
javacOptions ++= Seq("-source", "6", "-target", "6"),
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-language:_"),
resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
libraryDependencies ++= compileLibs ++ testLibs,
packageOptions += Package.ManifestAttributes(
("Main-Class", "com.github.zhongl.housemd.House"),
("Agent-Class", "com.github.zhongl.housemd.Agent"),
("Can-Retransform-Classes", "true"),
("Can-Redefine-Classes", "true"),
("Signature-Version", VERSION)
),
parallelExecution in Test := false
)
)
object Dependencies {
lazy val testLibs = Seq(
"org.mockito" % "mockito-all" % "1.9.0" % "test",
"com.typesafe.akka" % "akka-actor-tests_2.10" % "2.1.4" % "test",
"org.scalatest" % "scalatest_2.10" % "1.9.1" % "test"
)
lazy val compileLibs = Seq(
"org.ow2.asm" % "asm-commons" % "4.0",
"com.google.guava" % "guava" % "14.0.1",
"org.scalaz" % "scalaz-core_2.10" % "7.0.0",
"com.github.zhongl" % "yascli_2.10" % "0.2.0",
"com.typesafe.akka" % "akka-actor_2.10" % "2.1.4"
)
}
object Unmanaged {
lazy val toolsFile = file(javaHome + "/../lib/tools.jar")
lazy val classpathSettings =
if (toolsFile.exists()) Seq(
unmanagedClasspath in Compile += Attributed.blank(toolsFile),
unmanagedClasspath in Test <<= unmanagedClasspath in Compile
)
else Seq()
}
}