bundle Kotlin plugin with IDEA, use bundled runtime from plugin
authorDmitry Jemerov <yole@jetbrains.com>
Mon, 29 Jun 2015 15:59:23 +0000 (17:59 +0200)
committerDmitry Jemerov <yole@jetbrains.com>
Mon, 29 Jun 2015 16:00:36 +0000 (18:00 +0200)
.idea/libraries/KotlinJavaRuntime.xml
README.md
build.xml
build/.gitignore
build/download_kotlin.xml [new file with mode: 0644]
build/gant.xml
build/scripts/layouts.gant
build/scripts/libLicenses.gant
build/scripts/utils.gant
lib/.gitignore [new file with mode: 0644]

index e89a0a33a6bb4f8f7a025280c25f9405017160ec..54188de91d6e95d975f1cf9b18fd0edede9e3c07 100644 (file)
@@ -1,11 +1,10 @@
 <component name="libraryTable">
   <library name="KotlinJavaRuntime">
     <CLASSES>
-      <root url="jar://$PROJECT_DIR$/build/kotlinc/lib/kotlin-runtime.jar!/" />
+      <root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar!/" />
+      <root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
     </CLASSES>
     <JAVADOC />
-    <SOURCES>
-      <root url="jar://$PROJECT_DIR$/build/kotlinc/lib/kotlin-runtime-sources.jar!/" />
-    </SOURCES>
+    <SOURCES />
   </library>
 </component>
\ No newline at end of file
index 2ce0a9819d8f8785743a82d7dd69707e411a424c..148813f1918e49163ed88438882189f9a05f65ca 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
 ### Building and Running from the IDE
 To develop IntelliJ IDEA, you can use either IntelliJ IDEA Community Edition or IntelliJ IDEA Ultimate. To build and run the code:
 * Run **getPlugins.sh** / **getPlugins.bat** from the project root directory to check out additional modules.
+* Install the **Kotlin plugin** from the plugin manager (version 0.12.613). Parts of IntelliJ IDEA are written in Kotlin, and you need the plugin to compile the code.
 * Make sure you have the **Groovy** plugin enabled. Parts of IntelliJ IDEA are written in Groovy, and you will get compilation errors if you don't have the plugin enabled.
 * Make sure you have the **UI Designer** plugin enabled. Most of IntelliJ IDEA's UI is built using the **UI Designer**, and the version you build will not run correctly if you don't have the plugin enabled.
 * Open the project.
index 8e6bdbcfa22632ee9be107ec851dc7fc63e7b79b..d4cd47e2fe3aea238b216c525dbe8d42896ea29f 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -10,6 +10,7 @@
   <target name="init">
     <mkdir dir="${out.dir}"/>
     <mkdir dir="${tmp.dir}"/>
+    <ant dir="build" antfile="download_kotlin.xml"/>
   </target>
 
   <macrodef name="call_gant">
index b6e2bc7704d054133846636a54be01e406d095e8..39bb4e104911caffd2d8dad994321305d99ef4ce 100644 (file)
@@ -1,2 +1,3 @@
 /kotlinc/
 /jdk/
+kotlin-plugin*.zip
diff --git a/build/download_kotlin.xml b/build/download_kotlin.xml
new file mode 100644 (file)
index 0000000..36e0de7
--- /dev/null
@@ -0,0 +1,37 @@
+<project name="Download Kotlin" default="extract">
+  <property name="kotlin.version" value="0.12.613"/>
+  <property name="kotlin.build.type.id" value="Kotlin_M12_Idea142branch150version"/>
+  <property name="kotlin.build.selector" value=".lastSuccessful"/>
+
+  <target name="check_present">
+    <pathconvert property="kotlin.path" setonempty="false" pathsep=" ">
+      <path>
+        <fileset dir="${basedir}" includes="kotlin-plugin-${kotlin.version}*.zip"/>
+      </path>
+    </pathconvert>
+  </target>
+
+  <target name="download" depends="check_present" unless="kotlin.path">
+    <loadresource property="kotlin.build.number">
+      <url url="https://teamcity.jetbrains.com/guestAuth/app/rest/buildTypes/id:${kotlin.build.type.id}/builds/status:SUCCESS,count:1/number"/>
+    </loadresource>
+    <echo message="Downloading Kotlin build ${kotlin.build.number}"/>
+    <property name="kotlin.path" value="${basedir}/kotlin-plugin-${kotlin.build.number}.zip"/>
+    <get src="https://teamcity.jetbrains.com/guestAuth/repository/download/${kotlin.build.type.id}/${kotlin.build.number}/kotlin-plugin-${kotlin.build.number}.zip"
+         dest="${kotlin.path}"/>
+  </target>
+
+  <target name="extract" depends="download">
+    <unzip src="${kotlin.path}" dest="${basedir}/kotlinc/plugin"/>
+
+    <unzip src="${kotlin.path}" dest="${basedir}">
+      <patternset includes="Kotlin/kotlinc/**"/>
+      <globmapper from="Kotlin/*" to="*"/>
+    </unzip>
+
+    <unzip src="${kotlin.path}" dest="${basedir}/kotlinc/jps">
+      <patternset includes="Kotlin/lib/jps/**"/>
+      <globmapper from="Kotlin/lib/jps/*" to="*"/>
+    </unzip>
+  </target>
+</project>
index 349c59a23129f41a3175d824740d624b22eecfc6..8a7460997353cbc52e089af0364bd5c13e004979 100644 (file)
@@ -24,7 +24,7 @@
     <fileset dir="${project.home}/build/kotlinc/lib" erroronmissingdir="false">
       <include name="kotlin-runtime.jar"/>
     </fileset>
