次のようにインプロセスでプラグインを実行して、プラグインをテストしています。
type PluginMessage = StoreReporter#Info
def runPlugin(fileName: String): List[PluginMessage] = {
val settings = new Settings
settings.outputDirs setSingleOutput (curDir + "/target")
settings.classpath.tryToSet(List(
"project/boot/scala-" + scalaVersion + "/lib/scala-compiler.jar" +
":project/boot/scala-" + scalaVersion + "/lib/scala-library.jar"))
val reporter = new StoreReporter
val compiler = new Global(settings, reporter) {
override protected def computeInternalPhases() {
super.computeInternalPhases
for (phase <- new AlacsPlugin(this).components)
phasesSet += phase
}
}
(new compiler.Run).compile(List(testPrefix + fileName))
reporter.infos.toList
}
ただし、速度が遅いscalac
ため、特定のフェーズの後 (具体的には、プラグインの実行後) にコンパイルを終了したいと考えています。残念ながらGlobal.cancel
、意図した効果はありません。どうすればこれを行うことができますか?