Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 1ae8d78

Browse files
committed
Add a generic task to get the major and minor scala version
1 parent cb69ba1 commit 1ae8d78

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

build/src/main/scala/org/codeoverflow/chatoverflow/build/BuildUtils.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package org.codeoverflow.chatoverflow.build
22

33
import java.io.File
44

5+
import sbt.{Def, Task}
6+
import sbt.Keys.scalaVersion
57
import sbt.internal.util.ManagedLogger
68

79
object BuildUtils {
@@ -64,4 +66,11 @@ object BuildUtils {
6466
else
6567
Seq("--release", "8") // please compile against Java 8
6668
}
69+
70+
/**
71+
* A task that returns the major and minor version of the currently used version of scala, e.g. 2.12.
72+
*/
73+
lazy val scalaMajorVersion: Def.Initialize[Task[String]] = Def.task {
74+
scalaVersion.value.split('.').dropRight(1).mkString(".")
75+
}
6776
}

keys.sbt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ lazy val gui = TaskKey[Unit]("gui", "Installs GUI dependencies and builds it usi
2727
// Tasks
2828

2929
import org.codeoverflow.chatoverflow.build.GUIUtility
30+
import org.codeoverflow.chatoverflow.build.BuildUtils.scalaMajorVersion
3031
import org.codeoverflow.chatoverflow.build.deployment.DeploymentUtility
3132
import org.codeoverflow.chatoverflow.build.plugins.{PluginCreateWizard, PluginUtility}
3233

3334
create := new PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value, PluginCreateWizard.getApiVersion.value)
3435
fetch := new PluginUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
3536
pluginTargetFolderNames.value, apiProjectPath.value)
36-
copy := new PluginUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value,
37-
scalaVersion.value.split('.').dropRight(1).mkString("."))
38-
deploy := DeploymentUtility.prepareDeploymentTask(streams.value.log,
39-
scalaVersion.value.split('.').dropRight(1).mkString("."))
40-
deployDev := DeploymentUtility.prepareDevDeploymentTask(streams.value.log,
41-
scalaVersion.value.split('.').dropRight(1).mkString("."), apiProjectPath.value)
37+
copy := new PluginUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion.value)
38+
deploy := DeploymentUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion.value)
39+
deployDev := DeploymentUtility.prepareDevDeploymentTask(streams.value.log, scalaMajorVersion.value, apiProjectPath.value)
4240
gui := new GUIUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")
4341

4442

0 commit comments

Comments
 (0)