-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sbt
168 lines (143 loc) · 6.15 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
val nexus = "https://oss.sonatype.org/"
val nexusSnapshots = nexus + "content/repositories/snapshots"
val nexusStaging = nexus + "service/local/staging/deploy/maven2"
val consuelaApiBase = settingKey[String]("Base of consuela API docs")
val updateSite = taskKey[Unit]("Updates the project website on tickle")
ThisBuild / organization := "com.mchange"
ThisBuild / version := "0.6.0-SNAPSHOT"
ThisBuild / resolvers += ("releases" at nexusStaging)
ThisBuild / resolvers += ("snapshots" at nexusSnapshots)
ThisBuild / resolvers += ("Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/")
ThisBuild / publishTo := {
if (isSnapshot.value) Some("snapshots" at nexusSnapshots ) else Some("staging" at nexusStaging )
}
ThisBuild / scalaVersion := "2.12.13"
ThisBuild / scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-unchecked" /*,
"-Xlog-implicits" */
)
val consuelaArtifact : ModuleID = "com.mchange" %% "consuela" % "0.5.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(ParadoxPlugin).settings (
name := "sbt-ethereum",
sbtPlugin := true,
libraryDependencies ++= Seq(
consuelaArtifact,
"com.mchange" %% "ens-scala" % "0.5.0-SNAPSHOT",
"com.mchange" %% "etherscan-utils" % "0.1.0",
"com.mchange" %% "mlog-scala" % "0.3.13",
"com.mchange" %% "literal" % "0.1.0",
"com.mchange" %% "danburkert-continuum" % "0.3.99",
"com.mchange" %% "texttable" % "0.0.2",
"com.mchange" % "mchange-commons-java" % "0.2.20",
"com.mchange" % "c3p0" % "0.9.5.5",
"com.h2database" % "h2" % "1.4.192",
"ch.qos.logback" % "logback-classic" % "1.1.7",
"com.google.code.gson" % "gson" % "2.8.6", // yuk, but for ABI scraping (and only that) we need a parser lenient in the way GSON's can be setup to be, and I can't make play-json / jackson
"org.unbescape" % "unbescape" % "1.1.6.RELEASE", // also for scraping ABIs from entity-encoded HTML
"io.bullet" %% "borer-core" % "1.6.3" // parse CBOR metadata at the end of solidity compilations
),
sourceGenerators in Compile += generateBuildInfoSourceGeneratorTask,
paradoxTheme := None,
paradoxNavigationDepth := 3,
consuelaApiBase := {
val cVersion = consuelaArtifact.revision
s"https://www.mchange.com/projects/consuela/version/${cVersion}/apidocs"
},
packageOptions in (Compile, packageBin) += {
import java.util.jar.{Attributes, Manifest}
val manifest = new Manifest
val entries = manifest.getEntries()
def seal( pkgpath : String ) = {
entries.put(pkgpath, new Attributes())
manifest.getAttributes(pkgpath).put(Attributes.Name.SEALED, "true")
}
val bp = "com/mchange/sc/v1/sbtethereum/"
val pkgpaths = Seq(
bp,
bp + "shoebox/",
bp + "util/",
bp + "testing/",
bp + "compile/",
bp + "lib/",
bp + "api/",
bp + "signer/",
)
pkgpaths.foreach( seal )
Package.JarManifest( manifest )
},
paradoxProperties += ("scaladoc.com.mchange.sc.v1.consuela.base_url" -> consuelaApiBase.value),
updateSite := {
import scala.sys.process._
val dummy = (Compile / paradox).value // force a build of the site
val localDir = target.value / "paradox" / "site" / "main"
val local = localDir.listFiles.map( _.getPath ).mkString(" ")
val remote = s"tickle.mchange.com:/home/web/public/www.sbt-ethereum.io/version/${version.value}/"
s"rsync -avz ${local} ${remote}"!
},
pomExtra := pomExtraForProjectName( name.value )
)
// embed build-time information into a package object for com.mchange.sc.v1.sbtethereum.generated
val generatedCodePackageDir = Vector( "com", "mchange", "sc", "v1", "sbtethereum", "generated" )
val generateBuildInfoSourceGeneratorTask = Def.task{
import java.io._
import java.nio.file.Files
import scala.io.Codec
import java.time._
import java.time.format._
val srcManaged = (sourceManaged in Compile).value
val sbtEthVersion = version.value
val consuelaOrg = consuelaArtifact.organization
val consuelaName = consuelaArtifact.name
val consuelaVersion = consuelaArtifact.revision
val consuelaMaybeChanging = if (consuelaVersion.endsWith("SNAPSHOT")) " changing()" else ""
val ts = DateTimeFormatter.RFC_1123_DATE_TIME.withZone( ZoneId.systemDefault() ).format(java.time.Instant.now)
val sep = File.separator
val outDir = new File( srcManaged, generatedCodePackageDir.mkString( sep ) )
val outFile = new File( outDir, "package.scala" )
val contents = {
s"""|package ${generatedCodePackageDir.init.mkString(".")}
|
|package object ${generatedCodePackageDir.last} {
| final object SbtEthereum {
| val Version = "${sbtEthVersion}"
| val BuildTimestamp = "${ts}"
| }
| final object Consuela {
| import sbt._
| val ModuleID = "${consuelaOrg}" %% "${consuelaName}" % "${consuelaVersion}"${consuelaMaybeChanging}
| }
|}""".stripMargin
}
outDir.mkdirs()
Files.write( outFile.toPath, contents.getBytes( Codec.UTF8.charSet ) )
outFile :: Nil
}
// publication, pom extra stuff
def pomExtraForProjectName( projectName : String ) = {
<url>https://github.com/swaldman/{projectName}</url>
<licenses>
<license>
<name>GNU Lesser General Public License, Version 2.1</name>
<url>http://www.gnu.org/licenses/lgpl-2.1.html</url>
<distribution>repo</distribution>
</license>
<license>
<name>Eclipse Public License, Version 1.0</name>
<url>http://www.eclipse.org/org/documents/epl-v10.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>[email protected]:swaldman/{projectName}.git</url>
<connection>scm:git:[email protected]:swaldman/{projectName}</connection>
</scm>
<developers>
<developer>
<id>swaldman</id>
<name>Steve Waldman</name>
<email>[email protected]</email>
</developer>
</developers>
}