diff options
author | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2017-04-06 10:56:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-06 10:56:42 -0400 |
commit | 16ac805f1a3669b3bcca160e523e3d8cf4c7cc2b (patch) | |
tree | 686727fc21107b7ea66f1f7efa883e32994dfbb1 | |
parent | 2f6aaac52ac0b6afabf83ed8bd75cf5ea72ee78f (diff) | |
parent | 34f3d10608d6f11deb90979066d69d31b7a8fe4f (diff) | |
download | cbt-16ac805f1a3669b3bcca160e523e3d8cf4c7cc2b.tar.gz cbt-16ac805f1a3669b3bcca160e523e3d8cf4c7cc2b.tar.bz2 cbt-16ac805f1a3669b3bcca160e523e3d8cf4c7cc2b.zip |
Merge pull request #416 from cvogt/idea-plugin
Add IntelliJ IDEA project generator plugin
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | build/build.scala | 3 | ||||
-rw-r--r-- | examples/intellij/README.md | 1 | ||||
-rw-r--r-- | examples/intellij/build/build.scala | 5 | ||||
-rw-r--r-- | examples/intellij/src/Main.scala | 3 | ||||
-rw-r--r-- | stage2/plugins/IntelliJ.scala | 70 |
6 files changed, 83 insertions, 1 deletions
@@ -19,3 +19,5 @@ examples/scalajs-react-example/server/public/generated test/simple/src_generated examples/scalapb-example/src_generated ScalatexGenerated.scala +.idea/ +*.iml diff --git a/build/build.scala b/build/build.scala index 4635159..74bf6da 100644 --- a/build/build.scala +++ b/build/build.scala @@ -2,7 +2,7 @@ package cbt_build.cbt import cbt._ import cbt_internal._ -class Build(val context: Context) extends Shared with Scalariform with PublishLocal{ +class Build(val context: Context) extends Shared with Scalariform with PublishLocal with CommandLineOverrides{ override def name: String = "cbt" override def version: String = "0.1" override def description: String = "Fast, intuitive Build Tool for Scala" @@ -24,6 +24,7 @@ class Build(val context: Context) extends Shared with Scalariform with PublishLo Seq( context.cbtHome / "stage2" / "DirectoryDependency.scala", context.cbtHome / "stage2" / "LazyDependency.scala", + context.cbtHome / "stage2" / "plugins" / "IntelliJ.scala", context.cbtHome / "stage2" / "plugins" / "ScalaTest.scala", context.cbtHome / "stage2" / "plugins" / "Scalatex.scala", context.cbtHome / "stage2" / "plugins" / "Tut.scala", diff --git a/examples/intellij/README.md b/examples/intellij/README.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/examples/intellij/README.md @@ -0,0 +1 @@ + diff --git a/examples/intellij/build/build.scala b/examples/intellij/build/build.scala new file mode 100644 index 0000000..921cf40 --- /dev/null +++ b/examples/intellij/build/build.scala @@ -0,0 +1,5 @@ +import cbt._ + +class Build(val context: Context) extends BaseBuild with IntelliJ { + override def name = "idea-plugin-example" +} diff --git a/examples/intellij/src/Main.scala b/examples/intellij/src/Main.scala new file mode 100644 index 0000000..407a577 --- /dev/null +++ b/examples/intellij/src/Main.scala @@ -0,0 +1,3 @@ +object Main extends App { + println("This is an example Application for illustrating CBT IntelliJ project generator") +} diff --git a/stage2/plugins/IntelliJ.scala b/stage2/plugins/IntelliJ.scala new file mode 100644 index 0000000..c41ea51 --- /dev/null +++ b/stage2/plugins/IntelliJ.scala @@ -0,0 +1,70 @@ +package cbt + +import java.io.{ File, FileWriter } + +trait IntelliJ extends BaseBuild { + private // this plugin is not functional right now, needs fixing + def intellij = { + lib.writeIfChanged( + projectDirectory / name ++ ".iml", + IntelliJ.iml( + scalaVersion, + transitiveDependencies + ) + ) + } +} + +// TODO: +// - projects, their builds, their build builds, etc should be represented individually +// ideally with cbt's main sources being editable, but not the sources of other cbt versions +object IntelliJ { + def iml( + scalaVersion: String, + transitiveDependencies: Seq[Dependency] + ): String = { + """<?xml version="1.0" encoding="UTF-8"?>""" ++ "\n" ++ +// format: OFF +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output/> + <content url="file://$MODULE_DIR$/../cbt/compatibility"> + <sourceFolder url="file://$MODULE_DIR$/../cbt/compatibility" isTestSource="false"/> + <excludeFolder url="file://$MODULE_DIR$/../cbt/compatibility/target/scala-2.11"/> + </content> + <content url="file://$MODULE_DIR$/../cbt/nailgun_launcher"> + <sourceFolder url="file://$MODULE_DIR$/../cbt/nailgun_launcher" isTestSource="false"/> + <excludeFolder url="file://$MODULE_DIR$/../cbt/nailgun_launcher/target"/> + </content> + <content url="file://$MODULE_DIR$/../cbt/stage1"> + <sourceFolder url="file://$MODULE_DIR$/../cbt/stage1" isTestSource="false"/> + <excludeFolder url="file://$MODULE_DIR$/../cbt/stage1/target/scala-2.11"/> + </content> + <content url="file://$MODULE_DIR$/../cbt/stage2"> + <sourceFolder url="file://$MODULE_DIR$/../cbt/stage2" isTestSource="false"/> + <excludeFolder url="file://$MODULE_DIR$/../cbt/stage2/target/scala-2.11"/> + </content> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/main/scala/main" isTestSource="false"/> + <sourceFolder url="file://$MODULE_DIR$/src/test/scala" isTestSource="false"/> + </content> + <orderEntry type="inheritedJdk"/> + <orderEntry type="sourceFolder" forTests="false"/> + <orderEntry type="library" name="scala-sdk-{scalaVersion}" level="application"/> + { + transitiveDependencies.flatMap( _.exportedClasspath.files ).map( _.string ).map { cp => + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url={ if ( cp.endsWith( ".jar" ) ) s"jar://$cp!/" else s"file://$cp/" }/> + </CLASSES> + <JAVADOC/> + <SOURCES/> + </library> + </orderEntry> + } + } + </component> +</module>.buildString( stripComments = false ) // format: ON + } +} |