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

Commit 93ddc3f

Browse files
committed
Closed #124. Cleaned up build.sbt and split functionality.
1 parent 3aca081 commit 93ddc3f

File tree

3 files changed

+113
-139
lines changed

3 files changed

+113
-139
lines changed

build.sbt

Lines changed: 9 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,16 @@
1-
// ---------------------------------------------------------------------------------------------------------------------
2-
// PROJECT INFORMATION
3-
// ---------------------------------------------------------------------------------------------------------------------
4-
5-
/*
6-
* A brief introduction of the sbt related folder structure:
7-
* root
8-
* | build.sbt
9-
* | plugins.sbt (produced by the fetch task)
10-
* | -> api project (required to build plugins and the framework)
11-
* | -> a plugin source directory
12-
* | -> -> a plugin folder = plugin
13-
* | -> -> -> build.sbt
14-
* | -> -> -> source etc.
15-
* | -> -> another folder = another plugin
16-
* | -> -> -> build.sbt
17-
* | -> -> -> source etc.
18-
* | -> another plugin source directory (optional)
19-
* | -> gui project (build will be skipped, if missing)
20-
* | -> bootstrap launcher (for end-user deployments)
21-
* | -> build project (contains code for all sbt tasks and sbt related things)
22-
*/
23-
1+
// Main project config
242
name := "ChatOverflow"
253
version := "3.0.0"
26-
mainClass := Some("org.codeoverflow.chatoverflow.Launcher")
27-
28-
// One version for all sub projects. Use "retrieveManaged := true" to download and show all library dependencies.
29-
val scalaMajorVersion = "2.12"
30-
val scalaMinorVersion = ".5"
31-
inThisBuild(List(
32-
scalaVersion := s"$scalaMajorVersion$scalaMinorVersion",
33-
retrieveManaged := false)
34-
)
354

36-
import org.codeoverflow.chatoverflow.build.BuildUtils
37-
javacOptions ++= BuildUtils.getJava8CrossOptions
38-
39-
// Link the launcher
5+
// Main class and sub projects
6+
mainClass := Some("org.codeoverflow.chatoverflow.Launcher")
407
lazy val launcherProject = project in file("launcher")
8+
lazy val buildProject = project in file("build") // needed for intelliJ support
419

42-
// not actually used. Just required to say IntelliJ to mark the build directory as a sbt project, otherwise it wouldn't detect it.
43-
lazy val buildProject = project in file("build")
44-
45-
// ---------------------------------------------------------------------------------------------------------------------
46-
// LIBRARY DEPENDENCIES
47-
// ---------------------------------------------------------------------------------------------------------------------
48-
49-
// Command Line Parsing
50-
libraryDependencies += "com.github.scopt" %% "scopt" % "3.5.0"
51-
52-
// log4j Logger
53-
libraryDependencies += "org.slf4j" % "slf4j-log4j12" % "1.7.22"
54-
55-
// Scalatra (REST, ...)
56-
libraryDependencies ++= Seq(
57-
"org.scalatra" %% "scalatra" % "2.6.5",
58-
"org.scalatra" %% "scalatra-scalate" % "2.6.5",
59-
"org.scalatra" %% "scalatra-specs2" % "2.6.5",
60-
"ch.qos.logback" % "logback-classic" % "1.2.3" % "provided",
61-
"org.eclipse.jetty" % "jetty-webapp" % "9.4.7.v20170914" % "provided",
62-
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
63-
"org.scalatra" %% "scalatra-json" % "2.6.3",
64-
"org.scalatra" %% "scalatra-swagger" % "2.6.5",
65-
)
66-
67-
// JSON Lib (Jackson)
68-
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.5.2"
69-
70-
// PIRCBotX
71-
libraryDependencies += "org.pircbotx" % "pircbotx" % "2.1"
72-
73-
// Reflections API for annotation indexing
74-
libraryDependencies += "org.reflections" % "reflections" % "0.9.11"
75-
76-
// Akka Actors
77-
libraryDependencies ++= Seq(
78-
"com.typesafe.akka" %% "akka-actor" % "2.5.18",
79-
//"com.typesafe.akka" %% "akka-testkit" % "2.5.18" % Test
80-
)
10+
// Settings
11+
inThisBuild(List(scalaVersion := "2.12.5"))
8112