-    <fileset dir="${project.home}/build/kotlinc/plugin" erroronmissingdir="false">
+    <fileset dir="${project.home}/build/kotlinc/plugin/Kotlin/lib" erroronmissingdir="false">
       <include name="kotlin-plugin.jar"/>
     </fileset>
     <fileset dir="${idea.lib}">
index 7d8cc30070c0a09db3fff52eefbd21fa07ee242c..31f0f876af5d157feb8209cf8b8b3ac5d7776333 100644 (file)
@@ -592,6 +592,10 @@ public def layoutCommunityPlugins(String home) {
         }
       }
     }
+
+    pluginDir("Kotlin") {
+      fileset(dir: "${home}/build/kotlinc/plugin/Kotlin")
+    }
   }
 }
 
@@ -692,6 +696,7 @@ def reorder(String home, String targetDirectory) {
     arg(value: "${home}/lib")
     classpath {
       projectBuilder.moduleRuntimeClasspath(findModule("util"), false).each {
+        println(it)
         pathelement(location: it)
       }
     }
index 942c59cf0a37361f209a6efe89ba8adec3399844..e301961d88040051d3990324aa2a0ed4383093e0 100644 (file)
@@ -295,3 +295,4 @@ jetbrainsLibrary("JPS")
 jetbrainsLibrary("Maven Embedder")
 jetbrainsLibrary("tcServiceMessages")
 jetbrainsLibrary("optimizedFileManager.jar")
+jetbrainsLibrary("KotlinJavaRuntime")
index 1827cd54bda60169489887671de6477657a50dc6..474b7c2a7e92f5a28573e2cbc16bb732f742193d 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+
+
 import com.intellij.openapi.util.SystemInfo
 import com.intellij.openapi.util.io.FileUtil
 import org.jetbrains.jps.gant.JpsGantTool
@@ -24,6 +26,7 @@ import org.jetbrains.jps.model.java.JpsJavaExtensionService
 import org.jetbrains.jps.model.java.JpsJavaSdkType
 import org.jetbrains.jps.model.library.JpsOrderRootType
 import org.jetbrains.jps.model.module.JpsModule
+import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
 
 includeTool << JpsGantTool
 
@@ -134,6 +137,15 @@ binding.setVariable("guessHome", {
 binding.setVariable("loadProject", {
   defineJdk("IDEA jdk", setupJdkPath("jdkHome", "$home/build/jdk/1.6", "JDK_16_x64"))
   defineJdk("1.8", setupJdkPath("jdk8Home", "$home/build/jdk/1.8", "JDK_18_x64"))
+  def bundledKotlinPath = "$home/build/kotlinc"
+  if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
+    bundledKotlinPath = "$home/community/build/kotlinc"
+  }
+  if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
+    projectBuilder.error("Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar")
+    return
+  }
+  setPathVariable("KOTLIN_BUNDLED", bundledKotlinPath)
   projectBuilder.buildIncrementally = Boolean.parseBoolean(p("jps.build.incrementally", "false"))
   def dataDirName = projectBuilder.buildIncrementally ? ".jps-incremental-build" : ".jps-build-data"
   projectBuilder.dataStorageRoot = new File("$home/$dataDirName")
@@ -209,6 +221,11 @@ private void defineJdk(String jdkName, jdkHomePath) {
   }
 }
 
+private void setPathVariable(String name, String value) {
+  def pathVars = JpsModelSerializationDataService.getOrCreatePathVariablesConfiguration(global)
+  pathVars.addPathVariable(name, value)
+}
+
 binding.setVariable("prepareOutputFolder", {
   def targetFolder = projectBuilder.buildIncrementally ? "$home/out/incremental-build" : out
   projectBuilder.targetFolder = targetFolder
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644 (file)
index 0000000..0ca1c5c
--- /dev/null
@@ -0,0 +1,2 @@
+kotlin-runtime.jar
+kotlin-reflect.jar