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

Commit c59b51b

Browse files
committed
Started implementing the bootstrap dependency generation task.
1 parent 1b24f09 commit c59b51b

File tree

4 files changed

+133
-2
lines changed

4 files changed

+133
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<dependecies>
2+
</dependecies>

bootstrap/src/main/scala/Bootstrap.scala

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,70 @@ object Bootstrap {
1313
4. Make fat jar with only the scala lib inside (and the chat overflow files?)
1414
*/
1515

16+
/*
17+
Test content:
18+
http://central.maven.org/maven2/log4j/log4j/1.2.17/log4j-1.2.17.jar
19+
[info] chatoverflow:chatoverflow_2.12:0.2
20+
[info] chatoverflow-api:chatoverflow-api_2.12:1.0
21+
[info] com.fasterxml.jackson.core:jackson-annotations:2.8.0
22+
[info] com.fasterxml.jackson.core:jackson-core:2.8.4
23+
[info] com.fasterxml.jackson.core:jackson-databind:2.8.4
24+
[info] com.github.scopt:scopt_2.12:3.5.0
25+
[info] com.google.guava:guava:20.0
26+
[info] com.googlecode.juniversalchardet:juniversalchardet:1.0.3
27+
[info] com.thoughtworks.paranamer:paranamer:2.8
28+
[info] commons-codec:commons-codec:1.10
29+
[info] commons-logging:commons-logging:1.2
30+
[info] eu.medsea.mimeutil:mime-util:2.1.3
31+
[info] javax.servlet:javax.servlet-api:3.1.0
32+
[info] log4j:log4j:1.2.17
33+
[info] net.bytebuddy:byte-buddy:1.6.11
34+
[info] net.bytebuddy:byte-buddy-agent:1.6.11
35+
[info] org.apache.commons:commons-lang3:3.6
36+
[info] org.apache.httpcomponents:httpclient:4.5.3
37+
[info] org.apache.httpcomponents:httpcore:4.4.6
38+
[info] org.apache.httpcomponents:httpmime:4.5.3
39+
[info] org.eclipse.jetty:jetty-http:9.4.6.v20170531
40+
[info] org.eclipse.jetty:jetty-io:9.4.6.v20170531
41+
[info] org.eclipse.jetty:jetty-security:9.4.6.v20170531
42+
[info] org.eclipse.jetty:jetty-server:9.4.6.v20170531
43+
[info] org.eclipse.jetty:jetty-servlet:9.4.6.v20170531
44+
[info] org.eclipse.jetty:jetty-util:9.4.6.v20170531
45+
[info] org.eclipse.jetty:jetty-webapp:9.4.6.v20170531
46+
[info] org.eclipse.jetty:jetty-xml:9.4.6.v20170531
47+
[info] org.hamcrest:hamcrest-core:1.3
48+
[info] org.javassist:javassist:3.21.0-GA
49+
[info] org.json4s:json4s-ast_2.12:3.5.2
50+
[info] org.json4s:json4s-core_2.12:3.5.2
51+
[info] org.json4s:json4s-jackson_2.12:3.5.2
52+
[info] org.json4s:json4s-scalap_2.12:3.5.2
53+
[info] org.mockito:mockito-core:2.7.22
54+
[info] org.objenesis:objenesis:2.5
55+
[info] org.pircbotx:pircbotx:2.1
56+
[info] org.reflections:reflections:0.9.11
57+
[info] org.scala-lang:scala-compiler:2.12.5
58+
[info] org.scala-lang:scala-reflect:2.12.5
59+
[info] org.scala-lang.modules:scala-parser-combinators_2.12:1.0.6
60+
[info] org.scala-lang.modules:scala-xml_2.12:1.0.6
61+
[info] org.scala-sbt:test-interface:1.0
62+
[info] org.scalatra:scalatra-common_2.12:2.6.4
63+
[info] org.scalatra:scalatra-json_2.12:2.6.3
64+
[info] org.scalatra:scalatra-scalate_2.12:2.6.4
65+
[info] org.scalatra:scalatra-specs2_2.12:2.6.4
66+
[info] org.scalatra:scalatra-test_2.12:2.6.4
67+
[info] org.scalatra:scalatra_2.12:2.6.4
68+
[info] org.scalatra.scalate:scalate-core_2.12:1.8.0
69+
[info] org.scalatra.scalate:scalate-util_2.12:1.8.0
70+
[info] org.slf4j:slf4j-api:1.7.25
71+
[info] org.slf4j:slf4j-log4j12:1.7.22
72+
[info] org.specs2:classycle:1.4.3
73+
[info] org.specs2:specs2-analysis_2.12:4.0.1
74+
[info] org.specs2:specs2-common_2.12:4.0.1
75+
[info] org.specs2:specs2-core_2.12:4.0.1
76+
[info] org.specs2:specs2-fp_2.12:4.0.1
77+
[info] org.specs2:specs2-matcher-extra_2.12:4.0.1
78+
[info] org.specs2:specs2-matcher_2.12:4.0.1
79+
[info] org.specs2:specs2-mock_2.12:4.0.1
80+
*/
81+
1682
}

