summaryrefslogtreecommitdiff
path: root/core/src/main/scala/forge/eval/Evaluator.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-07 21:10:06 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-07 21:11:03 -0800
commitee080e63971399ceb22fd8f059a97e956d9f0dcb (patch)
treeaa4ce5a9b6647835fbdae11266621f13d24dcfcb /core/src/main/scala/forge/eval/Evaluator.scala
parentca02aef2c98079c695fa616c75ab05a693c9d512 (diff)
downloadmill-ee080e63971399ceb22fd8f059a97e956d9f0dcb.tar.gz
mill-ee080e63971399ceb22fd8f059a97e956d9f0dcb.tar.bz2
mill-ee080e63971399ceb22fd8f059a97e956d9f0dcb.zip
- Allow main methods to return `Target[T]`s, so they can then be evaled by an external `Evaluator` that has the `Discovered` mapping available
- Basic integration tests for `T.command` entrypoint running in the `JavaCompilerJarTests` suite
Diffstat (limited to 'core/src/main/scala/forge/eval/Evaluator.scala')
-rw-r--r--core/src/main/scala/forge/eval/Evaluator.scala25
1 files changed, 15 insertions, 10 deletions
diff --git a/core/src/main/scala/forge/eval/Evaluator.scala b/core/src/main/scala/forge/eval/Evaluator.scala
index 19cd3236..590b5534 100644
--- a/core/src/main/scala/forge/eval/Evaluator.scala
+++ b/core/src/main/scala/forge/eval/Evaluator.scala
@@ -48,13 +48,16 @@ class Evaluator(workspacePath: Path,
externalInputs.toIterator.map(results).toVector.hashCode +
group.toIterator.map(_.sideHash).toVector.hashCode()
- val primeLabel = labeling(terminals.items(0)).segments
-
-
- val targetDestPath = workspacePath / primeLabel
- val metadataPath = targetDestPath / up / (targetDestPath.last + ".forge.json")
+ val (targetDestPath, metadataPath) = labeling.get(terminals.items(0)) match{
+ case Some(labeling) =>
+ val targetDestPath = workspacePath / labeling.segments
+ val metadataPath = targetDestPath / up / (targetDestPath.last + ".forge.json")
+ (targetDestPath, Some(metadataPath))
+ case None => (null, None)
+ }
val cached = for{
+ metadataPath <- metadataPath
json <- scala.util.Try(Json.parse(read.getInputStream(metadataPath))).toOption
(cachedHash, terminalResults) <- Json.fromJson[(Int, Seq[JsValue])](json).asOpt
if cachedHash == inputsHash
@@ -71,11 +74,13 @@ class Evaluator(workspacePath: Path,
case _ =>
val (newResults, newEvaluated, terminalResults) = evaluateGroup(group, results, targetDestPath)
- write.over(
- metadataPath,
- Json.prettyPrint(
- Json.toJson(inputsHash -> terminals.toList.map(terminalResults))
- ),
+ metadataPath.foreach(
+ write.over(
+ _,
+ Json.prettyPrint(
+ Json.toJson(inputsHash -> terminals.toList.map(terminalResults))
+ ),
+ )
)
(newResults, newEvaluated)