forked from foundweekends/conscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
154 lines (148 loc) · 6.32 KB
/
build.sbt
File metadata and controls
154 lines (148 loc) · 6.32 KB
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
import Dependencies._
import com.typesafe.sbt.SbtGhPages.{ghpages, GhPagesKeys => ghkeys}
import com.typesafe.sbt.SbtGit.{git, GitKeys}
import com.typesafe.sbt.git.GitRunner
lazy val pushSiteIfChanged = taskKey[Unit]("push the site if changed")
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin, CrossPerProjectPlugin, PamfletPlugin).
settings(
inThisBuild(List(
organization := "org.foundweekends.conscript",
version := "0.5.0-SNAPSHOT",
scalaVersion := "2.11.8",
homepage := Some(url("https://github.com/foundweekends/conscript/")),
bintrayOrganization := Some("foundweekends"),
bintrayRepository := "maven-releases",
bintrayReleaseOnPublish := false,
bintrayPackage := "conscript",
licenses := Seq("LGPL-3.0" -> url("http://www.gnu.org/licenses/lgpl.txt")),
developers := List(
Developer("n8han", "Nathan Hamblen", "@n8han", url("http://github.com/n8han")),
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n"))
),
scmInfo := Some(ScmInfo(url("https://github.com/foundweekends/conscript"), "git@github.com:foundweekends/conscript.git"))
)),
name := "conscript",
crossScalaVersions := List("2.11.8"),
libraryDependencies ++= List(launcherInterface, scalaSwing, dispatchCore, scopt, liftJson, slf4jJdk14),
bintrayPackage := (bintrayPackage in ThisBuild).value,
bintrayRepository := (bintrayRepository in ThisBuild).value,
mainClass in (Compile, packageBin) := Some("conscript.Conscript"),
mappings in (Compile, packageBin) := {
val old = (mappings in (Compile, packageBin)).value
old filter { case (_, p) => p != "META-INF/MANIFEST.MF" }
},
mappings in (Compile, packageSrc) := {
val old = (mappings in (Compile, packageSrc)).value
old filter { case (_, p) => p != "META-INF/MANIFEST.MF" }
},
proguardSettings,
ProguardKeys.proguardVersion in Proguard := "5.2.1",
ProguardKeys.options in Proguard ++= Seq(
"-keep class conscript.* { *; }",
"-keep class dispatch.* { *; }",
"-keep class com.ning.http.util.** { *; }",
"-keep class com.ning.http.client.providers.netty.** { *; }",
"-keep class org.apache.commons.logging.impl.LogFactoryImpl { *; }",
"-keep class org.apache.commons.logging.impl.Jdk14Logger { *; }",
"-dontnote",
"-dontwarn",
"-dontobfuscate",
"-dontoptimize"
),
ProguardKeys.inputs in Proguard <<=
(fullClasspath in Compile, fullClasspath in Runtime) map { (ccp, rcp) =>
(ccp.files ++ rcp.files).distinct.filter { f =>
// This is a dependency of the launcher interface. It may not be the version of scala
// we're using at all, and we don't want it
f.getName != "scala-library.jar"
}
},
ProguardKeys.defaultInputFilter in Proguard := None,
javaOptions in (Proguard, ProguardKeys.proguard) := Seq("-Xmx2G"),
ProguardKeys.outputs in Proguard <<=
(ProguardKeys.proguardDirectory in Proguard, version) map { (op,v) =>
op / ("conscript-" + v + ".jar") :: Nil
},
artifact in (Compile, ProguardKeys.proguard) := {
val art = (artifact in (Compile, ProguardKeys.proguard)).value
art.copy(`classifier` = Some("proguard"))
},
addArtifact(artifact in (Compile, ProguardKeys.proguard), (ProguardKeys.proguard in Proguard) map { xs => xs.head }),
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion),
buildInfoPackage := "conscript",
publishMavenStyle := true,
publishArtifact in Test := false,
ghpages.settings,
sourceDirectory in Pamflet := { baseDirectory.value / "docs" },
// GitKeys.gitBranch in ghkeys.updatedRepository := Some("gh-pages"),
// This task is responsible for updating the master branch on some temp dir.
// On the branch there are files that was generated in some other ways such as:
// - CNAME file
//
// This task's job is to call "git rm" on files and directories that this project owns
// and then copy over the newly generated files.
ghkeys.synchLocal := {
// sync the generated site
val repo = ghkeys.updatedRepository.value
val s = streams.value
val r = GitKeys.gitRunner.value
gitConfig(repo, r, s.log)
gitRemoveFiles(repo, (repo * "*.html").get.toList, r, s)
val mappings = for {
(file, target) <- siteMappings.value
} yield (file, repo / target)
IO.copy(mappings)
repo
},
// https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
// 1. generate token at https://github.com/settings/tokens/new
// 2. encrypt the token
pushSiteIfChanged := (Def.taskDyn {
val repo = baseDirectory.value
val r = GitKeys.gitRunner.value
val s = streams.value
val changed = gitDocsChanged(repo, r, s.log)
if (changed) ghkeys.pushSite
else Def.task {}
}).value,
git.remoteRepo := {
sys.env.get("GH_TOKEN") match {
case Some(token) => s"https://${token}@github.com/foundweekends/conscript.git"
case _ => "git@github.com:foundweekends/conscript.git"
}
}
)
lazy val plugin = (project in file("sbt-conscript")).
enablePlugins(CrossPerProjectPlugin).
settings(
name := "sbt-conscript",
scalaVersion := "2.10.6",
crossScalaVersions := List("2.10.6"),
sbtPlugin := true,
bintrayOrganization := Some("sbt"),
bintrayRepository := "sbt-plugin-releases",
bintrayPackage := "sbt-conscript"
)
def gitRemoveFiles(dir: File, files: List[File], git: GitRunner, s: TaskStreams): Unit = {
if(!files.isEmpty)
git(("rm" :: "-r" :: "-f" :: "--ignore-unmatch" :: files.map(_.getAbsolutePath)) :_*)(dir, s.log)
()
}
def gitDocsChanged(dir: File, git: GitRunner, log: Logger): Boolean =
{
// git diff --shortstat HEAD^..HEAD docs
val range = sys.env.get("TRAVIS_COMMIT_RANGE") match {
case Some(x) => x
case _ => "HEAD^..HEAD"
}
val stat = git(("diff" :: "--shortstat" :: range :: "docs" :: Nil) :_*)(dir, log)
stat.trim.nonEmpty
}
def gitConfig(dir: File, git: GitRunner, log: Logger): Unit =
sys.env.get("GH_TOKEN") match {
case Some(token) =>
git(("config" :: "user.name" :: "Travis CI" :: Nil) :_*)(dir, log)
git(("config" :: "user.email" :: "eed3si9n@gmail.com" :: Nil) :_*)(dir, log)
case _ => ()
}