-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sbt
80 lines (73 loc) · 2.66 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
lazy val root = (project in file("."))
.settings(
organization := "org.scalikejdbc",
name := "csvquery",
version := "1.5.1-SNAPSHOT",
scalaVersion := "2.13.15",
crossScalaVersions := Seq("2.12.20", "2.13.15", "3.3.4"),
libraryDependencies ++= Seq(
"com.h2database" % "h2" % "2.2.224",
"org.scalikejdbc" %% "scalikejdbc" % "4.3.2",
"ch.qos.logback" % "logback-classic" % "1.2.13" % "provided",
"org.scalatest" %% "scalatest-funspec" % "3.2.19" % "test",
"org.scalatest" %% "scalatest-shouldmatchers" % "3.2.19" % "test"
),
Test / parallelExecution := false,
Test / logBuffered := false,
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
initialCommands := """
import scalikejdbc._
import csvquery._
Class.forName("org.h2.Driver")
implicit val session: DBSession = autoCSVSession
val csv = CSV("./sample.csv", Seq("name", "age"))
val count = withCSV(csv) { table =>
sql"select count(*) from $table".map(_.long(1)).single.apply().get
}
val records = withCSV(csv) { table =>
sql"select * from $table".toMap.list.apply()
}
case class Account(name: String, companyName: String, company: Option[Company])
case class Company(name: String, url: String)
val (accountsCsv, companiesCsv) = (
CSV("src/test/resources/accounts.csv", Seq("name", "company_name")),
CSV("src/test/resources/companies.csv", Seq("name", "url"))
)
val accounts: Seq[Account] = withCSV(accountsCsv, companiesCsv) { (a, c) =>
sql"select a.name, a.company_name, c.url from $a a left join $c c on a.company_name = c.name".map { rs =>
new Account(
name = rs.get("name"),
companyName = rs.get("company_name"),
company = rs.stringOpt("url").map(url => Company(rs.get("company_name"), url))
)
}.list.apply()
}
""",
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishMavenStyle := true,
pomIncludeRepository := { x => false },
pomExtra := <url>https://github.com/scalikejdbc/csvquery/</url>
<licenses>
<license>
<name>MIT License</name>
<url>https://www.opensource.org/licenses/mit-license</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:scalikejdbc/csvquery.git</url>
<connection>scm:git:git@github.com:scalikejdbc/csvquery.git</connection>
</scm>
<developers>
<developer>
<id>seratch</id>
<name>Kazuhiro Sera</name>
<url>https://git.io/sera</url>
</developer>
</developers>
)