82-
// Google GSON
83-
libraryDependencies += "com.google.code.gson" % "gson" % "2.8.5"
84-
85-
// JDA
86-
resolvers += "jcenter-bintray" at "https://jcenter.bintray.com"
87-
libraryDependencies += "net.dv8tion" % "JDA" % "3.8.3_463"
88-
89-
// Serial Communication
90-
libraryDependencies += "com.fazecast" % "jSerialComm" % "2.5.1"
91-
92-
// Socket.io
93-
libraryDependencies += "io.socket" % "socket.io-client" % "1.0.0"
94-
95-
// Coursier
96-
libraryDependencies += "io.get-coursier" %% "coursier" % "2.0.0-RC3-2"
97-
98-
// ---------------------------------------------------------------------------------------------------------------------
99-
// PLUGIN FRAMEWORK DEFINITIONS
100-
// ---------------------------------------------------------------------------------------------------------------------
101-
102-
// Plugin framework settings
103-
lazy val pluginBuildFileName = settingKey[String]("The filename of the plugin build file. Remember to gitignore it!")
104-
lazy val pluginFolderNames = settingKey[List[String]]("The folder names of all plugin source directories.")
105-
lazy val pluginTargetFolderNames = settingKey[List[String]]("The folder names of compiled and packaged plugins. Remember to gitignore these!")
106-
lazy val apiProjectPath = settingKey[String]("The path to the api sub project. Remember to gitignore it!")
107-
lazy val guiProjectPath = settingKey[String]("The path of the Angular gui.")
108-
109-
// Plugin framework tasks
110-
lazy val create = TaskKey[Unit]("create", "Creates a new plugin. Interactive command using the console.")
111-
lazy val fetch = TaskKey[Unit]("fetch", "Searches for plugins in plugin directories, builds the plugin build file.")
112-
lazy val copy = TaskKey[Unit]("copy", "Copies all packaged plugin jars to the target plugin folder.")
113-
lazy val deploy = TaskKey[Unit]("deploy", "Prepares the environment for deployment, fills deploy folder.")
114-
lazy val deployDev = TaskKey[Unit]("deployDev", "Prepares the environment for plugin developers, fills deployDev folder.")
115-
lazy val gui = TaskKey[Unit]("gui", "Installs GUI dependencies and builds it using npm.")
116-
117-
pluginBuildFileName := "plugins.sbt"
118-
pluginFolderNames := List("plugins-public", "plugins-private")
119-
pluginTargetFolderNames := List("plugins", s"target/scala-$scalaMajorVersion/plugins")
120-
apiProjectPath := "api"
121-
guiProjectPath := "gui"
122-
123-
124-
import org.codeoverflow.chatoverflow.build.GUIUtility
125-
import org.codeoverflow.chatoverflow.build.deployment.DeploymentUtility
126-
import org.codeoverflow.chatoverflow.build.plugins.{PluginCreateWizard, PluginUtility}
127-
128-
create := new PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value, PluginCreateWizard.getApiVersion.value)
129-
fetch := new PluginUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
130-
pluginTargetFolderNames.value, apiProjectPath.value)
131-
copy := new PluginUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
132-
deploy := DeploymentUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion)
133-
deployDev := DeploymentUtility.prepareDevDeploymentTask(streams.value.log, scalaMajorVersion, apiProjectPath.value, libraryDependencies.value.toList)
134-
gui := new GUIUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")
135-
136-
Compile / packageBin := {
137-
new GUIUtility(streams.value.log).packageGUITask(guiProjectPath.value, crossTarget.value)
138-
(Compile / packageBin).value
139-
}
140-
141-
Compile / unmanagedJars := new GUIUtility(streams.value.log).getGUIJarClasspath(guiProjectPath.value, crossTarget.value)
142-
143-
fork in run := true // Start ChatOverflow in it's own java process when starting it with 'sbt run'
13+
import org.codeoverflow.chatoverflow.build.BuildUtils
14414

145-
// Clears the built GUI dir on clean
146-
cleanFiles += baseDirectory.value / guiProjectPath.value / "dist"
15+
javacOptions ++= BuildUtils.getJava8CrossOptions
16+
fork in run := true // Start ChatOverflow in it's own java process when starting it with 'sbt run'

