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

Commit 108c8b5

Browse files
committed
Fixed dependency testing bug.
1 parent b960268 commit 108c8b5

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

project/BootstrapUtility.scala

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,39 @@ class Dependency(dependencyString: String, logger: ManagedLogger) {
2929
url = mavenCentralFormat.format(depAuthor.replaceAll("\\.", "/"), s"$combinedName",
3030
depVersion, s"$combinedName-$depVersion")
3131

32-
// Test if the url exists
33-
val connection = new URL(url).openConnection.asInstanceOf[HttpURLConnection]
34-
connection.setRequestMethod("HEAD")
35-
connection.setConnectTimeout(100)
36-
connection.setReadTimeout(100)
37-
val status = connection.getResponseCode
38-
connection.disconnect()
39-
available = status == 200
32+
available = testURL(0, 3)
33+
4034
case _ =>
4135
logger warn s"Invalid dependency format: '$dependencyString'."
4236
}
4337
}
4438

39+
private def testURL(recursionCount: Int, recursionLimit: Int): Boolean = {
40+
41+
var status = -1
42+
43+
try {
44+
45+
// Test if the url exists
46+
val connection = new URL(url).openConnection.asInstanceOf[HttpURLConnection]
47+
connection.setRequestMethod("HEAD")
48+
connection.setConnectTimeout(200)
49+
connection.setReadTimeout(200)
50+
status = connection.getResponseCode
51+
connection.disconnect()
52+
53+
} catch {
54+
case e: Exception => logger warn s"Error while testing dependency (attempt $recursionCount of $recursionLimit)" +
55+
s" availability of ${this}: ${e.getMessage}"
56+
}
57+
58+
if (status != 200 && recursionCount + 1 <= recursionLimit) {
59+
testURL(recursionCount + 1, recursionLimit)
60+
} else {
61+
status == 200
62+
}
63+
}
64+
4565
}
4666

4767
object BootstrapUtility {
@@ -61,25 +81,36 @@ object BootstrapUtility {
6181

6282
private def saveDependencyXML(dependencyList: List[Dependency], logger: ManagedLogger): Unit = {
6383

84+
logger info "Started saving dependency XML."
85+
6486
}
6587

6688
private def copyJars(logger: ManagedLogger): Unit = {
6789
}
6890

6991
private def retrieveDependencies(logger: ManagedLogger, scalaLibraryVersion: String): List[Dependency] = {
7092

93+
logger info "Starting dependency retrieval."
94+
7195
val dependencyFile = new File(dependencyListFileName)
7296

7397
if (!dependencyFile.exists()) {
7498
logger error "No dependency file found. Please copy the output of the task 'dependencyList' into a file named 'dependencyList.txt' in the root folder."
7599
List[Dependency]()
76100
} else {
77101

102+
logger info "Found dependency file."
103+
78104
// Load file, remove the info tag and create dependency objects
79105
val input = scala.io.Source.fromFile(dependencyFile).getLines().toList
80106
val lines = input.map(line => line.replaceFirst("\\[info\\] ", ""))
107+
108+
logger info "Read dependencies successfully. Creating dependency list."
109+
81110
val dependencies = for (line <- lines) yield new Dependency(line, logger)
82111

112+
logger info "Updating and modifying dependencies..."
113+
83114
// Modify dependencies: Remove ChatOverflow, add scala library
84115
val depsWithoutChatOverflow = dependencies.filter(d =>
85116
d.nameWithoutScalaVersion != "chatoverflow" && d.nameWithoutScalaVersion != "chatoverflow-api")

0 commit comments

Comments
 (0)