Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to scala2.12 #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea/
.idea_modules/
target/
.bloop/
.metals/
project/metals.sbt
69 changes: 41 additions & 28 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra whitespace.

import scalariform.formatter.preferences._

name := "scala-migrations"

Expand All @@ -18,7 +19,7 @@ licenses += "New BSD License" -> url("http://opensource.org/licenses/BSD-3-Claus

version := "1.1.2-SNAPSHOT"

scalaVersion := "2.10.3"
scalaVersion := "2.12.8"

// For a single major Scala release, e.g. 2.x.y, include at most one
// Scala release candidate in crossScalaVersions, e.g. "2.x.y-RC3".
Expand All @@ -28,7 +29,17 @@ crossScalaVersions := Seq("2.9.0", "2.9.0-1",
"2.9.1", "2.9.1-1",
"2.9.2", "2.9.3",
"2.10.3",
"2.11.0-M7")
"2.11.0-M7", "2.12.8")

// resolvers in Global ++= Seq(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't include commented out lines in general. What is the intention of this?

// Resolver.mavenLocal,
// Resolver.bintrayRepo("vpon", "maven"),
// "maven" at "https://mvnrepository.com",
// "twitter-repo" at "http://maven.twttr.com",
// "vpon release" at "http://nexus.vpon.com/content/repositories/releases/",
// "vpon snapshot" at "http://nexus.vpon.com/content/repositories/snapshots/",
// "vpon dev" at "http://nexus.vpon.com/content/repositories/developments/"
// )

// Increase warnings generated by the Scala compiler.
//
Expand All @@ -39,27 +50,29 @@ crossScalaVersions := Seq("2.9.0", "2.9.0-1",
// conversions and to maintain source compatibility so that separate
// branches are not needed, pass "-language:implicitConversions" so
// that "-feature" can be used without generating spurious warnings.
scalacOptions <++= scalaVersion map { v: String =>
val options1 = "-deprecation" :: "-unchecked" :: Nil
if (v.startsWith("2.9.0")) {
options1
}
else {
val options2 = "-Xlint" :: options1
if (v.startsWith("2.9"))
options2
else
"-feature" :: "-language:implicitConversions" :: options2
}
}
// scalacOptions <++= scalaVersion map { v: String =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete commented out code.

// val options1 = "-deprecation" :: "-unchecked" :: Nil
// if (v.startsWith("2.9.0")) {
// options1
// }
// else {
// val options2 = "-Xlint" :: options1
// if (v.startsWith("2.9"))
// options2
// else
// "-feature" :: "-language:implicitConversions" :: options2
// }
// }

libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.10-M4" % "test",
"log4jdbc" % "log4jdbc" % "1.1" from "http://log4jdbc.googlecode.com/files/log4jdbc4-1.1.jar",
// "com.googlecode.log4jdbc" % "log4jdbc" % "1.2",
"log4jdbc" % "log4jdbc" % "1.1" from "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/log4jdbc/log4jdbc4-1.1.jar",
"mysql" % "mysql-connector-java" % "[5.1.0,5.2)" % "test",
"org.apache.derby" % "derby" % "[10.5.3.0,11.0)" % "test",
// "org.apache.derby" % "derby" % "[10.5.3.0,11.0)" % "test",
"org.apache.derby" % "derby" % "10.5.3.0_1" % "test",
"org.hamcrest" % "hamcrest-core" % "1.3" % "test",
"org.jmock" % "jmock-junit4" % "[2.5.1,3.0)" % "test",
"org.jmock" % "jmock-junit4" % "2.12.0" % "test", //[2.5.1,3.0)
"org.slf4j" % "slf4j-api" % "[1.5.8,2.0)",
"org.slf4j" % "slf4j-log4j12" % "[1.5.8,2.0)" % "test",
"postgresql" % "postgresql" % "9.1-901.jdbc4" % "test")
Expand All @@ -71,12 +84,12 @@ parallelExecution in Test := false

testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")

scalariformSettings
// scalariformSettings

ScalariformKeys.preferences := FormattingPreferences().
setPreference(AlignParameters, true).
setPreference(CompactControlReadability, true).
setPreference(DoubleIndentClassDeclaration, true)
ScalariformKeys.preferences := FormattingPreferences().
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra whitespace.

setPreference(AlignParameters, true).
setPreference(CompactControlReadability, true).
setPreference(DoubleIndentClassDeclaration, true)

publishMavenStyle := true

Expand Down Expand Up @@ -123,14 +136,14 @@ pomPostProcess := { (node: scala.xml.Node) =>
transformer.transform(node)(0)
}

