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

Commit 0553179

Browse files
committed
Various small fixes in deploy build code
1 parent 4ba66f1 commit 0553179

File tree

4 files changed

+41
-42
lines changed

4 files changed

+41
-42
lines changed

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ lazy val fetch = TaskKey[Unit]("fetch", "Searches for plugins in plugin director
8383
lazy val copy = TaskKey[Unit]("copy", "Copies all packaged plugin jars to the target plugin folder.")
8484
lazy val bs = TaskKey[Unit]("bs", "Updates the bootstrap project with current dependencies and chat overflow jars.")
8585
lazy val deploy = TaskKey[Unit]("deploy", "Prepares the environment for deployment, fills deploy folder.")
86-
lazy val deployDev = TaskKey[Unit]("deployDev", "Prepares the environment for deployment, fills deploy folder.")
86+
lazy val deployDev = TaskKey[Unit]("deployDev", "Prepares the environment for plugin developers, fills deployDev folder.")
8787
lazy val gui = TaskKey[Unit]("gui", "Installs GUI dependencies and builds it using npm.")
8888

8989
pluginBuildFileName := "plugins.sbt"
@@ -119,7 +119,7 @@ lazy val getDependencyList = Def.task[List[ModuleID]] {
119119
m.name == s"chatoverflow_$scalaMajorVersion")
120120
}
121121
}
122-
//lazy val x = ModuleID.apply()
122+
123123
// Clears the built GUI dirs on clean
124124
cleanFiles += baseDirectory.value / guiProjectPath.value / "dist"
125125
cleanFiles += baseDirectory.value / "src" / "main" / "resources" / "chatoverflow-gui"

project/BootstrapUtility.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ object BootstrapUtility {
106106

107107
logger info "Started deployment process."
108108

109-
// First step: Create directories
110-
createOrEmptyFolder("deployDev")
109+
// First step: Create directory
110+
createOrEmptyFolder("deploy/")
111111

112112
// Second step: Create bin directories and copy all binaries
113113
val targetJarDirectories = List("bin", "deploy/bin")
@@ -146,16 +146,16 @@ object BootstrapUtility {
146146

147147
logger info "Started deployment process for plugin dev environment."
148148

149-
// First step: Create directories
150-
createOrEmptyFolder("deployDev")
149+
// First step: Create directory
150+
createOrEmptyFolder("deployDev/")
151151

152152
// Second step: Copy all binaries
153153
val targetJarDirectories = List("bin", "deployDev/bin")
154154
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion, copyApi = false)
155155

156156
// Third step: Copy the api
157157
sbt.IO.copyDirectory(new File(apiProjectPath), new File("deployDev/api/"))
158-
sbt.IO.delete(new File("deployDev/api/target"))
158+
sbt.IO.delete(new File("deployDev/api/target")) // otherwise compiled code would end up in the zip
159159

160160
// Fourth step: Copy required meta-build files
161161
val requiredBuildFiles = Set("BuildUtility.scala", "build.properties", "Plugin.scala", "PluginCreateWizard.scala",

project/BuildUtility.scala

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import java.io.{File, IOException}
22
import java.nio.file.{Files, StandardCopyOption}
33

4-
import BuildUtility._
54
import sbt.internal.util.ManagedLogger
65
import sbt.util.{FileFunction, FilesInfo}
76

@@ -236,6 +235,20 @@ class BuildUtility(logger: ManagedLogger) {
236235
}
237236
}
238237

238+
/**
239+
* Creates a file listing with all files including files in any sub-dir.
240+
*
241+
* @param f the directory for which the file listing needs to be created.
242+
* @return the file listing as a set of files.
243+
*/
244+
def recursiveFileListing(f: File): Set[File] = {
245+
if (f.isDirectory) {
246+
f.listFiles().flatMap(recursiveFileListing).toSet
247+
} else {
248+
Set(f)
249+
}
250+
}
251+
239252
private def withTaskInfo(taskName: String)(task: Unit): Unit = BuildUtility.withTaskInfo(taskName, logger)(task)
240253
}
241254

