-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
184 lines (151 loc) · 6.39 KB
/
build.sbt
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import ScriptedPlugin._
import bintray.Keys._
val pluginVersion = "1.7.1"
val gradleBuildVersion = "1.3.0"
val androidToolsVersion = "2.2.0"
// gradle-plugin and gradle-model projects
val model = project.in(file("gradle-model")).settings(
name := "gradle-discovery-model",
organization := "com.hanhuy.gradle",
resolvers += Resolver.jcenterRepo,
javacOptions ++= "-source" :: "1.6" :: "-target" :: "1.6" :: Nil,
autoScalaLibrary := false,
crossPaths := false,
libraryDependencies ++=
"com.android.tools.build" % "builder-model" % androidToolsVersion ::
"org.gradle" % "gradle-tooling-api" % "2.6" % "provided" :: Nil
)
val gradle = project.in(file("gradle-plugin")).settings(bintrayPublishSettings:_*).settings(
name := "gradle-discovery-plugin",
mappings in (Compile, packageBin) ++= (mappings in (Compile, packageBin) in model).value,
repository in bintray := "maven",
organization := "com.hanhuy.gradle",
bintrayOrganization in bintray := None,
resolvers += Resolver.jcenterRepo,
publishMavenStyle := true,
autoScalaLibrary := false,
crossPaths := false,
sbtPlugin := false,
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
version := "0.5",
javacOptions ++= "-source" :: "1.6" :: "-target" :: "1.6" :: Nil,
javacOptions in doc := {
(javacOptions in doc).value.foldRight(List.empty[String]) {
(x, a) => if (x != "-target") x :: a else a.drop(1)
}
},
libraryDependencies ++=
"org.codehaus.groovy" % "groovy" % "2.4.4" % "provided" ::
"com.android.tools.build" % "gradle" % androidToolsVersion ::
"com.android.tools.build" % "builder-model" % androidToolsVersion ::
"org.gradle" % "gradle-tooling-api" % "2.6" % "provided" ::
"javax.inject" % "javax.inject" % "1" % "provided" ::
Nil
) dependsOn(model % "compile-internal")
val gradlebuild = project.in(file("gradle-build")).settings(buildInfoSettings ++ bintrayPublishSettings:_*).settings(
version := gradleBuildVersion,
resolvers += Resolver.jcenterRepo,
mappings in (Compile, packageBin) ++=
(mappings in (Compile, packageBin) in model).value,
name := "sbt-android-gradle",
organization := "org.scala-android",
scalacOptions ++= Seq("-deprecation","-Xlint","-feature"),
libraryDependencies ++= Seq(
"com.hanhuy.sbt" %% "bintray-update-checker" % "0.2",
"com.google.code.findbugs" % "jsr305" % "3.0.1" % "compile-internal",
"org.gradle" % "gradle-tooling-api" % "2.6" % "provided",
"org.slf4j" % "slf4j-api" % "1.7.10" // required by gradle-tooling-api
),
// embed gradle-tooling-api jar in plugin since they don't publish on central
products in Compile := {
val p = (products in Compile).value
val t = crossTarget.value
val m = (managedClasspath in Compile).value
val g = t / "gradle-tooling-api"
val apiJar = m.collect {
case j if j.get(moduleID.key).exists(_.organization == "org.gradle") &&
j.get(moduleID.key).exists(_.name == "gradle-tooling-api") => j.data
}.headOption
FileFunction.cached(streams.value.cacheDirectory / "gradle-tooling-api", FilesInfo.lastModified) { in =>
in foreach (IO.unzip(_, g, { n: String => !n.startsWith("META-INF") }))
(g ** "*.class").get.toSet
}(apiJar.toSet)
g +: p
},
sbtPlugin := true,
repository in bintray := "sbt-plugins",
publishMavenStyle := false,
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
bintrayOrganization in bintray := None,
sourceGenerators in Compile <+= buildInfo,
buildInfoKeys := Seq(name, version),
buildInfoPackage := "android.gradle"
).settings(addSbtPlugin(
"org.scala-android" % "sbt-android" % pluginVersion)).dependsOn(model % "compile-internal")
name := "sbt-android"
organization := "org.scala-android"
version := pluginVersion
scalacOptions ++= Seq("-deprecation","-Xlint","-feature")
sourceDirectories in Compile <<= baseDirectory(b => Seq(b / "src"))
scalaSource in Compile <<= baseDirectory(_ / "src")
scalaSource in Test <<= baseDirectory(_ / "test")
unmanagedBase <<= baseDirectory(_ / "libs")
resourceDirectory in Compile <<= baseDirectory(_ / "resources")
libraryDependencies ++= Seq(
"org.ow2.asm" % "asm-all" % "5.0.4",
"com.google.code.findbugs" % "jsr305" % "3.0.1" % "compile-internal",
"org.javassist" % "javassist" % "3.20.0-GA",
"com.hanhuy.sbt" %% "bintray-update-checker" % "0.2",
"com.android.tools.build" % "builder" % androidToolsVersion,
"org.bouncycastle" % "bcpkix-jdk15on" % "1.51",
"com.android.tools.build" % "gradle-core" % androidToolsVersion excludeAll
ExclusionRule(organization = "net.sf.proguard"),
"com.android.tools.lint" % "lint" % "25.2.0",
"com.android.tools.external.com-intellij" % "uast" % "145.597.4", // because google didn't sync the correct version...
"net.orfjackal.retrolambda" % "retrolambda" % "2.3.0"
)
aggregate := false
sbtPlugin := true
// build info plugin
buildInfoSettings
sourceGenerators in Compile <+= buildInfo
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion)
buildInfoPackage := "android"
// bintray
bintrayPublishSettings
repository in bintray := "sbt-plugins"
publishMavenStyle := false
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
bintrayOrganization in bintray := None
// scripted-test settings
scriptedSettings
scriptedLaunchOpts ++= Seq("-Xmx1024m", "-Dplugin.version=" + version.value)
//scriptedBufferLog := false
sbtTestDirectory <<= baseDirectory (_ / "sbt-test")
// TODO reorganize tests better, ditch android-sdk-plugin prefix
// group by test config type
scriptedDependencies <<= ( sbtTestDirectory
, streams
, organization
, name
, version
, sbtVersion) map {
(dir,s, org, n, v, sbtv) =>
val testBases = List(dir / "android-sdk-plugin", dir / "no-travis")
val tests = testBases.flatMap(_.listFiles(DirectoryFilter)) filter { d =>
(d ** "*.sbt").get.nonEmpty || (d / "project").isDirectory
}
tests foreach { test =>
val project = test / "project"
project.mkdirs()
val pluginsFile = project / "auto_plugins.sbt"
val propertiesFile = project / "build.properties"
pluginsFile.delete()
propertiesFile.delete()
IO.writeLines(pluginsFile,
"""addSbtPlugin("%s" %% "%s" %% "%s")""".format(org, n, v) ::
Nil)
IO.write(propertiesFile, """sbt.version=%s""" format sbtv)
}
}
scriptedDependencies <<= scriptedDependencies dependsOn publishLocal