dependencies.sbt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Command Line Parsing
2+
libraryDependencies += "com.github.scopt" %% "scopt" % "3.5.0"
3+
4+
// log4j Logger
5+
libraryDependencies += "org.slf4j" % "slf4j-log4j12" % "1.7.22"
6+
7+
// Scalatra (REST, ...)
8+
libraryDependencies ++= Seq(
9+
"org.scalatra" %% "scalatra" % "2.6.5",
10+
"org.scalatra" %% "scalatra-scalate" % "2.6.5",
11+
"org.scalatra" %% "scalatra-specs2" % "2.6.5",
12+
"ch.qos.logback" % "logback-classic" % "1.2.3" % "provided",
13+
"org.eclipse.jetty" % "jetty-webapp" % "9.4.7.v20170914" % "provided",
14+
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
15+
"org.scalatra" %% "scalatra-json" % "2.6.3",
16+
"org.scalatra" %% "scalatra-swagger" % "2.6.5",
17+
)
18+
19+
// JSON Lib (Jackson)
20+
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.5.2"
21+
22+
// PIRCBotX
23+
libraryDependencies += "org.pircbotx" % "pircbotx" % "2.1"
24+
25+
// Reflections API for annotation indexing
26+
libraryDependencies += "org.reflections" % "reflections" % "0.9.11"
27+
28+
// Akka Actors
29+
libraryDependencies ++= Seq(
30+
"com.typesafe.akka" %% "akka-actor" % "2.5.18",
31+
//"com.typesafe.akka" %% "akka-testkit" % "2.5.18" % Test
32+
)
33+
34+
// Google GSON
35+
libraryDependencies += "com.google.code.gson" % "gson" % "2.8.5"
36+
37+
// JDA
38+
resolvers += "jcenter-bintray" at "https://jcenter.bintray.com"
39+
libraryDependencies += "net.dv8tion" % "JDA" % "3.8.3_463"
40+
41+
// Serial Communication
42+
libraryDependencies += "com.fazecast" % "jSerialComm" % "2.5.1"
43+
44+
// Socket.io
45+
libraryDependencies += "io.socket" % "socket.io-client" % "1.0.0"
46+
47+
// Coursier
48+
libraryDependencies += "io.get-coursier" %% "coursier" % "2.0.0-RC3-2"

keys.sbt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Settings
2+
pluginBuildFileName := "plugins.sbt"
3+
pluginFolderNames := List("plugins-public", "plugins-private")
4+
pluginTargetFolderNames := List("plugins", s"target/scala-${scalaVersion.value.split('.').dropRight(1).mkString(".")}/plugins")
5+
apiProjectPath := "api"
6+
guiProjectPath := "gui"
7+
8+
9+
10+
// Plugin framework setting keys
11+
lazy val pluginBuildFileName = settingKey[String]("The filename of the plugin build file. Remember to gitignore it!")
12+
lazy val pluginFolderNames = settingKey[List[String]]("The folder names of all plugin source directories. Remember to gitignore it!")
13+
lazy val pluginTargetFolderNames = settingKey[List[String]]("The folder names of compiled and packaged plugins. Remember to gitignore these!")
14+
lazy val apiProjectPath = settingKey[String]("The path to the api sub project. Remember to gitignore it!")
15+
lazy val guiProjectPath = settingKey[String]("The path of the Angular gui. Remember to gitignore it!")
16+
17+
// Plugin framework task keys
18+
lazy val create = TaskKey[Unit]("create", "Creates a new plugin. Interactive command using the console.")
19+
lazy val fetch = TaskKey[Unit]("fetch", "Searches for plugins in plugin directories, builds the plugin build file.")
20+
lazy val copy = TaskKey[Unit]("copy", "Copies all packaged plugin jars to the target plugin folder.")
21+
lazy val deploy = TaskKey[Unit]("deploy", "Prepares the environment for deployment, fills deploy folder.")
22+
lazy val deployDev = TaskKey[Unit]("deployDev", "Prepares the environment for plugin developers, fills deployDev folder.")
23+
lazy val gui = TaskKey[Unit]("gui", "Installs GUI dependencies and builds it using npm.")
24+
25+
26+
27+
// Tasks
28+
29+
import org.codeoverflow.chatoverflow.build.GUIUtility
30+
import org.codeoverflow.chatoverflow.build.deployment.DeploymentUtility
31+
import org.codeoverflow.chatoverflow.build.plugins.{PluginCreateWizard, PluginUtility}
32+
33+
create := new PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value, PluginCreateWizard.getApiVersion.value)
34+
fetch := new PluginUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
35+
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, libraryDependencies.value.toList)
42+
gui := new GUIUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")
43+
44+
45+
46+
// Enhance existing functionality
47+
Compile / packageBin := {
48+
new GUIUtility(streams.value.log).packageGUITask(guiProjectPath.value, crossTarget.value)
49+
(Compile / packageBin).value
50+
}
51+
52+
Compile / unmanagedJars := new GUIUtility(streams.value.log).getGUIJarClasspath(guiProjectPath.value, crossTarget.value)
53+
54+
cleanFiles += baseDirectory.value / guiProjectPath.value / "dist" // Clears the built GUI dir on clean
55+
56+

0 commit comments

Comments
 (0)