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

Commit b960268

Browse files
committed
Changed task name, updated dependency list retrieval and manipulation.
1 parent 7c41683 commit b960268

File tree

4 files changed

+111
-14
lines changed

4 files changed

+111
-14
lines changed

bootstrap/src/main/scala/Bootstrap.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ object Bootstrap {
88
TODO:
99
1. Write SBT-Logic to extract all libs from "sbt dependencyList"
1010
2. Write SBT-logic to transform and save this information as URL List
11+
2a. Make the logik copy the built jars into an bin folder inside the resources of the bootstrap
1112
3. Make the boostrap launcher download everything, create folder structures
1213
and launch chat overflow with custom classpath
1314
4. Make fat jar with only the scala lib inside (and the chat overflow files?)

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ lazy val apiProjectPath = settingKey[String]("The path to the api sub project. R
6262
lazy val create = TaskKey[Unit]("create", "Creates a new plugin. Interactive command using the console.")
6363
lazy val fetch = TaskKey[Unit]("fetch", "Searches for plugins in plugin directories, builds the plugin build file.")
6464
lazy val copy = TaskKey[Unit]("copy", "Copies all packaged plugin jars to the target plugin folder.")
65-
lazy val bootstrap = TaskKey[Unit]("bootstrap", "Creates a dependency list for the bootstrap project.")
65+
lazy val bs = TaskKey[Unit]("bs", "Updates the bootstrap project with current dependencies and chat overflow jars.")
6666

6767
pluginBuildFileName := "plugins.sbt"
6868
pluginFolderNames := List("plugins-public")
@@ -73,4 +73,4 @@ create := BuildUtility(streams.value.log).createPluginTask(pluginFolderNames.val
7373
fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
7474
pluginTargetFolderNames.value, apiProjectPath.value)
7575
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
76-
bootstrap := BootstrapUtility.bootstrapDependencyGenTask(streams.value.log)
76+
bs := BootstrapUtility.bootstrapGenTask(streams.value.log, s"$scalaMajorVersion$scalaMinorVersion")

dependencyList.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[info] chatoverflow:chatoverflow_2.12:0.2
2+
[info] chatoverflow-api:chatoverflow-api_2.12:1.0
3+
[info] com.fasterxml.jackson.core:jackson-annotations:2.8.0
4+
[info] com.fasterxml.jackson.core:jackson-core:2.8.4
5+
[info] com.fasterxml.jackson.core:jackson-databind:2.8.4
6+
[info] com.github.scopt:scopt_2.12:3.5.0
7+
[info] com.google.guava:guava:20.0
8+
[info] com.googlecode.juniversalchardet:juniversalchardet:1.0.3
9+
[info] com.thoughtworks.paranamer:paranamer:2.8
10+
[info] commons-codec:commons-codec:1.10
11+
[info] commons-logging:commons-logging:1.2
12+
[info] eu.medsea.mimeutil:mime-util:2.1.3
13+
[info] javax.servlet:javax.servlet-api:3.1.0
14+
[info] log4j:log4j:1.2.17
15+
[info] net.bytebuddy:byte-buddy:1.6.11
16+
[info] net.bytebuddy:byte-buddy-agent:1.6.11
17+
[info] org.apache.commons:commons-lang3:3.6
18+
[info] org.apache.httpcomponents:httpclient:4.5.3
19+
[info] org.apache.httpcomponents:httpcore:4.4.6
20+
[info] org.apache.httpcomponents:httpmime:4.5.3
21+
[info] org.eclipse.jetty:jetty-http:9.4.6.v20170531
22+
[info] org.eclipse.jetty:jetty-io:9.4.6.v20170531
23+
[info] org.eclipse.jetty:jetty-security:9.4.6.v20170531
24+
[info] org.eclipse.jetty:jetty-server:9.4.6.v20170531
25+
[info] org.eclipse.jetty:jetty-servlet:9.4.6.v20170531
26+
[info] org.eclipse.jetty:jetty-util:9.4.6.v20170531
27+
[info] org.eclipse.jetty:jetty-webapp:9.4.6.v20170531
28+
[info] org.eclipse.jetty:jetty-xml:9.4.6.v20170531
29+
[info] org.hamcrest:hamcrest-core:1.3
30+
[info] org.javassist:javassist:3.21.0-GA
31+
[info] org.json4s:json4s-ast_2.12:3.5.2
32+
[info] org.json4s:json4s-core_2.12:3.5.2
33+
[info] org.json4s:json4s-jackson_2.12:3.5.2
34+
[info] org.json4s:json4s-scalap_2.12:3.5.2
35+
[info] org.mockito:mockito-core:2.7.22
36+
[info] org.objenesis:objenesis:2.5
37+
[info] org.pircbotx:pircbotx:2.1
38+
[info] org.reflections:reflections:0.9.11
39+
[info] org.scala-lang:scala-compiler:2.12.5
40+
[info] org.scala-lang:scala-reflect:2.12.5
41+
[info] org.scala-lang.modules:scala-parser-combinators_2.12:1.0.6
42+
[info] org.scala-lang.modules:scala-xml_2.12:1.0.6
43+
[info] org.scala-sbt:test-interface:1.0
44+
[info] org.scalatra:scalatra-common_2.12:2.6.5
45+
[info] org.scalatra:scalatra-json_2.12:2.6.3
46+
[info] org.scalatra:scalatra-scalate_2.12:2.6.5
47+
[info] org.scalatra:scalatra-specs2_2.12:2.6.5
48+
[info] org.scalatra:scalatra-test_2.12:2.6.5
49+
[info] org.scalatra:scalatra_2.12:2.6.5
50+
[info] org.scalatra.scalate:scalate-core_2.12:1.8.0
51+
[info] org.scalatra.scalate:scalate-util_2.12:1.8.0
52+
[info] org.slf4j:slf4j-api:1.7.25
53+
[info] org.slf4j:slf4j-log4j12:1.7.22
54+
[info] org.specs2:classycle:1.4.3
55+
[info] org.specs2:specs2-analysis_2.12:4.0.1
56+
[info] org.specs2:specs2-common_2.12:4.0.1
57+
[info] org.specs2:specs2-core_2.12:4.0.1
58+
[info] org.specs2:specs2-fp_2.12:4.0.1
59+
[info] org.specs2:specs2-matcher-extra_2.12:4.0.1
60+
[info] org.specs2:specs2-matcher_2.12:4.0.1
61+
[info] org.specs2:specs2-mock_2.12:4.0.1

project/BootstrapUtility.scala

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.io.File
12
import java.net.{HttpURLConnection, URL}
23

34
import sbt.internal.util.ManagedLogger
@@ -31,8 +32,8 @@ class Dependency(dependencyString: String, logger: ManagedLogger) {
3132
// Test if the url exists
3233
val connection = new URL(url).openConnection.asInstanceOf[HttpURLConnection]
3334
connection.setRequestMethod("HEAD")
34-
connection.setConnectTimeout(5000)
35-
connection.setReadTimeout(5000)
35+
connection.setConnectTimeout(100)
36+
connection.setReadTimeout(100)
3637
val status = connection.getResponseCode
3738
connection.disconnect()
3839
available = status == 200
@@ -44,22 +45,56 @@ class Dependency(dependencyString: String, logger: ManagedLogger) {
4445
}
4546

4647
object BootstrapUtility {
48+
val dependencyListFileName = "dependencyList.txt"
49+
val dependencyXMLFileName = "bootstrap/src/main/resources/dependencies.xml"
4750

48-
def bootstrapDependencyGenTask(logger: ManagedLogger): Unit = {
51+
def bootstrapGenTask(logger: ManagedLogger, scalaLibraryVersion: String): Unit = {
4952
println("Welcome to the bootstrap generation utility. It's time to build!")
50-
println("Please enter the console output of the task 'dependencyList' without the intro part (so only the dependencies).")
51-
println("Should look like '[info] ... [info] ...'")
52-
println("> ")
5353

54-
// We just assume that the building guy knows what he's doing, lol
55-
val input = scala.io.Source.fromInputStream(System.in).bufferedReader().readLine()
54+
// Dependency management
55+
val dependencyList = retrieveDependencies(logger, scalaLibraryVersion)
56+
saveDependencyXML(dependencyList, logger)
5657

57-
// Splits the lines at the info tag of the console output
58-
val lines = input.replaceFirst("\\[info\\] ", "").split(" \\[info\\] ")
59-
val dependencies = for (line <- lines) yield new Dependency(line, logger)
58+
// Copy built jar files
59+
copyJars(logger)
60+
}
61+
62+
private def saveDependencyXML(dependencyList: List[Dependency], logger: ManagedLogger): Unit = {
63+
64+
}
6065

61-
// Modify dependencies: Remove ChatOverflow, add scala library
66+
private def copyJars(logger: ManagedLogger): Unit = {
6267
}
6368

69+
private def retrieveDependencies(logger: ManagedLogger, scalaLibraryVersion: String): List[Dependency] = {
70+
71+
val dependencyFile = new File(dependencyListFileName)
72+
73+
if (!dependencyFile.exists()) {
74+
logger error "No dependency file found. Please copy the output of the task 'dependencyList' into a file named 'dependencyList.txt' in the root folder."
75+
List[Dependency]()
76+
} else {
77+
78+
// Load file, remove the info tag and create dependency objects
79+
val input = scala.io.Source.fromFile(dependencyFile).getLines().toList
80+
val lines = input.map(line => line.replaceFirst("\\[info\\] ", ""))
81+
val dependencies = for (line <- lines) yield new Dependency(line, logger)
82+
83+
// Modify dependencies: Remove ChatOverflow, add scala library
84+
val depsWithoutChatOverflow = dependencies.filter(d =>
85+
d.nameWithoutScalaVersion != "chatoverflow" && d.nameWithoutScalaVersion != "chatoverflow-api")
86+
val modifiedDependencies = depsWithoutChatOverflow ++
87+
List(new Dependency(s"org.scala-lang:scala-library:$scalaLibraryVersion", logger))
88+
89+
// Info output
90+
logger info s"Found ${modifiedDependencies.length} dependencies."
91+
if (modifiedDependencies.exists(d => !d.available)) {
92+
logger warn "Found the following dependencies, that could not be retrieved online:"
93+
logger warn modifiedDependencies.filter(d => !d.available).map(_.toString).mkString("\n")
94+
}
95+
96+
modifiedDependencies
97+
}
98+
}
6499

65100
}

0 commit comments

Comments
 (0)