Skip to content

Commit

Permalink
[jdbc-scala] Cross build for Scala 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed May 1, 2014
1 parent 10a23da commit 363aab2
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 24 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.17

Cross compilation from Scala 2.10 to 2.11.

## 1.0.16 ## 1.0.16


([2a2093606f5c4582efa2fea4aa18de357f4b8a1c](https://github.com/cchantep/acolyte/commit/2a2093606f5c4582efa2fea4aa18de357f4b8a1c) @ [jdbc-driver](https://github.com/cchantep/acolyte/tree/master/jdbc-driver)) Batch support on statement and prepared statement. ([2a2093606f5c4582efa2fea4aa18de357f4b8a1c](https://github.com/cchantep/acolyte/commit/2a2093606f5c4582efa2fea4aa18de357f4b8a1c) @ [jdbc-driver](https://github.com/cchantep/acolyte/tree/master/jdbc-driver)) Batch support on statement and prepared statement.
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public T withQueryDetection(final String... pattern) {
* @param pattern Query detection pattern * @param pattern Query detection pattern
* @throws IllegalArgumentException if pattern is null * @throws IllegalArgumentException if pattern is null
*/ */
public abstract T withQueryDetection(final Pattern... pattern); public abstract T withQueryDetection(final Pattern[] pattern);


/** /**
* Appends given |pattern| to current query detection. * Appends given |pattern| to current query detection.
Expand Down
2 changes: 1 addition & 1 deletion jdbc-scala/src/main/scala/Acolyte.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ final class ScalaCompositeHandler(qd: Array[Pattern], qh: QueryHandler, uh: Upda
* handleStatement.withQueryDetection("^SELECT ", "EXEC proc") * handleStatement.withQueryDetection("^SELECT ", "EXEC proc")
* }}} * }}}
*/ */
def withQueryDetection(pattern: Pattern*) = new ScalaCompositeHandler( def withQueryDetection(pattern: Array[Pattern]) = new ScalaCompositeHandler(
queryDetectionPattern(pattern: _*), queryHandler, updateHandler) queryDetectionPattern(pattern: _*), queryHandler, updateHandler)


/** /**
Expand Down
5 changes: 3 additions & 2 deletions project/Acolyte.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ object Acolyte extends Build with Dependencies
aggregate(jdbcDriver, scalacPlugin, jdbcScala, studio). aggregate(jdbcDriver, scalacPlugin, jdbcScala, studio).
settings( settings(
organization in ThisBuild := "org.eu.acolyte", organization in ThisBuild := "org.eu.acolyte",
version in ThisBuild := "1.0.16-2", version in ThisBuild := "1.0.17",
javaOptions in ThisBuild ++= Seq("-source", "1.6", "-target", "1.6"), javaOptions in ThisBuild ++= Seq("-source", "1.6", "-target", "1.6"),
scalaVersion in ThisBuild := "2.10.3", scalaVersion in ThisBuild := "2.10.3",
crossScalaVersions in ThisBuild := Seq("2.10.4", "2.11.0"),
publishTo in ThisBuild := Some(Resolver.file("file", publishTo in ThisBuild := Some(Resolver.file("file",
new File(Path.userHome.absolutePath+"/.m2/repository"))), new File(Path.userHome.absolutePath+"/.m2/repository"))),
pomExtra in ThisBuild := ( pomExtra in ThisBuild := (
Expand Down Expand Up @@ -49,5 +50,5 @@ object Acolyte extends Build with Dependencies
} }


trait Dependencies { trait Dependencies {
val specs2Test = "org.specs2" %% "specs2" % "2.3.8" % "test" val specs2Test = "org.specs2" %% "specs2" % "2.3.11" % "test"
} }
6 changes: 5 additions & 1 deletion project/JdbcScala.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ trait JdbcScala { deps: Dependencies ⇒
zip(baseDirectory in (scalacPlugin, Compile)). zip(baseDirectory in (scalacPlugin, Compile)).
zip(name in (scalacPlugin, Compile)) map { d => zip(name in (scalacPlugin, Compile)) map { d =>
val (((v, sv), b), n) = d val (((v, sv), b), n) = d
val msv = if (sv startsWith "2.10") "2.10" else sv val msv =
if (sv startsWith "2.10") "2.10"
else if (sv startsWith "2.11") "2.11"
else sv

val td = b / "target" / "scala-%s".format(msv) val td = b / "target" / "scala-%s".format(msv)
val j = td / "%s_%s-%s.jar".format(n, msv, v) val j = td / "%s_%s-%s.jar".format(n, msv, v)


Expand Down
6 changes: 5 additions & 1 deletion project/ScalacPlugin.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ trait ScalacPlugin { deps: Dependencies ⇒
zip(scalaVersion in ThisBuild).zip(baseDirectory in Compile). zip(scalaVersion in ThisBuild).zip(baseDirectory in Compile).
zip(name in Compile) map { d => zip(name in Compile) map { d =>
val (((v, sv), b), n) = d val (((v, sv), b), n) = d
val msv = if (sv startsWith "2.10") "2.10" else sv val msv =
if (sv startsWith "2.10") "2.10"
else if (sv startsWith "2.11") "2.11"
else sv

val td = b / "target" / "scala-%s".format(msv) val td = b / "target" / "scala-%s".format(msv)
val j = td / "%s_%s-%s.jar".format(n, msv, v) val j = td / "%s_%s-%s.jar".format(n, msv, v)


Expand Down
14 changes: 8 additions & 6 deletions readme.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -931,17 +931,19 @@ mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-driver/target/jdbc-dr
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-driver/target/jdbc-driver-$VERSION.pom -Dfile=jdbc-driver/target/jdbc-driver-$VERSION-sources.jar -Dclassifier=sources -Durl=$REPO -DrepositoryId=sonatype-nexus-staging mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-driver/target/jdbc-driver-$VERSION.pom -Dfile=jdbc-driver/target/jdbc-driver-$VERSION-sources.jar -Dclassifier=sources -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-scala/target/scala-2.10/jdbc-scala_2.10-$VERSION.pom -Dfile=jdbc-scala/target/scala-2.10/jdbc-scala_2.10-$VERSION.jar -Durl=$REPO -DrepositoryId=sonatype-nexus-staging export SCALAVER="2.10"
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-scala/target/scala-2.10/jdbc-scala_2.10-$VERSION.pom -Dfile=jdbc-scala/target/scala-2.10/jdbc-scala_2.10-$VERSION-javadoc.jar -Dclassifier=javadoc -Durl=$REPO -DrepositoryId=sonatype-nexus-staging mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-scala/target/scala-$SCALAVER/jdbc-scala_$SCALAVER-$VERSION.pom -Dfile=jdbc-scala/target/scala-$SCALAVER/jdbc-scala_$SCALAVER-$VERSION.jar -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-scala/target/scala-2.10/jdbc-scala_2.10-$VERSION.pom -Dfile=jdbc-scala/target/scala-2.10/jdbc-scala_2.10-$VERSION-sources.jar -Dclassifier=sources -Durl=$REPO -DrepositoryId=sonatype-nexus-staging mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-scala/target/scala-$SCALAVER/jdbc-scala_$SCALAVER-$VERSION.pom -Dfile=jdbc-scala/target/scala-$SCALAVER/jdbc-scala_$SCALAVER-$VERSION-javadoc.jar -Dclassifier=javadoc -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scalac-plugin/target/scala-2.10/scalac-plugin_2.10-$VERSION.pom -Dfile=scalac-plugin/target/scala-2.10/scalac-plugin_2.10-$VERSION.jar -Durl=$REPO -DrepositoryId=sonatype-nexus-staging mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=jdbc-scala/target/scala-$SCALAVER/jdbc-scala_$SCALAVER-$VERSION.pom -Dfile=jdbc-scala/target/scala-$SCALAVER/jdbc-scala_$SCALAVER-$VERSION-sources.jar -Dclassifier=sources -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scalac-plugin/target/scala-2.10/scalac-plugin_2.10-$VERSION.pom -Dfile=scalac-plugin/target/scala-2.10/scalac-plugin_2.10-$VERSION-javadoc.jar -Dclassifier=javadoc -Durl=$REPO -DrepositoryId=sonatype-nexus-staging mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scalac-plugin/target/scala-$SCALAVER/scalac-plugin_$SCALAVER-$VERSION.pom -Dfile=scalac-plugin/target/scala-$SCALAVER/scalac-plugin_$SCALAVER-$VERSION.jar -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scalac-plugin/target/scala-2.10/scalac-plugin_2.10-$VERSION.pom -Dfile=scalac-plugin/target/scala-2.10/scalac-plugin_2.10-$VERSION-sources.jar -Dclassifier=sources -Durl=$REPO -DrepositoryId=sonatype-nexus-staging mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scalac-plugin/target/scala-$SCALAVER/scalac-plugin_$SCALAVER-$VERSION.pom -Dfile=scalac-plugin/target/scala-$SCALAVER/scalac-plugin_$SCALAVER-$VERSION-javadoc.jar -Dclassifier=javadoc -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scalac-plugin/target/scala-$SCALAVER/scalac-plugin_$SCALAVER-$VERSION.pom -Dfile=scalac-plugin/target/scala-$SCALAVER/scalac-plugin_$SCALAVER-$VERSION-sources.jar -Dclassifier=sources -Durl=$REPO -DrepositoryId=sonatype-nexus-staging
``` ```
Authentication should be configured in `~/.m2/settings.xml`: Authentication should be configured in `~/.m2/settings.xml`:
Expand Down
6 changes: 6 additions & 0 deletions scalac-plugin/readme.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -165,4 +165,10 @@ If there result from given extractor factory is not a valid extract, it will rai
``` ```
[error] /path/to/file.scala#refactored-match-M:1: value Xtr0 is not a case class constructor, nor does it have an unapply/unapplySeq method [error] /path/to/file.scala#refactored-match-M:1: value Xtr0 is not a case class constructor, nor does it have an unapply/unapplySeq method
[error] case Xtr1((a @ _)) => Nil // generated from ln L, col C [error] case Xtr1((a @ _)) => Nil // generated from ln L, col C
```

When using `~(Xtractor(params))`, following error can be raised if `unapply` from `Xtractor` wait at least one argument.

```
[error] /path/to/file.scala#refactored-match-M:1: not enough patterns for class Clazz offering Xtractor: expected 1, found 0
``` ```
14 changes: 9 additions & 5 deletions scalac-plugin/src/main/scala/acolyte/AcolytePlugin.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AcolytePlugin(val global: Global) extends Plugin {
val description = "Syntax extensions: Extractors with arguments" val description = "Syntax extensions: Extractors with arguments"
val components = List[PluginComponent](ExtractorComponent) val components = List[PluginComponent](ExtractorComponent)


var debug: Boolean with NotNull = false var debug: Boolean = false


override def processOptions(options: List[String], error: String Unit) { override def processOptions(options: List[String], error: String Unit) {
for (o options) { for (o options) {
Expand All @@ -27,9 +27,12 @@ class AcolytePlugin(val global: Global) extends Plugin {
override val runsBefore = List[String]("typer") override val runsBefore = List[String]("typer")
val phaseName = "rich-patmat" val phaseName = "rich-patmat"


def newTransformer(unit: global.CompilationUnit) = MatchTransformer def newTransformer(unit: global.CompilationUnit) =
new MatchTransformer(unit)

class MatchTransformer(
unit: global.CompilationUnit) extends global.Transformer {


object MatchTransformer extends global.Transformer {
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
import global.{ import global.{
//abort, //abort,
Expand Down Expand Up @@ -129,19 +132,20 @@ class AcolytePlugin(val global: Global) extends Plugin {


@inline private def refactorPattern[T](xp: Position, ex: Tree, xa: List[Tree], ua: List[Tree]): (ValDef, Apply) = { @inline private def refactorPattern[T](xp: Position, ex: Tree, xa: List[Tree], ua: List[Tree]): (ValDef, Apply) = {


import global.{ atPos, show, Ident, Modifiers } import global.{ atPos, show, newTermName, Ident, Modifiers }


val of = xp.source.file val of = xp.source.file
val file = new VirtualFile(of.name, val file = new VirtualFile(of.name,
s"${of.path}#refactored-match-${xp.line}") s"${of.path}#refactored-match-${xp.line}")


// ValDef // ValDef
val xn = global.treeBuilder.freshTermName("Xtr") val xn = unit.freshTermName("Xtr")
val vd = ValDef(Modifiers(), xn, global.TypeTree(), Apply(ex, xa)) val vd = ValDef(Modifiers(), xn, global.TypeTree(), Apply(ex, xa))
val vdc = val vdc =
s"${show(vd)} // generated from ln ${xp.line}, col ${xp.column - 1}" s"${show(vd)} // generated from ln ${xp.line}, col ${xp.column - 1}"


val vdp = xp.withPoint(0).withSource(new BatchSourceFile(file, vdc), 0) val vdp = xp.withPoint(0).withSource(new BatchSourceFile(file, vdc), 0)
// TODO: Scala 2.11 -> withSource(new BatchSourceFile(file, vdc))


(atPos(vdp)(vd), Apply(Ident(xn), ua)) (atPos(vdp)(vd), Apply(Ident(xn), ua))
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
package acolyte package acolyte


object ExtractorComponentSpec extends org.specs2.mutable.Specification object ExtractorComponentSpec extends org.specs2.mutable.Specification
with MatchTest with PartialFunctionTest { with MatchTest with PartialFunctionTest {


"Extractor component" title "Extractor component" title
Expand Down Expand Up @@ -157,7 +157,7 @@ object ExtractorComponentSpec extends org.specs2.mutable.Specification


sealed trait PartialFunctionTest { sealed trait PartialFunctionTest {
val partialFun1: String List[String] = { val partialFun1: String List[String] = {
case ~(IntRange(5, 10)) List("5-to-10") case ~(IntRange(5, 10), _) List("5-to-10")
case ~(IntRange(10, 20), i) List(s"range:$i") case ~(IntRange(10, 20), i) List(s"range:$i")
case Integer(n) List(s"num-$n") case Integer(n) List(s"num-$n")
case ~(Regex("^a.*")) List("no-binding") case ~(Regex("^a.*")) List("no-binding")
Expand All @@ -166,7 +166,7 @@ sealed trait PartialFunctionTest {
} }


def partialFun2: String List[String] = { def partialFun2: String List[String] = {
case ~(IntRange(5, 10)) List("5-to-10") case ~(IntRange(5, 10), _) List("5-to-10")
case ~(IntRange(10, 20), i) List(s"range:$i") case ~(IntRange(10, 20), i) List(s"range:$i")
case Integer(n) List(s"num-$n") case Integer(n) List(s"num-$n")
case ~(Regex("^a.*")) List("no-binding") case ~(Regex("^a.*")) List("no-binding")
Expand All @@ -176,7 +176,7 @@ sealed trait PartialFunctionTest {


/* Anonymous partial function */ /* Anonymous partial function */
def partialFun3(s: Option[String]): Option[List[String]] = s map { def partialFun3(s: Option[String]): Option[List[String]] = s map {
case ~(IntRange(5, 10)) List("5-to-10") case ~(IntRange(5, 10), _) List("5-to-10")
case ~(IntRange(10, 20), i) List(s"range:$i") case ~(IntRange(10, 20), i) List(s"range:$i")
case Integer(n) List(s"num-$n") case Integer(n) List(s"num-$n")
case ~(Regex("^a.*")) List("no-binding") case ~(Regex("^a.*")) List("no-binding")
Expand All @@ -187,7 +187,7 @@ sealed trait PartialFunctionTest {


sealed trait MatchTest { sealed trait MatchTest {
def patternMatching(s: String): List[String] = s match { def patternMatching(s: String): List[String] = s match {
case ~(IntRange(5, 10)) List("5-to-10") case ~(IntRange(5, 10), _) List("5-to-10")
case ~(IntRange(10, 20), i) List(s"range:$i") case ~(IntRange(10, 20), i) List(s"range:$i")
case Integer(n) List(s"num-$n") case Integer(n) List(s"num-$n")
case ~(Regex("^a.*")) List("no-binding") case ~(Regex("^a.*")) List("no-binding")
Expand Down
2 changes: 1 addition & 1 deletion site.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.eu.acolyte</groupId> <groupId>org.eu.acolyte</groupId>
<artifactId>acolyte</artifactId> <artifactId>acolyte</artifactId>
<version>1.0.16</version> <version>1.0.17</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Acolyte</name> <name>Acolyte</name>


Expand Down
2 changes: 1 addition & 1 deletion studio/pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<artifactId>studio</artifactId> <artifactId>studio</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Acolyte Studio</name> <name>Acolyte Studio</name>
<version>1.0.16</version> <version>1.0.17</version>
<url>https://github.com/cchantep/acolyte/</url> <url>https://github.com/cchantep/acolyte/</url>


<scm> <scm>
Expand Down

0 comments on commit 363aab2

Please sign in to comment.