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

Commit 0366f0b

Browse files
committed
Finished bootstrap launcher and deployment.
1 parent 4a6b705 commit 0366f0b

9 files changed

+251
-179
lines changed

.idea/runConfigurations/Bootstrap_Assembly__sbt_bs_assembly_.xml

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

.idea/runConfigurations/Deploy__sbt_deploy_.xml

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

.idea/runConfigurations/_Advanced__Full_Reload_and_Run_ChatOverflow.xml

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

.idea/runConfigurations/_Deploy__Generate_Bootstrap_Launcher_and_deploy.xml

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

.idea/runConfigurations/_Simple__Rebuild_plugins_and_Run_ChatOverflow.xml

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

bootstrap/src/main/scala/Bootstrap.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ object Bootstrap {
159159

160160
try {
161161
val connection = url.openConnection().asInstanceOf[HttpURLConnection]
162-
connection.setConnectTimeout(1000)
163-
connection.setReadTimeout(1000)
162+
connection.setConnectTimeout(3000)
163+
connection.setReadTimeout(3000)
164164
connection.connect()
165165

166166
if (connection.getResponseCode >= 400) {

project/BootstrapUtility.scala

Lines changed: 44 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,10 @@
11
import java.io.File
2-
import java.net.{HttpURLConnection, URL}
32
import java.nio.file.{Files, Paths}
43

4+
import BuildUtility.withTaskInfo
55
import sbt.internal.util.ManagedLogger
66

7-
import scala.xml.{Node, XML}
8-
9-
/**
10-
* A dependency holds all information of a library like name, version and maven url.
11-
*
12-
* @param dependencyString the input string from the 'dependencyList' sbt command
13-
* @param logger the sbt logger
14-
*/
15-
class Dependency(dependencyString: String, logger: ManagedLogger) {
16-
var nameWithoutScalaVersion = ""
17-
var version = ""
18-
var url = ""
19-
var available = false
20-
create()
21-
22-
override def toString: String = {
23-
s"$nameWithoutScalaVersion ($version) - $available - $url"
24-
}
25-
26-
/**
27-
* Converts the dependency to its xml representation, ready to be saved.
28-
*
29-
* @return a xml node called 'dependency'
30-
*/
31-
def toXML: Node = {
32-
<dependency>
33-
<name>
34-
{nameWithoutScalaVersion}
35-
</name>
36-
<version>
37-
{version}
38-
</version>
39-
<url>
40-
{url}
41-
</url>
42-
</dependency>
43-
}
44-
45-
/**
46-
* This constructor-alike function reads the console output of the 'dependencyList' sbt command
47-
* and fills all required information into the dependency object
48-
*/
49-
private def create(): Unit = {
50-
val DependencyRegex = "([^:]+):([^:_]+)(_[^:]+)?:([^:]+)".r
51-
val mavenCentralFormat = "http://central.maven.org/maven2/%s/%s/%s/%s.jar"
52-
53-
dependencyString match {
54-
case DependencyRegex(depAuthor, depName, scalaVersion, depVersion) =>
55-
this.nameWithoutScalaVersion = depName
56-
this.version = depVersion
57-
58-
val combinedName = if (scalaVersion != null) depName + scalaVersion else depName
59-
60-
// Create URL for maven central
61-
url = mavenCentralFormat.format(depAuthor.replaceAll("\\.", "/"), s"$combinedName",
62-
depVersion, s"$combinedName-$depVersion")
63-
64-
available = testURL(0, 3)
65-
66-
case _ =>
67-
logger warn s"Invalid dependency format: '$dependencyString'."
68-
}
69-
}
70-
71-
/**
72-
* Tests, if the dependency url is available. Uses recursion to handle connection faults.
73-
*/
74-
private def testURL(recursionCount: Int, recursionLimit: Int): Boolean = {
75-
76-
var status = -1
77-
78-
try {
79-
80-
// Test if the url exists
81-
val connection = new URL(url).openConnection.asInstanceOf[HttpURLConnection]
82-
connection.setRequestMethod("HEAD")
83-
connection.setConnectTimeout(200)
84-
connection.setReadTimeout(200)
85-
status = connection.getResponseCode
86-
connection.disconnect()
87-
88-
} catch {
89-
case e: Exception => logger warn s"Error while testing dependency (attempt $recursionCount of $recursionLimit)" +
90-
s" availability of ${this}: ${e.getMessage}"
91-
}
92-
93-
if (status != 200 && recursionCount + 1 <= recursionLimit) {
94-
testURL(recursionCount + 1, recursionLimit)
95-
} else {
96-
status == 200
97-
}
98-
}
99-
100-
}
7+
import scala.xml.XML
1018

1029
/**
10310
* Holds the functionality to read all dependencies and feed the bootstrap launcher with this information.
@@ -115,13 +22,12 @@ object BootstrapUtility {
11522
* @param scalaLibraryVersion the current scala library version
11623
*/
11724
def bootstrapGenTask(logger: ManagedLogger, scalaLibraryVersion: String): Unit = {
118-
println("Welcome to the bootstrap generation utility. It's time to build!")
119-
120-
// Dependency management
121-
val dependencyList = retrieveDependencies(logger, scalaLibraryVersion)
122-
saveDependencyXML(dependencyList, logger)
25+
withTaskInfo("BOOTSTRAP GENERATION", logger) {
12326

124-
println("Finished bootstrap generation utility. Have a nice day!")
27+
// Dependency management
28+
val dependencyList = retrieveDependencies(logger, scalaLibraryVersion)
29+
saveDependencyXML(dependencyList, logger)
30+
}
12531
}
12632

12733
/**
@@ -195,48 +101,52 @@ object BootstrapUtility {
195101
// Assuming, before this: clean, bs, assembly bootstrapProject, package
196102
// Assuming: Hardcoded "bin/" and "deploy/" folders
197103
// Assuming: A folder called "deployment-files" with all additional files (license, bat, etc.)
198-
logger info "Started deployment process."
199104

200-
// First step: Preparing bin folder
201-
logger info "Preparing 'bin/' folder."
202-
createOrEmptyFolder("bin/")
105+
withTaskInfo("PREPARE DEPLOYMENT", logger) {
203106

204-
// Second step: Preparing deploy folder, copying bin folder, bootstrap launcher, etc.
205-
logger info "Preparing 'deploy/' folder."
206-
createOrEmptyFolder("deploy/")
207-
createOrEmptyFolder("deploy/bin/")
107+
logger info "Started deployment process."
208108

209-
// Third step: Copying chat overflow files
210-
logger info "Copying chat overflow files..."
109+
// First step: Preparing bin folder
110+
logger info "Preparing 'bin/' folder."
111+
createOrEmptyFolder("bin/")
211112

212-
val sourceJarDirectories = List(s"target/scala-$scalaLibraryVersion/",
213-
s"api/target/scala-$scalaLibraryVersion/")
113+
// Second step: Preparing deploy folder, copying bin folder, bootstrap launcher, etc.
114+
logger info "Preparing 'deploy/' folder."
115+
createOrEmptyFolder("deploy/")
116+
createOrEmptyFolder("deploy/bin/")
214117

215-
val targetJarDirectories = List("bin", "deploy/bin")
118+
// Third step: Copying chat overflow files
119+
logger info "Copying chat overflow files..."
216120

217-
for (sourceDirectory <- sourceJarDirectories) {
218-
copyJars(sourceDirectory, targetJarDirectories, logger)
219-
}
121+
val sourceJarDirectories = List(s"target/scala-$scalaLibraryVersion/",
122+
s"api/target/scala-$scalaLibraryVersion/")
220123

221-
// Fourth step: Copy bootstrap launcher
222-
copyJars(s"bootstrap/target/scala-$scalaLibraryVersion/", List("deploy/"), logger)
124+
val targetJarDirectories = List("bin", "deploy/bin")
223125

224-
// Last step: Copy additional files
225-
logger info "Copying additional deployment files..."
226-
val deploymentFiles = new File("deployment-files/")
227-
if (!deploymentFiles.exists()) {
228-
logger warn "Unable to find deployment files."
229-
} else {
230-
for (deploymentFile <- deploymentFiles.listFiles()) {
231-
Files.copy(Paths.get(deploymentFile.getAbsolutePath),
232-
Paths.get(s"deploy/${deploymentFile.getName}"))
233-
logger info s"Finished copying additional deployment file '${deploymentFile.getName}'."
126+
for (sourceDirectory <- sourceJarDirectories) {
127+
copyJars(sourceDirectory, targetJarDirectories, logger)
234128
}
235-
}
236129

237-
// TODO: Deployment readme file html
238-
// TODO: Deployment bat file
239-
// TODO: Deployment unix launch file (...?)
130+
// Fourth step: Copy bootstrap launcher
131+
copyJars(s"bootstrap/target/scala-$scalaLibraryVersion/", List("deploy/"), logger)
132+
133+
// Last step: Copy additional files
134+
logger info "Copying additional deployment files..."
135+
val deploymentFiles = new File("deployment-files/")
136+
if (!deploymentFiles.exists()) {
137+
logger warn "Unable to find deployment files."
138+
} else {
139+
for (deploymentFile <- deploymentFiles.listFiles()) {
140+
Files.copy(Paths.get(deploymentFile.getAbsolutePath),
141+
Paths.get(s"deploy/${deploymentFile.getName}"))
142+
logger info s"Finished copying additional deployment file '${deploymentFile.getName}'."
143+
}
144+
}
145+
146+
// TODO: Deployment readme file html
147+
// TODO: Deployment bat file
148+
// TODO: Deployment unix launch file (...?)
149+
}
240150
}
241151

242152
/**
@@ -276,6 +186,4 @@ object BootstrapUtility {
276186
}
277187
}
278188

279-
// TODO: Use withTaskInfo to properly print tasks
280-
// TODO: Create missing deployment files
281-
// TODO: Create and commit deploy run configuration. clean, package, bs, assembly (bootstrapProject), deploy
189+
// TODO: Create missing deployment files

0 commit comments

Comments
 (0)