|
1 |
| -version := "1.1.2" |
| 1 | +import sbtassembly.MergeStrategy |
2 | 2 |
|
3 |
| -scalaVersion := "2.13.15" |
| 3 | +name := "flink-scala" |
| 4 | +version := "1.1.3-SNAPSHOT" |
4 | 5 |
|
5 |
| -name := "flink-scala-2.13" |
| 6 | +val scala212 = "2.12.20" |
| 7 | +val scala213 = "2.13.16" |
6 | 8 |
|
7 |
| -lazy val flinkV = "1.16.2" |
8 |
| -lazy val scalaTestV = "3.2.17" |
| 9 | +scalaVersion := scala212 |
| 10 | +crossScalaVersions := List(scala212, scala213) |
9 | 11 |
|
| 12 | +val flinkV = settingKey[String]("Flink version") // to extract using `show flinkV` |
| 13 | +flinkV := "1.20.1" |
10 | 14 |
|
11 |
| -assembly / artifact := { |
12 |
| - val art = (assembly / artifact).value |
13 |
| - art.withClassifier(Some("assembly")) |
14 |
| -} |
| 15 | +lazy val scalaTestV = "3.2.19" |
15 | 16 |
|
16 |
| -addArtifact(assembly / artifact, assembly) |
| 17 | +lazy val assemblySettings = Seq( |
| 18 | + assembly / artifact := { |
| 19 | + val art = (assembly / artifact).value |
| 20 | + art.withClassifier(Some("assembly")) |
| 21 | + }, |
| 22 | + assembly / assemblyMergeStrategy := { |
| 23 | + case PathList(ps@_*) if ps.last == "module-info.class" => MergeStrategy.discard |
| 24 | + case x => MergeStrategy.defaultMergeStrategy(x) |
| 25 | + }, |
| 26 | + addArtifact(assembly / artifact, assembly) |
| 27 | +) |
17 | 28 |
|
18 | 29 | lazy val publishSettings = Seq(
|
19 | 30 | publishMavenStyle := true,
|
| 31 | + sonatypeCredentialHost := "central.sonatype.com", |
20 | 32 | publishTo := {
|
21 |
| - val defaultNexusUrl = "https://oss.sonatype.org/" |
22 |
| - if (isSnapshot.value) |
23 |
| - Some("snapshots" at defaultNexusUrl + "content/repositories/snapshots") |
24 |
| - else { |
25 |
| - sonatypePublishToBundle.value |
26 |
| - } |
| 33 | + if (isSnapshot.value) |
| 34 | + Some("snapshots" at "https://central.sonatype.com/repository/maven-snapshots/") |
| 35 | + else { |
| 36 | + sonatypePublishToBundle.value //todo: full release not tested yet |
| 37 | + } |
27 | 38 | },
|
28 | 39 | Test / publishArtifact := false,
|
29 | 40 | //We don't put scm information here, it will be added by release plugin and if scm provided here is different than the one from scm
|
30 | 41 | //we'll end up with two scm sections and invalid pom...
|
31 | 42 | pomExtra in Global := {
|
32 | 43 | <scm>
|
33 |
| - <connection>scm:git:github.com/TouK/flink-scala-2.13.git</connection> |
34 |
| - <developerConnection>scm:git:git@github.com:TouK/flink-scala-2.13.git</developerConnection> |
35 |
| - <url>github.com/TouK/flink-scala-2.13</url> |
| 44 | + <connection>scm:git:github.com/TouK/flink-scala.git</connection> |
| 45 | + <developerConnection>scm:git:git@github.com:TouK/flink-scala.git</developerConnection> |
| 46 | + <url>github.com/TouK/flink-scala</url> |
36 | 47 | </scm>
|
37 |
| - <developers> |
38 |
| - <developer> |
39 |
| - <id>TouK</id> |
40 |
| - <name>TouK</name> |
41 |
| - <url>https://touk.pl</url> |
42 |
| - </developer> |
43 |
| - </developers> |
| 48 | + <developers> |
| 49 | + <developer> |
| 50 | + <id>TouK</id> |
| 51 | + <name>TouK</name> |
| 52 | + <url>https://touk.pl</url> |
| 53 | + </developer> |
| 54 | + </developers> |
44 | 55 | },
|
45 | 56 | organization := "pl.touk",
|
46 | 57 | )
|
47 | 58 |
|
48 | 59 | lazy val root = (project in file("."))
|
49 | 60 | .settings(
|
50 |
| - name := "flink-scala-2.13", |
| 61 | + name := "flink-scala", |
51 | 62 | organization := "pl.touk",
|
52 | 63 | licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
|
53 |
| - homepage := Some(url("https://github.com/TouK/flink-scala-2.13")), |
54 |
| - libraryDependencies ++= { |
55 |
| - Seq( |
56 |
| - "org.scala-lang" % "scala-compiler" % scalaVersion.value, |
57 |
| - "org.scala-lang" % "scala-reflect" % scalaVersion.value, |
58 |
| - |
59 |
| - "org.apache.flink" % "flink-streaming-java" % flinkV % "provided", |
60 |
| - "com.twitter" %% "chill" % "0.9.5" exclude("com.esotericsoftware", "kryo-shaded"), |
61 |
| - "com.esotericsoftware.kryo" % "kryo" % "2.24.0" % "provided", |
62 |
| - |
63 |
| - "org.scalatest" %% "scalatest" % scalaTestV % "test", |
64 |
| - ) |
65 |
| - } |
| 64 | + homepage := Some(url("https://github.com/TouK/flink-scala")), |
| 65 | + libraryDependencies ++= (forScalaVersion(scalaVersion.value) { |
| 66 | + case (2, 12) => |
| 67 | + Seq( |
| 68 | + "org.apache.flink" %% "flink-scala" % flinkV.value excludeAll( |
| 69 | + ExclusionRule(organization = "org.apache.flink", name = "flink-core"), |
| 70 | + ExclusionRule(organization = "org.apache.flink", name = "flink-java"), |
| 71 | + ExclusionRule(organization = "org.apache.flink", name = "flink-shaded-asm-9"), |
| 72 | + ExclusionRule(organization = "org.slf4j", name = "slf4j-api"), |
| 73 | + ExclusionRule(organization = "com.google.code.findbugs", name = "jsr305"), |
| 74 | + ), |
| 75 | + "com.esotericsoftware.kryo" % "kryo" % "2.24.0" % Test, |
| 76 | + "org.apache.flink" % "flink-java" % flinkV.value % Test, |
| 77 | + ) |
| 78 | + case (2, 13) => |
| 79 | + Seq( |
| 80 | + "org.apache.flink" % "flink-streaming-java" % flinkV.value % "provided", |
| 81 | + "com.twitter" %% "chill" % "0.9.5" exclude("com.esotericsoftware", "kryo-shaded"), |
| 82 | + "com.esotericsoftware.kryo" % "kryo" % "2.24.0" % "provided", |
| 83 | + ) |
| 84 | + } ++ Seq( |
| 85 | + "org.scala-lang" % "scala-library" % scalaVersion.value, |
| 86 | + "org.scala-lang" % "scala-compiler" % scalaVersion.value, |
| 87 | + "org.scala-lang" % "scala-reflect" % scalaVersion.value, |
| 88 | + "org.scalatest" %% "scalatest" % scalaTestV % Test, |
| 89 | + )) |
66 | 90 | )
|
| 91 | + .settings(assemblySettings *) |
67 | 92 | .settings(publishSettings)
|
| 93 | + |
| 94 | +def forScalaVersion[T](version: String)(provide: PartialFunction[(Int, Int), T]): T = { |
| 95 | + CrossVersion.partialVersion(version) match { |
| 96 | + case Some((major, minor)) if provide.isDefinedAt((major.toInt, minor.toInt)) => |
| 97 | + provide((major.toInt, minor.toInt)) |
| 98 | + case Some(_) => |
| 99 | + throw new IllegalArgumentException(s"Scala version $version is not handled") |
| 100 | + case None => |
| 101 | + throw new IllegalArgumentException(s"Invalid Scala version $version") |
| 102 | + } |
| 103 | +} |
0 commit comments