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

Commit 7d43af1

Browse files
committed
Let sbt handle dependencies in plugin dev environment and rework deploy tasks
1 parent 2d68314 commit 7d43af1

File tree

6 files changed

+141
-53
lines changed

6 files changed

+141
-53
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ project/plugins/project/
3232
/bin/
3333
/lib/
3434
/deploy/
35+
/deployDev/
3536
/wiki/
3637

3738
# Plugin Data

build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ libraryDependencies += "net.dv8tion" % "JDA" % "3.8.3_463"
6565
libraryDependencies += "com.fazecast" % "jSerialComm" % "[2.0.0,3.0.0)"
6666

6767
// Socket.io
68-
libraryDependencies += "io.socket" % "socket.io-client"% "1.0.0"
68+
libraryDependencies += "io.socket" % "socket.io-client" % "1.0.0"
6969
// ---------------------------------------------------------------------------------------------------------------------
7070
// PLUGIN FRAMEWORK DEFINITIONS
7171
// ---------------------------------------------------------------------------------------------------------------------
@@ -97,8 +97,8 @@ fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.valu
9797
pluginTargetFolderNames.value, apiProjectPath.value, apiJarPath = "")
9898
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
9999
bs := BootstrapUtility.bootstrapGenTask(streams.value.log, s"$scalaMajorVersion$scalaMinorVersion", getDependencyList.value)
100-
deploy := BootstrapUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion, dev = false)
101-
deployDev := BootstrapUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion, dev = true)
100+
deploy := BootstrapUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion)
101+
deployDev := BootstrapUtility.prepareDevDeploymentTask(streams.value.log, scalaMajorVersion)
102102
gui := BuildUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")
103103

104104
// ---------------------------------------------------------------------------------------------------------------------

deployment-files-dev/.idea/runConfigurations/_Advanced__Full_Reload_and_Run_ChatOverflow.xml

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployment-files-dev/.idea/runConfigurations/_Simple__Rebuild_plugins_and_Run_ChatOverflow.xml

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployment-files-dev/build.sbt

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This is a stripped down version of the build.sbt found in the main framework.
2-
// It just contains version numbers and all sbt tasks for plugin developers.
2+
// Its almost like the one from the framework but without some sbt tasks like 'deploy' that aren't needed for plugin developers.
33

44
// ---------------------------------------------------------------------------------------------------------------------
55
// PROJECT INFORMATION
@@ -16,6 +16,56 @@ inThisBuild(List(
1616
retrieveManaged := false)
1717
)
1818

19+
// ---------------------------------------------------------------------------------------------------------------------
20+
// LIBRARY DEPENDENCIES
21+
// ---------------------------------------------------------------------------------------------------------------------
22+
23+
// Command Line Parsing
24+
libraryDependencies += "com.github.scopt" %% "scopt" % "3.5.0"
25+
26+
// log4j Logger
27+
libraryDependencies += "org.slf4j" % "slf4j-log4j12" % "1.7.22"
28+
29+
// Scalatra (REST, ...)
30+
libraryDependencies ++= Seq(
31+
"org.scalatra" %% "scalatra" % "2.6.+",
32+
"org.scalatra" %% "scalatra-scalate" % "2.6.+",
33+
"org.scalatra" %% "scalatra-specs2" % "2.6.+",
34+
"ch.qos.logback" % "logback-classic" % "1.2.3" % "provided",
35+
"org.eclipse.jetty" % "jetty-webapp" % "9.4.7.v20170914" % "provided",
36+
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
37+
"org.scalatra" %% "scalatra-json" % "2.6.3",
38+
"org.scalatra" %% "scalatra-swagger" % "2.6.5",
39+
)
40+
41+
// JSON Lib (Jackson)
42+
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.5.2"
43+
44+
// PIRCBotX
45+
libraryDependencies += "org.pircbotx" % "pircbotx" % "2.1"
46+
47+
// Reflections API for annotation indexing
48+
libraryDependencies += "org.reflections" % "reflections" % "0.9.11"
49+
50+
// Akka Actors
51+
libraryDependencies ++= Seq(
52+
"com.typesafe.akka" %% "akka-actor" % "2.5.18",
53+
//"com.typesafe.akka" %% "akka-testkit" % "2.5.18" % Test
54+
)
55+
56+
// Google GSON
57+
libraryDependencies += "com.google.code.gson" % "gson" % "2.8.5"
58+
59+
// JDA
60+
resolvers += "jcenter-bintray" at "http://jcenter.bintray.com"
61+
libraryDependencies += "net.dv8tion" % "JDA" % "3.8.3_463"
62+
63+
//Serial Communication
64+
libraryDependencies += "com.fazecast" % "jSerialComm" % "[2.0.0,3.0.0)"
65+
66+
// Socket.io
67+
libraryDependencies += "io.socket" % "socket.io-client"% "1.0.0"
68+
1969
// ---------------------------------------------------------------------------------------------------------------------
2070
// PLUGIN FRAMEWORK DEFINITIONS
2171
// ---------------------------------------------------------------------------------------------------------------------

