Skip to content

Commit 3c560fe

Browse files
authored
Merge pull request scala#11112 from lrytz/ij
Remove custom IntelliJ project files
2 parents 7137904 + 5648fcd commit 3c560fe

27 files changed

+8
-1160
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
/sandbox/
3535

3636
# intellij
37-
/src/intellij*/*.iml
38-
/src/intellij*/*.ipr
39-
/src/intellij*/*.iws
4037
**/.cache
4138
/.idea
4239
/.settings

.idea/icon.png

-78.1 KB
Binary file not shown.

README.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ but also:
9090
scala/
9191
+---/library-aux Scala Auxiliary Library, for bootstrapping and documentation purposes
9292
+---/interactive Scala Interactive Compiler, for clients such as an IDE (aka Presentation Compiler)
93-
+---/intellij IntelliJ project templates
9493
+---/manual Scala's runner scripts "man" (manual) pages
9594
+---/partest Scala's internal parallel testing framework
9695
+---/partest-javaagent Partest's helper java agent
@@ -201,34 +200,18 @@ temporarily commenting them out in `~/.sbt/1.0/plugins/plugins.sbt`).
201200
We recommend keeping local test files in the `sandbox` directory which is listed in
202201
the `.gitignore` of the Scala repo.
203202

204-
#### Incremental compilation
205-
206-
Note that sbt's incremental compilation is often too coarse for the Scala compiler
207-
codebase and re-compiles too many files, resulting in long build times (check
208-
[sbt#1104](https://github.com/sbt/sbt/issues/1104) for progress on that front). In the
209-
meantime you can:
210-
- Use IntelliJ IDEA for incremental compiles (see [IDE Setup](#ide-setup) below) - its
211-
incremental compiler is a bit less conservative, but usually correct.
212-
213203
### IDE setup
214204

215-
We suggest using IntelliJ IDEA (see
216-
[src/intellij/README.md](src/intellij/README.md)).
217-
218-
[Metals](https://scalameta.org/metals/) may also work, but we don't
219-
yet have instructions or sample configuration for that. A pull request
220-
in this area would be exceedingly welcome. In the meantime, we are
221-
collecting guidance at
222-
[scala/scala-dev#668](https://github.com/scala/scala-dev/issues/668).
205+
In IntelliJ IDEA, use "File - Open...", select the project folder and use
206+
"Open as: sbt project".
207+
- JUnit tests can be launched / debugged from the IDE, including tests that
208+
run the compiler (e.g., `QuickfixTest`).
209+
- Building in IntelliJ interoperates with the sbt build; the compiler script in
210+
`build/quick/bin` (generated by running `sbt dist/mkBin`) runs the classfiles
211+
built via the IDE.
223212

224-
In order to use IntelliJ's incremental compiler:
225-
- run `dist/mkBin` in sbt to get a build and the runner scripts in `build/quick/bin`
226-
- run "Build" - "Make Project" in IntelliJ
213+
In VSCode / Metals, open the project directory and import the project as ususal.
227214

228-
Now you can edit and build in IntelliJ and use the scripts (compiler, REPL) to
229-
directly test your changes. You can also run the `scala`, `scalac` and `partest`
230-
commands in sbt. Enable "Ant mode" (explained above) to prevent sbt's incremental
231-
compiler from re-compiling (too many) files before each `partest` invocation.
232215

233216
# Coding guidelines
234217

build.sbt

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,164 +1488,9 @@ commands ++= {
14881488

14891489
addCommandAlias("scalap", "scalap/compile:runMain scala.tools.scalap.Main -usejavacp")
14901490

1491-
lazy val intellij = taskKey[Unit]("Update the library classpaths in the IntelliJ project files.")
1492-
1493-
def moduleDeps(p: Project, config: Configuration = Compile) = (p / config / externalDependencyClasspath).map(a => (p.id, a.map(_.data)))
1494-
14951491
// aliases to projects to prevent name clashes
1496-
def compilerP = compiler
14971492
def testP = test
14981493

1499-
intellij := {
1500-
import xml._
1501-
import xml.transform._
1502-
1503-
val s = streams.value
1504-
val compilerScalaInstance = (LocalProject("compiler") / scalaInstance).value
1505-
1506-
val modules: List[(String, Seq[File])] = {
1507-
// for the sbt build module, the dependencies are fetched from the project's build using sbt-buildinfo
1508-
val buildModule = ("scala-build", scalabuild.BuildInfo.buildClasspath.split(java.io.File.pathSeparator).toSeq.map(new File(_)))
1509-
// `sbt projects` lists all modules in the build
1510-
buildModule :: List(
1511-
moduleDeps(bench).value,
1512-
moduleDeps(compilerP).value,
1513-
moduleDeps(interactive).value,
1514-
moduleDeps(junit).value,
1515-
moduleDeps(library).value,
1516-
moduleDeps(manual).value,
1517-
moduleDeps(partest).value,
1518-
moduleDeps(partestJavaAgent).value,
1519-
moduleDeps(reflect).value,
1520-
moduleDeps(repl).value,
1521-
moduleDeps(replFrontend).value,
1522-
moduleDeps(scalacheck, config = Test).value.copy(_1 = "scalacheck-test"),
1523-
moduleDeps(scaladoc).value,
1524-
moduleDeps(scalap).value,
1525-
moduleDeps(tastytest).value,
1526-
moduleDeps(testP).value,
1527-
moduleDeps(testkit).value,
1528-
)
1529-
}
1530-
1531-
def moduleDep(name: String, jars: Seq[File]) = {
1532-
val entries = jars.map(f => s""" <root url="jar://${f.toURI.getPath}!/" />""").mkString("\n")
1533-
s"""| <library name="$name-deps">
1534-
| <CLASSES>
1535-
|$entries
1536-
| </CLASSES>
1537-
| <JAVADOC />
1538-
| <SOURCES />
1539-
| </library>""".stripMargin
1540-
}
1541-
1542-
def starrDep(jars: Seq[File]) = {
1543-
val entries = jars.map(f => s""" <root url="file://${f.toURI.getPath}" />""").mkString("\n")
1544-
s"""| <library name="starr" type="Scala">
1545-
| <properties>
1546-
| <option name="languageLevel" value="Scala_2_12" />
1547-
| <compiler-classpath>
1548-
|$entries
1549-
| </compiler-classpath>
1550-
| </properties>
1551-
| <CLASSES />
1552-
| <JAVADOC />
1553-
| <SOURCES />
1554-
| </library>""".stripMargin
1555-
}
1556-
1557-
def replaceLibrary(data: Node, libName: String, libType: Option[String], newContent: String) = {
1558-
object rule extends RewriteRule {
1559-
var transformed = false
1560-
def checkAttrs(attrs: MetaData) = {
1561-
def check(key: String, expected: String) = {
1562-
val a = attrs(key)
1563-
a != null && a.text == expected
1564-
}
1565-
check("name", libName) && libType.forall(tp => check("type", tp))
1566-
}
1567-
1568-
override def transform(n: Node): Seq[Node] = n match {
1569-
case e @ Elem(_, "library", attrs, _, _*) if checkAttrs(attrs) =>
1570-
transformed = true
1571-
XML.loadString(newContent)
1572-
case other =>
1573-
other
1574-
}
1575-
}
1576-
object trans extends RuleTransformer(rule)
1577-
val r = trans(data)
1578-
if (!rule.transformed) sys.error(s"Replacing library classpath for $libName failed, no existing library found.")
1579-
r
1580-
}
1581-
1582-
val intellijDir = (ThisBuild / baseDirectory).value / "src/intellij"
1583-
val ipr = intellijDir / "scala.ipr"
1584-
backupIdea(intellijDir)
1585-
if (!ipr.exists) {
1586-
intellijCreateFromSample((ThisBuild / baseDirectory).value)
1587-
}
1588-
s.log.info("Updating library classpaths in src/intellij/scala.ipr.")
1589-
val content = XML.loadFile(ipr)
1590-
1591-
val newStarr = replaceLibrary(content, "starr", Some("Scala"), starrDep(compilerScalaInstance.allJars))
1592-
val newModules = modules.foldLeft(newStarr)({
1593-
case (res, (modName, jars)) =>
1594-
if (jars.isEmpty) res // modules without dependencies
1595-
else replaceLibrary(res, s"$modName-deps", None, moduleDep(modName, jars))
1596-
})
1597-
1598-
// I can't figure out how to keep the entity escapes for \n in the attribute values after this use of XML transform.
1599-
// Patching the original version back in with more brutish parsing.
1600-
val R = """(?ims)(.*)(<copyright>.*</copyright>)(.*)""".r
1601-
val oldContents = IO.read(ipr)
1602-
XML.save(ipr.getAbsolutePath, newModules)
1603-
oldContents match {
1604-
case R(_, withEscapes, _) =>
1605-
val newContents = IO.read(ipr)
1606-
val R(pre, toReplace, post) = newContents
1607-
IO.write(ipr, pre + withEscapes + post)
1608-
case _ =>
1609-
// .ipr file hasn't been updated from `intellijFromSample` yet
1610-
}
1611-
}
1612-
1613-
lazy val intellijFromSample = taskKey[Unit]("Create fresh IntelliJ project files from src/intellij/*.SAMPLE.")
1614-
1615-
def backupIdea(ideaDir: File): Unit = {
1616-
val temp = IO.createTemporaryDirectory
1617-
IO.copyDirectory(ideaDir, temp)
1618-
println(s"Backed up existing src/intellij to $temp")
1619-
}
1620-
1621-
intellijFromSample := {
1622-
val s = streams.value
1623-
val intellijDir = (ThisBuild / baseDirectory).value / "src/intellij"
1624-
val ipr = intellijDir / "scala.ipr"
1625-
backupIdea(intellijDir)
1626-
intellijCreateFromSample((ThisBuild / baseDirectory).value)
1627-
}
1628-
1629-
def intellijCreateFromSample(basedir: File): Unit = {
1630-
val files = basedir / "src/intellij" * "*.SAMPLE"
1631-
val copies = files.get.map(f => (f, new File(f.getAbsolutePath.stripSuffix(".SAMPLE"))))
1632-
IO.copy(copies, CopyOptions() withOverwrite true)
1633-
}
1634-
1635-
lazy val intellijToSample = taskKey[Unit]("Update src/intellij/*.SAMPLE using the current IntelliJ project files.")
1636-
1637-
intellijToSample := {
1638-
val s = streams.value
1639-
val intellijDir = (ThisBuild / baseDirectory).value / "src/intellij"
1640-
val ipr = intellijDir / "scala.ipr"
1641-
backupIdea(intellijDir)
1642-
val existing =intellijDir * "*.SAMPLE"
1643-
IO.delete(existing.get)
1644-
val current = intellijDir * ("*.iml" || "*.ipr")
1645-
val copies = current.get.map(f => (f, new File(f.getAbsolutePath + ".SAMPLE")))
1646-
IO.copy(copies)
1647-
}
1648-
16491494
/** Find a specific module's JAR in a classpath, comparing only organization and name */
16501495
def findJar(files: Seq[Attributed[File]], dep: ModuleID): Option[Attributed[File]] = {
16511496
def extract(m: ModuleID) = (m.organization, m.name)

project/plugins.sbt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.18.0"
1010

1111
libraryDependencies += "biz.aQute.bnd" % "biz.aQute.bndlib" % "6.1.0"
1212

13-
enablePlugins(BuildInfoPlugin)
14-
15-
// configure sbt-buildinfo to send the externalDependencyClasspath to the main build, which allows using it for the IntelliJ project config
16-
17-
lazy val buildClasspath = taskKey[String]("Colon-separated (or semicolon-separated in case of Windows) list of entries on the sbt build classpath.")
18-
19-
buildClasspath := (Compile / externalDependencyClasspath).value.map(_.data).mkString(java.io.File.pathSeparator)
20-
21-
buildInfoKeys := Seq[BuildInfoKey](buildClasspath)
22-
23-
buildInfoPackage := "scalabuild"
24-
2513
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4")
2614

2715
libraryDependencies ++= Seq(

project/project/plugins.sbt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/intellij/README.md

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/intellij/benchmarks.iml.SAMPLE

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/intellij/compiler.iml.SAMPLE

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)