Skip to content
Permalink
Browse files

Extract all build code into an own sub-project

  • Loading branch information
daniel0611 committed Aug 7, 2019
1 parent d85d12b commit 43ddbd15e14153c6d22f8885683a900025abb6be
@@ -17,6 +17,9 @@ inThisBuild(List(
// Link the bootstrap launcher
lazy val bootstrapProject = project in file("bootstrap")

// not actually used. Just required to say IntelliJ to mark the build directory as a sbt project, otherwise it wouldn't detect it.
lazy val buildProject = project in file("build")

// ---------------------------------------------------------------------------------------------------------------------
// LIBRARY DEPENDENCIES
// ---------------------------------------------------------------------------------------------------------------------
@@ -66,6 +69,7 @@ libraryDependencies += "com.fazecast" % "jSerialComm" % "[2.0.0,3.0.0)"

// Socket.io
libraryDependencies += "io.socket" % "socket.io-client" % "1.0.0"

// ---------------------------------------------------------------------------------------------------------------------
// PLUGIN FRAMEWORK DEFINITIONS
// ---------------------------------------------------------------------------------------------------------------------
@@ -92,17 +96,17 @@ pluginTargetFolderNames := List("plugins", s"target/scala-$scalaMajorVersion/plu
apiProjectPath := "api"
guiProjectPath := "gui"

create := PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value)
fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
create := new PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value)
fetch := new BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
pluginTargetFolderNames.value, apiProjectPath.value)
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
copy := new BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
bs := BootstrapUtility.bootstrapGenTask(streams.value.log, s"$scalaMajorVersion$scalaMinorVersion", getDependencyList.value)
deploy := BootstrapUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion)
deployDev := BootstrapUtility.prepareDevDeploymentTask(streams.value.log, scalaMajorVersion, apiProjectPath.value, libraryDependencies.value.toList)
gui := BuildUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")
gui := new BuildUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")

Compile / packageBin := {
BuildUtility(streams.value.log).packageGUITask(guiProjectPath.value, scalaMajorVersion, crossTarget.value)
new BuildUtility(streams.value.log).packageGUITask(guiProjectPath.value, scalaMajorVersion, crossTarget.value)
(Compile / packageBin).value
}

@@ -127,5 +131,5 @@ lazy val getDependencyList = Def.task[List[ModuleID]] {
}
}

// Clears the built GUI dirs on clean
// Clears the built GUI dir on clean
cleanFiles += baseDirectory.value / guiProjectPath.value / "dist"
@@ -0,0 +1,5 @@
name := "chatoverflow-build"
sbtPlugin := true

// JSON lib (Jackson) used for parsing the GUI version in the package.json file
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.5.2"
File renamed without changes.
@@ -158,16 +158,27 @@ object BootstrapUtility {
sbt.IO.delete(new File("deployDev/api/target")) // otherwise compiled code would end up in the zip

// Fourth step: Copy required meta-build files
val requiredBuildFiles = Set("BuildUtility.scala", "build.properties", "Plugin.scala", "PluginCreateWizard.scala",
"PluginLanguage.scala", "PluginMetadata.scala", "SbtFile.scala", "APIUtility.scala", "RequirementsFile.scala",
"dependencies.sbt")

for (filepath <- requiredBuildFiles) {
// Everything in /project
val requiredMetaBuildFiles = Set("build.properties", "dependencies.sbt")
for (filepath <- requiredMetaBuildFiles) {
val origFile = new File(s"project/$filepath")
val deployFile = new File(s"deployDev/project/$filepath")
sbt.IO.copyFile(origFile, deployFile)
}

// Everything in /build
val requiredBuildFiles = Set("BuildUtility.scala", "Plugin.scala", "PluginCreateWizard.scala",
"PluginLanguage.scala", "PluginMetadata.scala", "SbtFile.scala", "APIUtility.scala", "RequirementsFile.scala")

for (filepath <- requiredBuildFiles) {
val origFile = new File(s"build/src/main/scala/$filepath")
val deployFile = new File(s"deployDev/build/src/main/scala/$filepath")
sbt.IO.copyFile(origFile, deployFile)
}

sbt.IO.copyFile(new File("build/build.sbt"), new File("deployDev/build/build.sbt")) // sbt file for the build project

// Fifth step: Create sbt files containing all dependencies
val depFile = new SbtFile(dependencies)
sbt.IO.write(new File("deployDev/dependencies.sbt"), depFile.toString)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -39,7 +39,7 @@ pluginFolderNames := List("plugins-public", "plugins-private")
pluginTargetFolderNames := List("plugins", s"target/scala-$scalaMajorVersion/plugins")
apiProjectPath := "api"

create := PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value)
fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
create := new PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value)
fetch := new BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
pluginTargetFolderNames.value, apiProjectPath.value)
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
copy := new BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
@@ -1,2 +1,2 @@
// JSON lib (Jackson) used for parsing the GUI version in the package.json file
libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.5.2"
lazy val build = ProjectRef(file("../build"), "build")
lazy val metaProject = (project in file(".")).dependsOn(build)

0 comments on commit 43ddbd1

Please sign in to comment.
You can’t perform that action at this time.