bundle Kotlin plugin with IDEA, use bundled runtime from plugin

This commit is contained in:
Dmitry Jemerov
2015-06-29 17:59:23 +02:00
parent 57f98ab8bb
commit fd9cbccb19
10 changed files with 69 additions and 5 deletions

View 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>

View File

@@ -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.

View File

@@ -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">

1
build/.gitignore vendored
View File

@@ -1,2 +1,3 @@
/kotlinc/
/jdk/
kotlin-plugin*.zip

37
build/download_kotlin.xml Normal file
View File

@@ -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>

View 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}">

View 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)
}
}

View File

@@ -295,3 +295,4 @@ jetbrainsLibrary("JPS")
jetbrainsLibrary("Maven Embedder")
jetbrainsLibrary("tcServiceMessages")
jetbrainsLibrary("optimizedFileManager.jar")
jetbrainsLibrary("KotlinJavaRuntime")

View 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

2
lib/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
kotlin-runtime.jar
kotlin-reflect.jar