@@ -3,25 +3,31 @@ import java.nio.charset.StandardCharsets
3
3
import sbt .Keys ._
4
4
import sbt ._
5
5
6
- object VertxScalaBuild extends Build {
6
+ object Variables {
7
+ val org = " io.vertx"
8
+ val name = " mod-mysql-postgresql"
9
+ val version = " 0.3.0-SNAPSHOT"
10
+ val scalaVersion = " 2.10.4"
11
+ val crossScalaVersions = Seq (" 2.10.4" , " 2.11.2" )
12
+ val description = " Fully async MySQL / PostgreSQL module for Vert.x"
13
+ }
7
14
8
- val baseSettings = Defaults .defaultSettings ++ Seq (
9
- organization := " io.vertx" ,
10
- name := " mod-mysql-postgresql" ,
11
- version := " 0.3.0-SNAPSHOT" ,
12
- scalaVersion := " 2.10.4" ,
13
- crossScalaVersions := Seq (" 2.10.4" , " 2.11.2" ),
14
- description := " Fully async MySQL / PostgreSQL module for Vert.x"
15
- )
15
+ object VertxScalaBuild extends Build {
16
16
17
17
lazy val project = Project (
18
18
" project" ,
19
19
file(" ." ),
20
- settings = baseSettings ++ Seq (
20
+ settings = Seq (
21
+ organization := Variables .org,
22
+ name := Variables .name,
23
+ version := Variables .version,
24
+ scalaVersion := Variables .scalaVersion,
25
+ crossScalaVersions := Variables .crossScalaVersions,
26
+ description := Variables .description,
21
27
copyModTask,
22
28
zipModTask,
23
- libraryDependencies ++ = Dependencies .compile,
24
- libraryDependencies <+= scalaVersion(" org.scala-lang" % " scala-compiler" % _),
29
+ libraryDependencies : = Dependencies .compile,
30
+ // libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _),
25
31
// Fork JVM to allow Scala in-flight compilation tests to load the Scala interpreter
26
32
fork in Test := true ,
27
33
// Vert.x tests are not designed to run in paralell
@@ -35,11 +41,12 @@ object VertxScalaBuild extends Build {
35
41
resourceGenerators in Compile += Def .task {
36
42
val file = (resourceManaged in Compile ).value / " langs.properties"
37
43
val contents = s " scala=io.vertx~lang-scala_ ${getMajor(scalaVersion.value)}~ ${Dependencies .Versions .vertxLangScalaVersion}:org.vertx.scala.platform.impl.ScalaVerticleFactory \n .scala=scala \n "
38
- IO .write(file, contents)
44
+ IO .write(file, contents, StandardCharsets . UTF_8 )
39
45
Seq (file)
40
46
}.taskValue,
41
- copyMod <<= copyMod dependsOn (compile in Compile ),
47
+ copyMod <<= copyMod dependsOn (copyResources in Compile ),
42
48
(test in Test ) <<= (test in Test ) dependsOn copyMod,
49
+ zipMod <<= zipMod dependsOn copyMod,
43
50
(packageBin in Compile ) <<= (packageBin in Compile ) dependsOn copyMod,
44
51
// Publishing settings
45
52
publishMavenStyle := true ,
@@ -78,7 +85,7 @@ object VertxScalaBuild extends Build {
78
85
</developer >
79
86
</developers >
80
87
)
81
- ).settings(addArtifact(Artifact (" lang-scala " , " zip" , " zip" , " mod" ), zipMod).settings: _* )
88
+ ).settings(addArtifact(Artifact (Variables .name , " zip" , " zip" , " mod" ), zipMod).settings: _* )
82
89
83
90
val copyMod = TaskKey [Unit ](" copy-mod" , " Assemble the module into the local mods directory" )
84
91
val zipMod = TaskKey [File ](" zip-mod" , " Package the module .zip file" )
@@ -88,7 +95,7 @@ object VertxScalaBuild extends Build {
88
95
val modOwner = organization.value
89
96
val modName = name.value
90
97
val modVersion = version.value
91
- val scalaMajor = scalaVersion.value.substring( 0 , scalaVersion.value.lastIndexOf( '.' ) )
98
+ val scalaMajor = getMajor( scalaVersion.value)
92
99
val moduleName = s " $modOwner~ ${modName}_ $scalaMajor~ $modVersion"
93
100
log.info(" Create module " + moduleName)
94
101
val moduleDir = target.value / " mods" / moduleName
@@ -108,7 +115,7 @@ object VertxScalaBuild extends Build {
108
115
val modOwner = organization.value
109
116
val modName = name.value
110
117
val modVersion = version.value
111
- val scalaMajor = scalaVersion.value.substring( 0 , scalaVersion.value.lastIndexOf( '.' ) )
118
+ val scalaMajor = getMajor( scalaVersion.value)
112
119
val moduleName = s " $modOwner~ ${modName}_ $scalaMajor~ $modVersion"
113
120
log.info(" Create ZIP module " + moduleName)
114
121
val moduleDir = target.value / " mods" / moduleName
@@ -155,24 +162,32 @@ object Dependencies {
155
162
156
163
val vertxCore = " io.vertx" % " vertx-core" % vertxVersion % " provided"
157
164
val vertxPlatform = " io.vertx" % " vertx-platform" % vertxVersion % " provided"
158
- val vertxTesttools = " io.vertx" % " testtools" % testtoolsVersion % " provided"
159
165
val vertxLangScala = " io.vertx" %% " lang-scala" % vertxLangScalaVersion % " provided"
160
- val postgreSqlDriver = " com.github.mauricio" %% " postgresql-async" % asyncDriverVersion % " provided"
161
- val mySqlDriver = " com.github.mauricio" %% " mysql-async" % asyncDriverVersion % " provided"
166
+ val postgreSqlDriver = (" com.github.mauricio" %% " postgresql-async" % asyncDriverVersion % " compile" ).excludeAll(
167
+ ExclusionRule (organization = " org.scala-lang" ),
168
+ ExclusionRule (organization = " io.netty" ),
169
+ ExclusionRule (organization = " org.slf4j" )
170
+ )
171
+ val mySqlDriver = (" com.github.mauricio" %% " mysql-async" % asyncDriverVersion % " compile" ). excludeAll(
172
+ ExclusionRule (organization = " org.scala-lang" ),
173
+ ExclusionRule (organization = " io.netty" ),
174
+ ExclusionRule (organization = " org.slf4j" )
175
+ )
162
176
}
163
177
164
178
object Test {
165
179
166
180
import Dependencies .Versions ._
167
181
182
+ val vertxTesttools = " io.vertx" % " testtools" % testtoolsVersion % " test"
168
183
val hamcrest = " org.hamcrest" % " hamcrest-library" % hamcrestVersion % " test"
169
184
val junitInterface = " com.novocode" % " junit-interface" % junitInterfaceVersion % " test"
170
185
}
171
186
172
187
import Dependencies .Compile ._
173
188
174
- val test = List (Test .hamcrest, Test .junitInterface)
189
+ val test = List (Test .vertxTesttools, Test . hamcrest, Test .junitInterface)
175
190
176
- val compile = List (vertxCore, vertxPlatform, vertxTesttools, vertxLangScala, postgreSqlDriver, mySqlDriver) ::: test
191
+ val compile = List (vertxCore, vertxPlatform, vertxLangScala, postgreSqlDriver, mySqlDriver) ::: test
177
192
178
193
}
0 commit comments