Skip to content

Commit 0e253ef

Browse files
committed
use plugin.properties
1 parent 32e6faa commit 0e253ef

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed

compiler/src/dotty/tools/dotc/plugins/Plugin.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dotty.tools.io._
88
import transform.MegaPhase.MiniPhase
99

1010
import java.io.InputStream
11-
import java.util.Scanner
11+
import java.util.Properties
1212

1313
import scala.collection.mutable
1414
import scala.util.{ Try, Success, Failure }
@@ -59,7 +59,7 @@ trait ResearchPlugin extends Plugin {
5959

6060
object Plugin {
6161

62-
private val PluginFile = "plugin"
62+
private val PluginFile = "plugin.properties"
6363

6464
/** Create a class loader with the specified locations plus
6565
* the loader that loaded the Scala compiler.
@@ -101,10 +101,13 @@ object Plugin {
101101
{
102102

103103
def fromFile(inputStream: InputStream): String = {
104-
val s = new Scanner(inputStream)
104+
val props = new Properties
105+
props.load(inputStream)
105106

106-
if (s.hasNext) s.nextLine.trim
107-
else throw new RuntimeException("Bad plugin descriptor.")
107+
val pluginClass = props.getProperty("pluginClass")
108+
109+
if (pluginClass == null) throw new RuntimeException("Bad plugin descriptor.")
110+
else pluginClass
108111
}
109112

110113
def loadDescriptionFromDir(f: Path): Try[String] =

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class CompilationTests extends ParallelTesting {
314314
}
315315

316316
@Test def testPlugins: Unit = {
317-
val pluginFile = "plugin"
317+
val pluginFile = "plugin.properties"
318318

319319
// 1. hack with absolute path for -Xplugin
320320
// 2. copy `pluginFile` to destination

sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/src/main/resources/plugin

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pluginClass=dividezero.DivideZero

tests/plugins/neg/divideZero-research/plugin

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pluginClass=DivideZero

tests/plugins/neg/divideZero/plugin

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pluginClass=DivideZero

0 commit comments

Comments
 (0)