build.sbt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inThisBuild(List(
1515
)
1616

1717
// Link the bootstrap launcher
18-
lazy val bootstrap = project in file("bootstrap")
18+
lazy val bootstrapProject = project in file("bootstrap")
1919

2020
// ---------------------------------------------------------------------------------------------------------------------
2121
// LIBRARY DEPENDENCIES
@@ -62,6 +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.")
6566

6667
pluginBuildFileName := "plugins.sbt"
6768
pluginFolderNames := List("plugins-public")
@@ -71,4 +72,5 @@ apiProjectPath := "api"
7172
create := BuildUtility(streams.value.log).createPluginTask(pluginFolderNames.value)
7273
fetch := BuildUtility(streams.value.log).fetchPluginsTask(pluginFolderNames.value, pluginBuildFileName.value,
7374
pluginTargetFolderNames.value, apiProjectPath.value)
74-
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
75+
copy := BuildUtility(streams.value.log).copyPluginsTask(pluginFolderNames.value, pluginTargetFolderNames.value, scalaMajorVersion)
76+
bootstrap := BootstrapUtility.bootstrapDependencyGenTask(streams.value.log)

project/BootstrapUtility.scala

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import sbt.internal.util.ManagedLogger
2+
3+
class Dependency(dependencyString: String, logger: ManagedLogger) {
4+
var nameWithoutScalaVersion = ""
5+
var version = ""
6+
var url = ""
7+
var available = false
8+
create()
9+
10+
private def create(): Unit = {
11+
val DependencyRegex = "([^:]+):([^:_]+)(_[^:]+)?:([^:]+)".r
12+
// TODO: HTTPS?
13+
val mavenCentralFormat = "http://central.maven.org/maven2/%s/%s/%s/%s.jar"
14+
15+
dependencyString match {
16+
case DependencyRegex(depAuthor, depName, scalaVersion, depVersion) =>
17+
this.nameWithoutScalaVersion = depName
18+
this.version = depVersion
19+
20+
val combinedName = if (scalaVersion != null) depName + scalaVersion else depName
21+
22+
// Create URL for maven central
23+
url = mavenCentralFormat.format(depAuthor.replaceAll("\\.", "/"), s"$combinedName",
24+
depVersion, s"$combinedName-$depVersion")
25+
26+
logger info url
27+
// TODO: Test availability of URL without full download (?), save into available
28+
case _ =>
29+
logger warn s"Invalid dependency format: '$dependencyString'."
30+
}
31+
}
32+
33+
}
34+
35+
object BootstrapUtility {
36+
37+
def bootstrapDependencyGenTask(logger: ManagedLogger): Unit = {
38+
println("Welcome to the bootstrap generation utility. It's time to build!")
39+
println("Please enter the console output of the task 'dependencyList' without the intro part (so only the dependencies).")
40+
println("Should look like '[info] ... [info] ...'")
41+
println("> ")
42+
43+
// We just assume that the building guy knows what he's doing, lol
44+
val input = scala.io.Source.fromInputStream(System.in).bufferedReader().readLine()
45+
46+
// Splits the lines at the info tag of the console output
47+
val lines = input.replaceFirst("\\[info\\] ", "").split(" \\[info\\] ")
48+
val dependencies = for (line <- lines) yield new Dependency(line, logger)
49+
50+
//val testString = "[info] log4j:log4j:1.2.17"
51+
//logger info testString
52+
//logger info removeInfo(testString)
53+
//new Dependency(removeInfo(testString), logger)
54+
}
55+
56+
private def removeInfo(dependencyString: String): String = {
57+
val InfoRegex = "^\\[info\\] ".r
58+
InfoRegex.replaceFirstIn(dependencyString, "")
59+
}
60+
61+
}

0 commit comments

Comments
 (0)