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

Commit 6093ba1

Browse files
committed
Deploy the whole api project instead of jars, fixes javadoc in IntelliJ
1 parent d0c3dce commit 6093ba1

File tree

7 files changed

+44
-51
lines changed

7 files changed

+44
-51
lines changed

.idea/runConfigurations/Full_API_package__sbt_packagedArtifacts_.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.idea/runConfigurations/_DeployDev__Generate_Bootstrap_Launcher_and_deploy_plugin_dev_environment.xml

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

build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ guiProjectPath := "gui"
9494

9595
create := PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value)
9696
fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
97-
pluginTargetFolderNames.value, apiProjectPath.value, apiJarPath = "")
97+
pluginTargetFolderNames.value, apiProjectPath.value)
9898
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
9999
bs := BootstrapUtility.bootstrapGenTask(streams.value.log, s"$scalaMajorVersion$scalaMinorVersion", getDependencyList.value)
100100
deploy := BootstrapUtility.prepareDeploymentTask(streams.value.log, scalaMajorVersion)
101-
deployDev := BootstrapUtility.prepareDevDeploymentTask(streams.value.log, scalaMajorVersion, getDependencyList.value)
101+
deployDev := BootstrapUtility.prepareDevDeploymentTask(streams.value.log, scalaMajorVersion, apiProjectPath.value, libraryDependencies.value.toList)
102102
gui := BuildUtility(streams.value.log).guiTask(guiProjectPath.value, streams.value.cacheDirectory / "gui")
103103

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

deployment-files-dev/build.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ unmanagedBase := file("bin")
2727
lazy val pluginBuildFileName = settingKey[String]("The filename of the plugin build file. Remember to gitignore it!")
2828
lazy val pluginFolderNames = settingKey[List[String]]("The folder names of all plugin source directories.")
2929
lazy val pluginTargetFolderNames = settingKey[List[String]]("The folder names of compiled and packaged plugins. Remember to gitignore these!")
30+
lazy val apiProjectPath = settingKey[String]("The path to the api sub project. Remember to gitignore it!")
3031

3132
// Plugin framework tasks
3233
lazy val create = TaskKey[Unit]("create", "Creates a new plugin. Interactive command using the console.")
@@ -36,8 +37,9 @@ lazy val copy = TaskKey[Unit]("copy", "Copies all packaged plugin jars to the ta
3637
pluginBuildFileName := "plugins.sbt"
3738
pluginFolderNames := List("plugins-public", "plugins-private")
3839
pluginTargetFolderNames := List("plugins", s"target/scala-$scalaMajorVersion/plugins")
40+
apiProjectPath := "api"
3941

4042
create := PluginCreateWizard(streams.value.log).createPluginTask(pluginFolderNames.value)
4143
fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
42-
pluginTargetFolderNames.value, "", "bin/")
44+
pluginTargetFolderNames.value, apiProjectPath.value)
4345
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)