publishTo <<= version { (v: String) =>
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

useGpg := true
useGpg := true

useGpgAgent := true
useGpgAgent := true
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.0
sbt.version=1.1.6
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
// addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.5.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
53 changes: 33 additions & 20 deletions src/main/scala/com/imageworks/migration/ColumnDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ abstract class ColumnDefinition {
options = options filter { _ ne option }

if (isAutoIncrement) {
logger.warn("Redundant AutoIncrement specified for the '{}' column.",
logger.warn(
"Redundant AutoIncrement specified for the '{}' column.",
getColumnName)
}
isAutoIncrement = true
Expand All @@ -205,8 +206,9 @@ abstract class ColumnDefinition {
options = options filter { _ ne option }

if (default.isDefined && default.get != value) {
logger.warn("Redefining the default value for the '{}' column " +
"from '{}' to '{}'.",
logger.warn(
"Redefining the default value for the '{}' column " +
"from '{}' to '{}'.",
Array[AnyRef](getColumnName, default.get, value): _*)
}
default = Some(value)
Expand All @@ -232,8 +234,9 @@ abstract class ColumnDefinition {
options = options filter { _ ne option }

if (_limitOpt.isDefined && _limitOpt.get != length) {
logger.warn("Redefining the limit for the '{}' column " +
"from '{}' to '{}'.",
logger.warn(
"Redefining the limit for the '{}' column " +
"from '{}' to '{}'.",
Array[AnyRef](getColumnName, _limitOpt.get, length): _*)
}
_limitOpt = Some(length)
Expand All @@ -256,9 +259,11 @@ abstract class ColumnDefinition {
options = options filter { _ ne option }

if (n1.isDefined && n1 != n2) {
logger.warn("Redefining the '{}' column's nullability " +
"from {} to {}.",
Array[AnyRef](getColumnName,
logger.warn(
"Redefining the '{}' column's nullability " +
"from {} to {}.",
Array[AnyRef](
getColumnName,
if (n1.get) "NOT NULL" else "NULL",
if (n2.get) "NOT NULL" else "NULL"): _*)
}
Expand Down Expand Up @@ -302,9 +307,11 @@ abstract class ColumnDefinition {
options = options filter { _ ne option }

if (_precisionOpt.isDefined && _precisionOpt.get != value) {
logger.warn("Redefining the precision for the '{}' column " +
"from '{}' to '{}'.",
Array[AnyRef](getColumnName,
logger.warn(
"Redefining the precision for the '{}' column " +
"from '{}' to '{}'.",
Array[AnyRef](
getColumnName,
java.lang.Integer.valueOf(_precisionOpt.get),
java.lang.Integer.valueOf(value)): _*)
}
Expand All @@ -331,9 +338,11 @@ abstract class ColumnDefinition {
options = options filter { _ ne option }

if (_scaleOpt.isDefined && _scaleOpt.get != value) {
logger.warn("Redefining the scale for the '{}' column " +
"from '{}' to '{}'.",
Array[AnyRef](getColumnName,
logger.warn(
"Redefining the scale for the '{}' column " +
"from '{}' to '{}'.",
Array[AnyRef](
getColumnName,
java.lang.Integer.valueOf(_scaleOpt.get),
java.lang.Integer.valueOf(value)): _*)
}
Expand Down Expand Up @@ -383,8 +392,9 @@ abstract class ColumnDefinition {

if (getAdapter.supportsCheckConstraints) {
for (option <- options) {
def appendCheckSql(name: String,
expr: String) {
def appendCheckSql(
name: String,
expr: String) {
options = options filter { _ ne option }

sb.append(" CONSTRAINT ")
Expand All @@ -400,7 +410,8 @@ abstract class ColumnDefinition {
}

case Check(expr) => {
val tbd = new TableColumnDefinition(getTableName,
val tbd = new TableColumnDefinition(
getTableName,
Array(getColumnName))
val on = new On(tbd)
val (name, _) = getAdapter.generateCheckConstraintName(on)
Expand All @@ -415,7 +426,8 @@ abstract class ColumnDefinition {

// Warn for any unused options.
if (!options.isEmpty) {
logger.warn("The following options for the '{}' column are unused: {}.",
logger.warn(
"The following options for the '{}' column are unused: {}.",
Array[AnyRef](getColumnName, options): _*)
}

Expand Down Expand Up @@ -447,8 +459,9 @@ abstract class ColumnDefinition {
* @return the column type name with the limit syntax if a limit was
* given
*/
protected def optionallyAddLimitToDataType(columnTypeName: String,
limitOpt: Option[String]): String = {
protected def optionallyAddLimitToDataType(
columnTypeName: String,
limitOpt: Option[String]): String = {
limitOpt match {
case Some(l) => columnTypeName + "(" + l + ")"
case None => columnTypeName
Expand Down
19 changes: 11 additions & 8 deletions src/main/scala/com/imageworks/migration/ConnectionBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ import javax.sql.DataSource
* Adapter class for getting a Connection from either the
* DriverManager or a DataSource.
*/
class ConnectionBuilder private (either: Either[DataSource, String],
loginOpt: Option[(String, String)]) {
class ConnectionBuilder private (
either: Either[DataSource, String],
loginOpt: Option[(String, String)]) {
/**
* Construct a connection builder for a database that does not need
* a username and password.
Expand All @@ -63,9 +64,10 @@ class ConnectionBuilder private (either: Either[DataSource, String],
* @param password the password associated with the database
* username
*/
def this(url: String,
username: String,
password: String) {
def this(
url: String,
username: String,
password: String) {
this(Right(url), Some((username, password)))
}

Expand All @@ -89,9 +91,10 @@ class ConnectionBuilder private (either: Either[DataSource, String],
* @param password the password associated with the database
* username
*/
def this(datasource: DataSource,
username: String,
password: String) {
def this(
datasource: DataSource,
username: String,
password: String) {
this(Left(datasource), Some((username, password)))
}

Expand Down
Loading