project/BootstrapUtility.scala

Lines changed: 65 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -92,44 +92,28 @@ object BootstrapUtility {
9292
}
9393

9494
/**
95-
* Prepares the environemnt for deployment. Should be called after package and assembly task.
95+
* Prepares the environment for deployment. Should be called after package and assembly task.
9696
*
9797
* @param logger the sbt logger
9898
* @param scalaLibraryVersion the scala library major version
99-
* @param dev whether sbt scripts and stuff for plugin developers should be included
10099
*/
101-
def prepareDeploymentTask(logger: ManagedLogger, scalaLibraryVersion: String, dev: Boolean): Unit = {
102-
// Assuming, before this: clean, bs, assembly bootstrapProject, package and if dev apiProject/packagedArtifacts
100+
def prepareDeploymentTask(logger: ManagedLogger, scalaLibraryVersion: String): Unit = {
101+
// Assuming, before this: clean, bs, assembly bootstrapProject, package
103102
// Assuming: Hardcoded "bin/" and "deploy/" folders
104103
// Assuming: A folder called "deployment-files" with all additional files (license, bat, etc.)
105-
// Assuming: A folder called "deployment-files-dev" with more additional files for plugin developers (only included if dev == true)
106104

107105
withTaskInfo("PREPARE DEPLOYMENT", logger) {
108106

109107
logger info "Started deployment process."
110108

111-
// First step: Preparing bin folder
112-
logger info "Preparing 'bin/' folder."
113-
createOrEmptyFolder("bin/")
114-
115-
// Second step: Preparing deploy folder, copying bin folder, bootstrap launcher, etc.
116-
logger info "Preparing 'deploy/' folder."
117-
createOrEmptyFolder("deploy/")
118-
createOrEmptyFolder("deploy/bin/")
119-
120-
// Third step: Copying chat overflow files
121-
logger info "Copying chat overflow files..."
122-
123-
val sourceJarDirectories = List(s"target/scala-$scalaLibraryVersion/",
124-
s"api/target/scala-$scalaLibraryVersion/")
109+
// First step: Create directories
110+
createOrEmptyFolder("deployDev")
125111

112+
// Second step: Create bin directories and copy all binaries
126113
val targetJarDirectories = List("bin", "deploy/bin")
114+
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion)
127115

128-
for (sourceDirectory <- sourceJarDirectories) {
129-
copyJars(sourceDirectory, targetJarDirectories, logger)
130-
}
131-
132-
// Fourth step: Copy bootstrap launcher
116+
// Third step: Copy bootstrap launcher
133117
copyJars(s"bootstrap/target/scala-$scalaLibraryVersion/", List("deploy/"), logger)
134118

135119
// Last step: Copy additional files
@@ -141,27 +125,68 @@ object BootstrapUtility {
141125
sbt.IO.copyDirectory(deploymentFiles, new File("deploy/"))
142126
logger info s"Finished copying additional deployment files."
143127
}
128+
}
129+
}
144130