project/BootstrapUtility.scala

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ object BootstrapUtility {
9898
* @param scalaLibraryVersion the scala library major version
9999
*/
100100
def prepareDeploymentTask(logger: ManagedLogger, scalaLibraryVersion: String): Unit = {
101-
// Assuming, before this: clean, bs, assembly bootstrapProject, package
101+
// Assuming, before this: clean, gui, bs, bootstrapProject/assembly, package
102102
// Assuming: Hardcoded "bin/" and "deploy/" folders
103103
// Assuming: A folder called "deployment-files" with all additional files (license, bat, etc.)
104104

@@ -111,7 +111,7 @@ object BootstrapUtility {
111111

112112
// Second step: Create bin directories and copy all binaries
113113
val targetJarDirectories = List("bin", "deploy/bin")
114-
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion)
114+
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion, copyApi = true)
115115

116116
// Third step: Copy bootstrap launcher
117117
copyJars(s"bootstrap/target/scala-$scalaLibraryVersion/", List("deploy/"), logger)
@@ -134,9 +134,11 @@ object BootstrapUtility {
134134
*
135135
* @param logger the sbt logger
136136
* @param scalaLibraryVersion the scala library major version
137+
* @param apiProjectPath the path to the api project. Used to copy the api into the deployDev directory
138+
* @param dependencies the dependencies of the framework. Used to create a sbt file with them.
137139
*/
138-
def prepareDevDeploymentTask(logger: ManagedLogger, scalaLibraryVersion: String, dependencies: List[ModuleID]): Unit = {
139-
// Assuming, before this: clean, package and apiProject/packagedArtifacts
140+
def prepareDevDeploymentTask(logger: ManagedLogger, scalaLibraryVersion: String, apiProjectPath: String, dependencies: List[ModuleID]): Unit = {
141+
// Assuming, before this: clean, gui and package
140142
// Assuming: Hardcoded "bin/" and "deployDev/" folders
141143
// Assuming: A folder called "deployment-files-dev" with more additional files for plugin developers
142144

@@ -149,19 +151,23 @@ object BootstrapUtility {
149151

150152
// Second step: Copy all binaries
151153
val targetJarDirectories = List("bin", "deployDev/bin")
152-
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion)
154+
prepareBinDirectories(logger, targetJarDirectories, scalaLibraryVersion, copyApi = false)
153155

154-
// Third step: Copy required meta-build files
156+
// Third step: Copy the api
157+
sbt.IO.copyDirectory(new File(apiProjectPath), new File("deployDev/api/"))
158+
sbt.IO.delete(new File("deployDev/api/target"))
159+
160+
// Fourth step: Copy required meta-build files
155161
val requiredBuildFiles = Set("BuildUtility.scala", "build.properties", "Plugin.scala", "PluginCreateWizard.scala",
156-
"PluginLanguage.scala", "PluginMetadata.scala", "SbtFile.scala")
162+
"PluginLanguage.scala", "PluginMetadata.scala", "SbtFile.scala", "APIUtility.scala", "RequirementsFile.scala")
157163

158164
for (filepath <- requiredBuildFiles) {
159165
val origFile = new File(s"project/$filepath")
160166
val deployFile = new File(s"deployDev/project/$filepath")
161167
sbt.IO.copyFile(origFile, deployFile)
162168
}
163169

164-
// Fourth step: Create sbt files containing all dependencies
170+
// Fifth step: Create sbt files containing all dependencies
165171
val depFile = new SbtFile(dependencies)
166172
sbt.IO.write(new File("deployDev/dependencies.sbt"), depFile.toString)
167173

@@ -176,7 +182,7 @@ object BootstrapUtility {
176182
}
177183
}
178184

179-
private def prepareBinDirectories(logger: ManagedLogger, targetDirs: List[String], scalaLibraryVersion: String): Unit = {
185+
private def prepareBinDirectories(logger: ManagedLogger, targetDirs: List[String], scalaLibraryVersion: String, copyApi: Boolean): Unit = {
180186
// First prepare all bin folders
181187
targetDirs.foreach(d => {
182188
logger info s"Preparing '$d' folder."
@@ -185,8 +191,10 @@ object BootstrapUtility {
185191

186192
// Then copy all binary files
187193
logger info "Copying chat overflow files..."
188-
val sourceJarDirectories = List(s"target/scala-$scalaLibraryVersion/",
189-
s"api/target/scala-$scalaLibraryVersion/")
194+
val sourceJarDirectories = if (copyApi)
195+
List(s"target/scala-$scalaLibraryVersion/", s"api/target/scala-$scalaLibraryVersion/")
196+
else
197+
List(s"target/scala-$scalaLibraryVersion/")
190198

191199
sourceJarDirectories.foreach(d => copyJars(d, targetDirs, logger))
192200
}

project/BuildUtility.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ class BuildUtility(logger: ManagedLogger) {
3434
* @param pluginBuildFileName The generated sbt build file, containing all sub project references. Defined in build.sbt.
3535
* @param pluginTargetFolderNames The name of the directory, in which all plugins should be copied.
3636
* @param apiProjectPath The path of the api project. Chosen over apiJarPath if possible.
37-
* @param apiJarPath The path of a directory which is containing all api jars. Chosen if apiProjectPath is empty.
3837
*/
3938
def fetchPluginsTask(pluginSourceFolderNames: List[String], pluginBuildFileName: String,
40-
pluginTargetFolderNames: List[String], apiProjectPath: String, apiJarPath: String): Unit = {
39+
pluginTargetFolderNames: List[String], apiProjectPath: String): Unit = {
4140
withTaskInfo("FETCH PLUGINS") {
4241

4342
// Check validity of plugin source folders
@@ -49,7 +48,7 @@ class BuildUtility(logger: ManagedLogger) {
4948
val allPlugins = getAllPlugins(pluginSourceFolderNames)
5049

5150
// Create a sbt file with all plugin dependencies (sub projects)
52-
val sbtFile = new SbtFile("", "", allPlugins, apiProjectPath, apiJarPath, defineRoot = true, List())
51+
val sbtFile = new SbtFile("", "", allPlugins, apiProjectPath, defineRoot = true, List())
5352

5453
if (sbtFile.save(pluginBuildFileName)) {
5554
logger info s"Successfully updated plugin file at '$pluginBuildFileName'."

project/SbtFile.scala

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.io.{BufferedWriter, File, FileWriter, IOException}
22

3-
import sbt.librarymanagement.ModuleID
3+
import sbt.librarymanagement.{CrossVersion, ModuleID}
44

55
/**
66
* Represents a simple sbt files content and methods to create a new sbt file. Not intended to open/read sbt files.
@@ -9,19 +9,18 @@ import sbt.librarymanagement.ModuleID
99
* @param version the version of a sbt project
1010
* @param plugins list of paths of sub projects
1111
* @param apiProjectPath the path of a base api project which every project depends on
12-
* @param apiJarDirPath the path of a directory containing jar files over the api. Designed to be a fallback to apiProjectPath
1312
* @param defineRoot true, if a root project (".") should be defined in the sbt file
1413
* @param dependencies library dependencies to add to the sbt file
1514
*/
1615
class SbtFile(val name: String, val version: String, val plugins: List[Plugin], val apiProjectPath: String,
17-
val apiJarDirPath: String, val defineRoot: Boolean, dependencies: List[ModuleID]) {
16+
val defineRoot: Boolean, dependencies: List[ModuleID]) {
1817
/**
1918
* Represents a simple sbt files content and methods to create a new sbt file. Not intended to open/read sbt files.
2019
*
2120
* @param name the name of a sbt project
2221
* @param version the version of a sbt project
2322
*/
24-
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())
2524

2625
/**
2726
* Represents a simple sbt files content and methods to create a new sbt file. Not intended to open/read sbt files.
@@ -33,7 +32,7 @@ class SbtFile(val name: String, val version: String, val plugins: List[Plugin],
3332
*
3433
* @param dependencies library dependencies to add to the sbt file
3534
*/
36-
def this(dependencies: List[ModuleID]) = this("", "", List(), "", "", false, dependencies)
35+
def this(dependencies: List[ModuleID]) = this("", "", List(), "", false, dependencies)
3736

3837
/**
3938
* Tries to save the sbt files content into a defined directory.
@@ -79,17 +78,13 @@ class SbtFile(val name: String, val version: String, val plugins: List[Plugin],
7978

8079
if (apiProjectPath != "") {
8180
pluginLine += ".dependsOn(apiProject)"
82-
} else if (apiJarDirPath != "") {
83-
pluginLine += ".settings(Compile / unmanagedJars := jars)"
8481
}
8582

8683
sbtContent append pluginLine
8784
}
8885

8986
if (apiProjectPath != "") {
9087
sbtContent append "\n\nlazy val apiProject = project in file(\"%s\")".format(apiProjectPath)
91-
} else if (apiJarDirPath != "") {
92-
sbtContent append "\nlazy val jars: Classpath = (file(\"%s\") ** \"chatoverflow-api*.jar\").classpath\n".format(apiJarDirPath)
9388
}
9489

9590
if (defineRoot) {
@@ -112,8 +107,19 @@ class SbtFile(val name: String, val version: String, val plugins: List[Plugin],
112107
sbtContent append "\nresolvers += \"jcenter-bintray\" at \"http://jcenter.bintray.com\"\n"
113108

114109
// Note that the %% in the string are required to escape the string formatter and will turn into a single %
115-
val depString = dependencies.map(m => "\"%s\" %% \"%s\" %% \"%s\"".format(m.organization, m.name, m.revision))
116-
.mkString(" ", ",\n ", "")
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 ", "")
117123

118124
sbtContent append s"libraryDependencies ++= Seq(\n$depString\n)\n"
119125
}

0 commit comments

Comments
 (0)