@@ -261,18 +274,4 @@ object BuildUtility {
261274
// Info when task stopped (better log comprehension)
262275
logger info s"Finished custom task: $taskName"
263276
}
264-
265-
/**
266-
* Creates a file listing with all files including files in any sub-dir.
267-
*
268-
* @param f the directory for which the file listing needs to be created.
269-
* @return the file listing as a set of files.
270-
*/
271-
def recursiveFileListing(f: File): Set[File] = {
272-
if (f.isDirectory) {
273-
f.listFiles().flatMap(recursiveFileListing).toSet
274-
} else {
275-
Set(f)
276-
}
277-
}
278277
}

project/SbtFile.scala

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SbtFile(val name: String, val version: String, val plugins: List[Plugin],
2020
* @param name the name of a sbt project
2121
* @param version the version of a sbt project
2222
*/
23-
def this(name: String, version: String) = this(name, version, List(), "", false, List())
23+
def this(name: String, version: String) = this(name, version, List(), "", false, List())
2424

2525
/**
2626
* Represents a simple sbt files content and methods to create a new sbt file. Not intended to open/read sbt files.
@@ -88,13 +88,8 @@ class SbtFile(val name: String, val version: String, val plugins: List[Plugin],
8888
}
8989

9090
if (defineRoot) {
91-
var aggregateElems = plugins.map(p => s"`${p.normalizedName}`")
92-
if (apiProjectPath != "") {
93-
aggregateElems = "apiProject" +: aggregateElems
94-
}
95-
9691
var rootLine = "\n\nlazy val root = (project in file(\".\")).aggregate(%s)"
97-
.format(aggregateElems.mkString(", "))
92+
.format(("apiProject" +: plugins.map(p => s"`${p.normalizedName}`")).mkString(", "))
9893

9994
if (apiProjectPath != "") {
10095
rootLine += ".dependsOn(apiProject)"
@@ -107,23 +102,28 @@ class SbtFile(val name: String, val version: String, val plugins: List[Plugin],
107102
sbtContent append "\nresolvers += \"jcenter-bintray\" at \"http://jcenter.bintray.com\"\n"
108103

109104
// Note that the %% in the string are required to escape the string formatter and will turn into a single %
110-
val depString = dependencies.map(m => {
111-
var formatString = ""
112-
113-
if (m.crossVersion == CrossVersion.binary)
114-
formatString += "\"%s\" %%%% \"%s\" %% \"%s\""
115-
else
116-
formatString += "\"%s\" %% \"%s\" %% \"%s\""
117-
118-
if (m.configurations.isDefined)
119-
formatString += " %% \"%s\""
120-
121-
formatString.format(m.organization, m.name, m.revision, m.configurations.getOrElse(""))
122-
}).mkString(" ", ",\n ", "")
105+
val depString = dependencies.map(m => renderModuleID(m)).mkString(" ", ",\n ", "")
123106

124107
sbtContent append s"libraryDependencies ++= Seq(\n$depString\n)\n"
125108
}
126109

127110
sbtContent.mkString
128111
}
112+
113+
/**
114+
* Converts a ModuleID instance to a string with the module in the syntax that is used in sbt files.
115+
*/
116+
private def renderModuleID(m: ModuleID): String = {
117+
var formatString = ""
118+
119+
if (m.crossVersion == CrossVersion.binary)
120+
formatString += "\"%s\" %%%% \"%s\" %% \"%s\""
121+
else
122+
formatString += "\"%s\" %% \"%s\" %% \"%s\""
123+
124+
if (m.configurations.isDefined)
125+
formatString += " %% \"%s\""
126+
127+
formatString.format(m.organization, m.name, m.revision, m.configurations.getOrElse(""))
128+
}
129129
}

0 commit comments

Comments
 (0)