145-
if (dev) {
146-
val devDeploymentFiles = new File("deployment-files-dev/")
147-
if (!devDeploymentFiles.exists()) {
148-
logger warn "Unable to find dev deployment files."
149-
} else {
150-
sbt.IO.copyDirectory(devDeploymentFiles, new File("deploy/"))
151-
logger info "Finished copying additional dev deployment files."
152-
}
131+
/**
132+
* Prepares the environment for a deployment for plugin developers.
133+
* Should be called after package and apiProject/packagedArtifacts task.
134+
*
135+
* @param logger the sbt logger
136+
* @param scalaLibraryVersion the scala library major version
137+
*/
138+
def prepareDevDeploymentTask(logger: ManagedLogger, scalaLibraryVersion: String): Unit = {
139+
// Assuming, before this: clean, package and apiProject/packagedArtifacts
140+
// Assuming: Hardcoded "bin/" and "deployDev/" folders
141+
// Assuming: A folder called "deployment-files-dev" with more additional files for plugin developers
153142

154-
val requiredBuildFiles = Set("BuildUtility.scala", "build.properties", "Plugin.scala", "PluginCreateWizard.scala",
155-
"PluginLanguage.scala", "PluginMetadata.scala", "SbtFile.scala")
156-
for (filepath <- requiredBuildFiles) {
157-
val origFile = new File(s"project/$filepath")
158-
val deployFile = new File(s"deploy/project/$filepath")
159-
sbt.IO.copyFile(origFile, deployFile)
160-
}
143+
withTaskInfo("PREPARE DEV DEPLOYMENT", logger) {
144+
145+
logger info "Started deployment process for plugin dev environment."
146+
147+
// First step: Create directories
148+
createOrEmptyFolder("deployDev")
149+
150+
// Second step: Copy all binaries
151+
val targetJarDirectories = List("bin", "deployDev/bin")
152+
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion)
153+
154+
// Third step: Copy required meta-build files
155+
val requiredBuildFiles = Set("BuildUtility.scala", "build.properties", "Plugin.scala", "PluginCreateWizard.scala",
156+
"PluginLanguage.scala", "PluginMetadata.scala", "SbtFile.scala")
157+
158+
for (filepath <- requiredBuildFiles) {
159+
val origFile = new File(s"project/$filepath")
160+
val deployFile = new File(s"deployDev/project/$filepath")
161+
sbt.IO.copyFile(origFile, deployFile)
162+
}
163+
164+
// Last step: Copy additional files
165+
val devDeploymentFiles = new File("deployment-files-dev/")
166+
if (!devDeploymentFiles.exists()) {
167+
logger warn "Unable to find dev deployment files."
168+
} else {
169+
sbt.IO.copyDirectory(devDeploymentFiles, new File("deployDev/"))
170+
logger info "Finished copying additional dev deployment files."
161171
}
162172
}
163173
}
164174

175+
private def prepareBinDirectories(logger: ManagedLogger, targetDirs: List[String], scalaLibraryVersion: String): Unit = {
176+
// First prepare all bin folders
177+
targetDirs.foreach(d => {
178+
logger info s"Preparing '$d' folder."
179+
createOrEmptyFolder(d)
180+
})
181+
182+
// Then copy all binary files
183+
logger info "Copying chat overflow files..."
184+
val sourceJarDirectories = List(s"target/scala-$scalaLibraryVersion/",
185+
s"api/target/scala-$scalaLibraryVersion/")
186+
187+
sourceJarDirectories.foreach(d => copyJars(d, targetDirs, logger))
188+
}
189+
165190
/**
166191
* Creates a directory or empties it, by recursively deleting files and sub directories.
167192
*/
@@ -177,7 +202,7 @@ object BootstrapUtility {
177202
}
178203
}
179204
} else {
180-
folder.mkdir()
205+
folder.mkdirs()
181206
}
182207
}
183208

0 commit comments

Comments
 (0)