summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-03-22 10:00:22 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2016-03-22 10:00:22 +0100
commit2b3696ec4134f08ae37414f1406a87e746bc6128 (patch)
tree6bdc55ba88cfdb62ecf52f36384d3a65d5cb2f53
parent5f5cc186cbedff6dc55993cb3b0dcfe36038efa1 (diff)
downloadscala-2b3696ec4134f08ae37414f1406a87e746bc6128.tar.gz
scala-2b3696ec4134f08ae37414f1406a87e746bc6128.tar.bz2
scala-2b3696ec4134f08ae37414f1406a87e746bc6128.zip
Cleanup IntelliJ integration based on review feedback
-rw-r--r--build.sbt66
1 files changed, 35 insertions, 31 deletions
diff --git a/build.sbt b/build.sbt
index 3ef4cbf2b5..5b9036deb4 100644
--- a/build.sbt
+++ b/build.sbt
@@ -853,7 +853,11 @@ addCommandAlias("scalap", "scalap/compile:runMain scala.tools.sca
lazy val intellij = taskKey[Unit]("Update the library classpaths in the IntelliJ project files.")
-def moduleDeps(name: String) = Def.taskDyn { Def.task((name, (externalDependencyClasspath in Compile in LocalProject(name)).value.map(_.data))) }
+def moduleDeps(p: Project) = (externalDependencyClasspath in Compile in p).map(a => (p.id, a.map(_.data)))
+
+// aliases to projects to prevent name clashes
+def compilerP = compiler
+def testP = test
intellij := {
import xml._
@@ -866,30 +870,30 @@ intellij := {
val buildModule = ("scala-build", scalabuild.BuildInfo.buildClasspath.split(":").toSeq.map(new File(_)))
// `sbt projects` lists all modules in the build
buildModule :: List(
- moduleDeps("actors").value,
- moduleDeps("compiler").value,
- // moduleDeps("dist").value, // No sources, therefore no module in IntelliJ
- moduleDeps("forkjoin").value,
- moduleDeps("interactive").value,
- moduleDeps("junit").value,
- moduleDeps("library").value,
- // moduleDeps("library-all").value, // No sources
- moduleDeps("manual").value,
- moduleDeps("partest-extras").value,
- moduleDeps("partest-javaagent").value,
- moduleDeps("reflect").value,
- moduleDeps("repl").value,
- moduleDeps("repl-jline").value,
- // moduleDeps("repl-jline-embedded").value, // No sources
- // moduleDeps("root").value, // No sources
- // moduleDeps("scala-dist").value, // No sources
- moduleDeps("scaladoc").value,
- moduleDeps("scalap").value,
- moduleDeps("test").value)
+ moduleDeps(actors).value,
+ moduleDeps(compilerP).value,
+ // moduleDeps(dist).value, // No sources, therefore no module in IntelliJ
+ moduleDeps(forkjoin).value,
+ moduleDeps(interactive).value,
+ moduleDeps(junit).value,
+ moduleDeps(library).value,
+ // moduleDeps(libraryAll).value, // No sources
+ moduleDeps(manual).value,
+ moduleDeps(partestExtras).value,
+ moduleDeps(partestJavaAgent).value,
+ moduleDeps(reflect).value,
+ moduleDeps(repl).value,
+ moduleDeps(replJline).value,
+ // moduleDeps(replJlineEmbedded).value, // No sources
+ // moduleDeps(root).value, // No sources
+ // moduleDeps(scalaDist).value, // No sources
+ moduleDeps(scaladoc).value,
+ moduleDeps(scalap).value,
+ moduleDeps(testP).value)
}
def moduleDep(name: String, jars: Seq[File]) = {
- val entries = jars.map(f => s""" <root url="jar://${f.getCanonicalPath}!/" />""").mkString("\n")
+ val entries = jars.map(f => s""" <root url="jar://${f.toURI.getRawPath}!/" />""").mkString("\n")
s"""| <library name="${name}-deps">
| <CLASSES>
|$entries
@@ -900,7 +904,7 @@ intellij := {
}
def starrDep(jars: Seq[File]) = {
- val entries = jars.map(f => s""" <root url="file://${f.getCanonicalPath}" />""").mkString("\n")
+ val entries = jars.map(f => s""" <root url="file://${f.toURI.getRawPath}" />""").mkString("\n")
s"""| <library name="starr" type="Scala">
| <properties>
| <option name="languageLevel" value="Scala_2_12" />
@@ -935,7 +939,7 @@ intellij := {
}
object trans extends RuleTransformer(rule)
val r = trans(data)
- if (!rule.transformed) error(s"Replacing library classpath for $libName failed, no existing library found.")
+ if (!rule.transformed) sys.error(s"Replacing library classpath for $libName failed, no existing library found.")
r
}
@@ -943,13 +947,13 @@ intellij := {
var continue = false
if (!ipr.exists) {
- scala.Console.print(s"Could not find src/intellij/scala.ipr. Create new project files from src/intellij/*.SAMPLE (y/n)? ")
+ scala.Console.print(s"Could not find src/intellij/scala.ipr. Create new project files from src/intellij/*.SAMPLE (y/N)? ")
if (scala.Console.readLine() == "y") {
intellijCreateFromSample((baseDirectory in ThisBuild).value)
continue = true
}
} else {
- scala.Console.print("Update library classpaths in the current src/intellij/scala.ipr (y/n)? ")
+ scala.Console.print("Update library classpaths in the current src/intellij/scala.ipr (y/N)? ")
continue = scala.Console.readLine() == "y"
}
if (continue) {
@@ -963,7 +967,7 @@ intellij := {
else replaceLibrary(res, s"$modName-deps", None, moduleDep(modName, jars))
})
- XML.save(ipr.getCanonicalPath, newModules)
+ XML.save(ipr.getAbsolutePath, newModules)
} else {
s.log.info("Aborting.")
}
@@ -973,7 +977,7 @@ lazy val intellijFromSample = taskKey[Unit]("Create fresh IntelliJ project files
intellijFromSample := {
val s = streams.value
- scala.Console.print(s"Create new project files from src/intellij/*.SAMPLE (y/n)? ")
+ scala.Console.print(s"Create new project files from src/intellij/*.SAMPLE (y/N)? ")
if (scala.Console.readLine() == "y")
intellijCreateFromSample((baseDirectory in ThisBuild).value)
else
@@ -982,7 +986,7 @@ intellijFromSample := {
def intellijCreateFromSample(basedir: File): Unit = {
val files = basedir / "src/intellij" * "*.SAMPLE"
- val copies = files.get.map(f => (f, new File(f.getCanonicalPath.stripSuffix(".SAMPLE"))))
+ val copies = files.get.map(f => (f, new File(f.getAbsolutePath.stripSuffix(".SAMPLE"))))
IO.copy(copies, overwrite = true)
}
@@ -990,13 +994,13 @@ lazy val intellijToSample = taskKey[Unit]("Update src/intellij/*.SAMPLE using th
intellijToSample := {
val s = streams.value
- scala.Console.print(s"Update src/intellij/*.SAMPLE using the current IntelliJ project files (y/n)? ")
+ scala.Console.print(s"Update src/intellij/*.SAMPLE using the current IntelliJ project files (y/N)? ")
if (scala.Console.readLine() == "y") {
val basedir = (baseDirectory in ThisBuild).value
val existing = basedir / "src/intellij" * "*.SAMPLE"
IO.delete(existing.get)
val current = basedir / "src/intellij" * ("*.iml" || "*.ipr")
- val copies = current.get.map(f => (f, new File(f.getCanonicalPath + ".SAMPLE")))
+ val copies = current.get.map(f => (f, new File(f.getAbsolutePath + ".SAMPLE")))
IO.copy(copies)
} else
s.log.info("Aborting.")