diff --git a/.gitignore b/.gitignore
index c5016fde3e91..41224fe891fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+build/dependencies/.gradle
+build/dependencies/build
/android
/config
/system
@@ -7,3 +9,5 @@
/test-system
/test-config
*.pyc
+.idea/libraries/Gradle__*.xml
+.idea/gradle_extensions.xml
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 000000000000..14a9ba34adb3
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 430c128405c2..6158046516c6 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -65,6 +65,7 @@
+
@@ -167,7 +168,7 @@
-
+
@@ -194,7 +195,7 @@
-
+
@@ -263,7 +264,7 @@
-
+
diff --git a/build.xml b/build.xml
index 33716395f4f7..851b0e6ee3b0 100644
--- a/build.xml
+++ b/build.xml
@@ -37,16 +37,13 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/build/build.iml b/build/build.iml
index 075656c3d6a6..b3a996123689 100644
--- a/build/build.iml
+++ b/build/build.iml
@@ -5,6 +5,7 @@
+
diff --git a/build/dependencies/build.gradle b/build/dependencies/build.gradle
new file mode 100644
index 000000000000..e7c767606088
--- /dev/null
+++ b/build/dependencies/build.gradle
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+buildscript {
+ repositories {
+ maven { url "http://repo.labs.intellij.net/plugins-gradle-org/" }
+ maven { url "https://plugins.gradle.org/m2/" }
+ }
+ dependencies {
+ classpath "de.undercouch:gradle-download-task:3.2.0"
+ }
+}
+
+apply plugin: "de.undercouch.download"
+apply plugin: 'base'
+
+group 'com.intellij.build'
+version '1.0'
+
+try {
+ project.ext.inJetBrainsNetwork = InetAddress.getByName("repo.labs.intellij.net").isReachable(300)
+}
+catch (UnknownHostException ignore) {
+ project.ext.inJetBrainsNetwork = false
+}
+
+apply from: 'setupJdk.gradle'
+apply from: 'setupKotlin.gradle'
+apply from: 'setupJetSign.gradle'
+
+task setupDependencies(dependsOn: ['setupJdks', 'setupKotlinPlugin', 'setupJetSign'], group: 'dependencies')
+clean.dependsOn('cleanSetupJdks', 'cleanSetupKotlinPlugin',
+ 'cleanDownloadJre', 'downloadJdk18', 'cleanSetupJdk16', 'cleanSetupJdk18', 'cleanSetupJetSign')
+
+task wrapper(type: Wrapper) {
+ // 2.14 is the latest version supports Java 6 (which is still present on TeamCity build agents)
+ gradleVersion = '2.14'
+}
\ No newline at end of file
diff --git a/build/dependencies/dependencies.iml b/build/dependencies/dependencies.iml
new file mode 100644
index 000000000000..e32a091ed56f
--- /dev/null
+++ b/build/dependencies/dependencies.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/dependencies/gradle.properties b/build/dependencies/gradle.properties
new file mode 100644
index 000000000000..d1cd86b3fd0f
--- /dev/null
+++ b/build/dependencies/gradle.properties
@@ -0,0 +1,3 @@
+jdkBuild=u112b752.4
+kotlinPluginBuild=1.1.0-release-IJ2017.1-1
+jetSignBuild=42.30
\ No newline at end of file
diff --git a/build/dependencies/gradle/wrapper/gradle-wrapper.jar b/build/dependencies/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000000..0bcc53af302f
Binary files /dev/null and b/build/dependencies/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/build/dependencies/gradle/wrapper/gradle-wrapper.properties b/build/dependencies/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000000..8129803d391d
--- /dev/null
+++ b/build/dependencies/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Feb 17 14:30:05 MSK 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip
diff --git a/build/dependencies/gradlew b/build/dependencies/gradlew
new file mode 100755
index 000000000000..4453ccea33d9
--- /dev/null
+++ b/build/dependencies/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save ( ) {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/build/dependencies/gradlew.bat b/build/dependencies/gradlew.bat
new file mode 100644
index 000000000000..f9553162f122
--- /dev/null
+++ b/build/dependencies/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/build/dependencies/settings.gradle b/build/dependencies/settings.gradle
new file mode 100644
index 000000000000..155a87622cc3
--- /dev/null
+++ b/build/dependencies/settings.gradle
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+rootProject.name = 'dependencies'
\ No newline at end of file
diff --git a/build/dependencies/setupJdk.gradle b/build/dependencies/setupJdk.gradle
new file mode 100644
index 000000000000..04dbf7de0b83
--- /dev/null
+++ b/build/dependencies/setupJdk.gradle
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+task setupJdks(dependsOn: ['downloadJre', 'setupJdk18', 'setupJdk16'])
+
+def jdkRepo = inJetBrainsNetwork ? 'http://repo.labs.intellij.net' : 'https://dl.bintray.com/jetbrains/'
+
+def checkoutDir = intellijProjectDir()
+def jdkDir = "$checkoutDir/build/jdk"
+
+project.ext.platformToDirectory = [linux: 'linux', osx: 'mac', windows: 'win']
+project.ext.jdk18OutputDir = "${System.getProperty("intellij.jdk18.output.dir", "$jdkDir/1.8")}"
+project.ext.targetOs = "${System.getProperty("intellij.build.target.os", "all")}"
+
+task downloadJre {}
+
+jrePlatformsToDownload(targetOs).each { platform ->
+ archToDownload(platform).each { arch ->
+ task("downloadJbrex_${platform}_$arch") {
+ def outputDir = "$jdkDir/${platformToDirectory[platform]}"
+ def artifactName = "jbrex8${jdkBuild}_${platform}_$arch"
+
+ inputs.property('build', jdkBuild)
+ outputs.file("$outputDir/${artifactName}.tar.gz")
+ doLast {
+ logger.info("Setting up JRE 1.8 to bundle for ${platform}_$arch (usin $jdkRepo repo)")
+ downloadJdk(jdkRepo, artifactName, outputDir)
+ }
+ }
+ downloadJre.dependsOn("downloadJbrex_${platform}_$arch")
+ cleanDownloadJre.dependsOn("cleanDownloadJbrex_${platform}_$arch")
+
+ task("untarJbre_${platform}_$arch", type: Copy) {
+ def downloadOutputs = tasks["downloadJbrex_${platform}_$arch"].outputs.files
+ from tarTree(downloadOutputs.singleFile)
+ exclude "**/tools.jar"
+ into { "${downloadOutputs.singleFile.parent}/${downloadOutputs.singleFile.name.replace("jbrex", "jbre") - '.tar.gz'}/" }
+ }
+
+ task("tarJbre_${platform}_$arch", type: Tar) {
+ def untarOutputs = tasks["untarJbre_${platform}_$arch"].outputs.files
+ from untarOutputs
+ compression = Compression.GZIP
+ archiveName = "${untarOutputs.singleFile.name}.tar.gz"
+ destinationDir = untarOutputs.singleFile.parentFile
+ }
+ downloadJre.dependsOn("tarJbre_${platform}_$arch")
+ cleanDownloadJre.dependsOn("cleanTarJbre_${platform}_$arch")
+ }
+}
+
+task downloadJdk18 {
+ def os = org.gradle.internal.os.OperatingSystem.current()
+ def arch = !os.isWindows() || !os.nativePrefix.endsWith('x86') ? 'x64' : 'x86'
+ def platform = currentPlatformName()
+
+ def outputDir = "$jdkDir/${platformToDirectory[platform]}"
+ def artifactName = "jbsdk8${jdkBuild}_${platform}_$arch"
+
+ inputs.property('build', jdkBuild)
+ outputs.file("$outputDir/${artifactName}.tar.gz")
+ doLast {
+ logger.info("Downloading up JDK 1.8 to compile (using $jdkRepo repo)")
+ downloadJdk(jdkRepo, artifactName, outputDir)
+ }
+}
+
+task setupJdk18() {
+ def outputDir = jdk18OutputDir
+ def downloadOutputs = downloadJdk18.outputs.files
+
+ inputs.files(downloadOutputs)
+ inputs.property("jdk18OutputDir", outputDir)
+ outputs.dir(outputDir)
+ doLast {
+ logger.info("Setting up JDK 1.8 to compile")
+ unpackJdk(downloadOutputs.singleFile, outputDir)
+ }
+}
+
+def unpackJdk(jdkArchive, outputDir) {
+ logger.info("Unpacking $jdkArchive to ${outputDir}")
+ file(outputDir).deleteDir()
+ copy {
+ from tarTree(jdkArchive)
+ into outputDir
+ }
+ def jdkContents = file("${outputDir}/jdk/Contents")
+ if (org.gradle.internal.os.OperatingSystem.current().isMacOsX() && jdkContents.exists()) {
+ copy {
+ from fileTree(jdkContents)
+ into outputDir
+ }
+ jdkContents.deleteDir()
+ }
+}
+
+def downloadJdk(jdkRepo, artifact, outputDir) {
+ logger.info("Downloading $artifact to $outputDir")
+ download {
+ src "$jdkRepo/intellij-jdk/${artifact}.tar.gz"
+ dest "$outputDir/${artifact}.tar.gz"
+ onlyIfNewer true
+ }
+}
+
+static def currentPlatformName() {
+ def os = org.gradle.internal.os.OperatingSystem.current()
+ if (os.isWindows()) {
+ "windows"
+ }
+ else if (os.isMacOsX()) {
+ "osx"
+ }
+ else {
+ "linux"
+ }
+}
+
+// see org.jetbrains.intellij.build.BuildOptions.targetOS
+static def jrePlatformsToDownload(targetOs) {
+ def jrePlatformToDownload = new HashSet()
+ if (targetOs == 'all' || targetOs == 'linux') jrePlatformToDownload.add('linux')
+ if (targetOs == 'all' || targetOs == 'windows') jrePlatformToDownload.add('windows')
+ if (targetOs == 'all' || targetOs == 'mac') jrePlatformToDownload.add('osx')
+ jrePlatformToDownload
+}
+
+static def archToDownload(targetOs) {
+ targetOs == 'windows' ? ['x86', 'x64'] : ['x64']
+}
+
+// JDK 1.6
+repositories {
+ maven {
+ url 'http://repo.labs.intellij.net/java'
+ }
+}
+
+configurations {
+ jdk16
+}
+
+dependencies {
+ jdk16 "jetbrains:jre:${jdk16Version()}@tar.gz"
+}
+
+task setupJdk16(dependsOn: configurations.jdk16) {
+ if (!inJetBrainsNetwork) {
+ return
+ }
+
+ def jdkArchive = { configurations.jdk16.singleFile }
+ def outputDir = "$jdkDir/1.6"
+ inputs.file(jdkArchive)
+ outputs.dir(outputDir)
+
+ doLast {
+ logger.info("Setting up JDK 1.6 to compile")
+ unpackJdk(jdkArchive, outputDir)
+ }
+}
+
+def intellijProjectDir() {
+ def communityDir = project.file("../..")
+ communityDir.name == 'community' ? communityDir.parent : communityDir
+}
+
+static def jdk16Version() {
+ def os = org.gradle.internal.os.OperatingSystem.current()
+ if (os.isWindows()) {
+ def suffix = os.nativePrefix.endsWith('x86') ? "_i586" : "x64"
+ return "6.45:windows_$suffix"
+ }
+ else if (os.isMacOsX()) {
+ return '6.65:macosx_x64'
+ }
+ return '6.45:linux_x64'
+}
\ No newline at end of file
diff --git a/build/dependencies/setupJetSign.gradle b/build/dependencies/setupJetSign.gradle
new file mode 100644
index 000000000000..ec641e90e71e
--- /dev/null
+++ b/build/dependencies/setupJetSign.gradle
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+repositories {
+ maven {
+ url 'http://repo.labs.intellij.net/jet-sign'
+ }
+}
+
+configurations {
+ jetSign
+}
+
+dependencies {
+ jetSign "com.jetbrains:jet-sign:${jetSignBuild}"
+}
+
+task setupJetSign(dependsOn: configurations.jetSign) {
+ if (!inJetBrainsNetwork) {
+ return
+ }
+ def ultimateProjectDir = ultimateProjectDir()
+ if (!ultimateProjectDir) {
+ return
+ }
+
+ doFirst { logger.info("Setting up JetSign") }
+ def jetSignJar = { configurations.jetSign.singleFile }
+ def outputDir = file("$ultimateProjectDir/build/lib/")
+ inputs.file(jetSignJar)
+ outputs.file("$outputDir/jet-sign.jar")
+
+ doLast {
+ logger.info("Copying $jetSignJar to $outputDir")
+ copy {
+ from file(jetSignJar)
+ into outputDir
+ rename '.+\\.jar', 'jet-sign.jar'
+ }
+ }
+}
+
+def ultimateProjectDir() {
+ def communityDir = project.file("../..")
+ communityDir.name == 'community' ? communityDir.parent : null
+}
\ No newline at end of file
diff --git a/build/dependencies/setupKotlin.gradle b/build/dependencies/setupKotlin.gradle
new file mode 100644
index 000000000000..3f5eb2ef7dde
--- /dev/null
+++ b/build/dependencies/setupKotlin.gradle
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+repositories {
+ maven {
+ url 'http://repo.labs.intellij.net/plugins.jetbrains.com'
+ }
+ maven {
+ url 'http://plugins.jetbrains.com/maven/'
+ }
+}
+
+configurations {
+ kotlinPlugin
+}
+
+dependencies {
+ kotlinPlugin "com.jetbrains.plugins:org.jetbrains.kotlin:$kotlinPluginBuild@zip"
+}
+
+task setupKotlinPlugin(dependsOn: configurations.kotlinPlugin) {
+ def kotlinPluginArchive = { configurations.kotlinPlugin.singleFile }
+ inputs.file(kotlinPluginArchive)
+ def outputDir = project.buildDir
+ outputs.dir("$outputDir/Kotlin")
+
+ doFirst { logger.info("Setting up Kotlin") }
+ doLast {
+ logger.info("Unpack ${kotlinPluginArchive.call()} to $outputDir")
+ copy {
+ from zipTree(kotlinPluginArchive.call())
+ into outputDir
+ }
+ }
+}
\ No newline at end of file
diff --git a/build/gant.xml b/build/gant.xml
index 4d193422827b..f5d132f4df94 100644
--- a/build/gant.xml
+++ b/build/gant.xml
@@ -21,14 +21,14 @@
-
+
-
+
-
+
diff --git a/build/groovy/org/jetbrains/intellij/build/BaseIdeaProperties.groovy b/build/groovy/org/jetbrains/intellij/build/BaseIdeaProperties.groovy
index dffaa82f0322..bebed024e0f9 100644
--- a/build/groovy/org/jetbrains/intellij/build/BaseIdeaProperties.groovy
+++ b/build/groovy/org/jetbrains/intellij/build/BaseIdeaProperties.groovy
@@ -128,7 +128,7 @@ abstract class BaseIdeaProperties extends ProductProperties {
}
}
context.ant.copy(todir: "$targetDirectory/plugins/Kotlin") {
- fileset(dir: "$context.paths.communityHome/build/kotlinc/plugin/Kotlin")
+ fileset(dir: "$context.paths.communityHome/build/dependencies/build/Kotlin")
}
context.ant.move(file: "$targetDirectory/lib/annotations-java8.jar", tofile: "$targetDirectory/redist/annotations-java8.jar")
}
diff --git a/build/scripts/unpackJdks.gant b/build/scripts/unpackJdks.gant
index 356b40f3f0bb..1a0de9f8b51a 100644
--- a/build/scripts/unpackJdks.gant
+++ b/build/scripts/unpackJdks.gant
@@ -1,6 +1,4 @@
-import com.intellij.openapi.util.SystemInfoRt
-import com.intellij.openapi.util.io.FileUtilRt
-import org.apache.tools.ant.BuildException
+import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
/*
* Copyright 2000-2016 JetBrains s.r.o.
@@ -18,92 +16,22 @@ import org.apache.tools.ant.BuildException
* limitations under the License.
*/
+includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
+
target(default: "Unpack JDKs") {
- unpackJdks()
-}
-
-def unpackJdks() {
- String home = guessHome(this)
- def osDirName = SystemInfoRt.isWindows ? "win" : SystemInfoRt.isMac ? "mac" : "linux"
- String basePath
- if (new File(home).getName().equals("community")) {
- basePath = new File(home).getParent()
- }
- else {
- basePath = home
- }
-
- def jdkDir = new File(basePath, "build/jdk")
- def osDir = new File(jdkDir, osDirName)
- if (!osDir.isDirectory()) {
- ant.project.log("Cannot unpack JDK: $osDir not found")
- return
- }
-
- unpackJdk(osDir, jdkDir, "jre6", "1.6")
- unpackJdk(osDir, jdkDir, "jbsdk8", "1.8")
-}
-
-private void unpackJdk(File osDir, File jdkDir, String archiveFileNamePrefix, String targetDirectoryName) {
- def jdkFiles = osDir.listFiles().findAll { it.name.startsWith(archiveFileNamePrefix) }
- if (SystemInfoRt.isWindows) {
- def arch = System.getenv("ProgramFiles(x86)") != null ? "x64" : "x86"
- jdkFiles = jdkFiles.findAll { it.name.endsWith("_${arch}.tar.gz") }
- }
- if (SystemInfoRt.isLinux) {
- jdkFiles = jdkFiles.findAll { it.name.endsWith("64.tar.gz") }
- }
- if (jdkFiles.empty) {
- throw new BuildException("Cannot unpack JDK: $archiveFileNamePrefix not found in $osDir")
- }
- if (jdkFiles.size() > 1) {
- throw new BuildException("Cannot unpack JDK: several matching files are found ($jdkFiles)")
- }
-
- File jdkFile = jdkFiles.first()
- def destDir = new File(jdkDir, targetDirectoryName)
- FileUtilRt.delete(destDir)
- ant.project.log("Extracting $jdkFile to $destDir")
- ant.mkdir(dir: destDir)
-
- if (jdkFile.name.endsWith(".tar.gz")) {
- if (SystemInfoRt.isWindows) {
- ant.untar(src: jdkFile, dest: destDir, compression: 'gzip')
- }
- else {
- //'tar' and 'mv' commands are used instead of Ant tasks to ensure that executable flag and symlink will be preserved
- ant.exec(executable: "tar", dir: jdkFile.getParent()) {
- arg(value: "-xf")
- arg(value: jdkFile.name)
- arg(value: "--directory")
- arg(value: destDir)
- }
- def jdkContents = new File(destDir, "jdk/Contents")
- if (SystemInfoRt.isMac && jdkContents.exists()) {
- jdkContents.listFiles().each { file ->
- ant.exec(executable: "mv", dir: destDir) {
- arg(value: file.absolutePath)
- arg(value: destDir)
- }
- }
- }
- }
- }
- else {
- throw new BuildException("Cannot unpack JDK: unknown extension of file '${jdkFile.name}'")
+ def workingDirectory = getDependenciesProjectDir()
+ def gradleScript = System.getProperty('os.name').toLowerCase().contains('windows') ? "gradlew.bat" : "gradlew"
+ def process = new ProcessBuilder("${workingDirectory.absolutePath}/$gradleScript", 'setupJdks', '--stacktrace', '--info')
+ .directory(workingDirectory)
+ .start()
+ process.consumeProcessOutputStream((OutputStream)System.out)
+ process.consumeProcessErrorStream((OutputStream)System.err)
+ process.waitFor()
+ if (process.exitValue() != 0) {
+ projectBuilder.error("Cannot unpack JDK")
}
}
-static String guessHome(Script script) {
- File home = new File(script["gant.file"].substring("file:".length()))
-
- while (home != null) {
- if (home.isDirectory()) {
- if (new File(home, ".idea").exists()) return home.getCanonicalPath()
- }
-
- home = home.getParentFile()
- }
-
- return null
-}
+private File getDependenciesProjectDir() {
+ return new File(home, new File(home).name == "community" ? "build/dependencies" : "community/build/dependencies")
+}
\ No newline at end of file
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index 382000145b16..cd622b284e4c 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -35,7 +35,7 @@ binding.setVariable("p", {String key, String defaultValue = null ->
if (defaultValue != null) {
return defaultValue
}
- throw e;
+ throw e
}
})
@@ -106,12 +106,14 @@ 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"
+
+ setupKotlin()
+ def bundledKotlinPath = "$home/build/dependencies/build/Kotlin/kotlinc"
if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
- bundledKotlinPath = "$home/community/build/kotlinc"
+ bundledKotlinPath = "$home/community/build/dependencies/build/Kotlin/kotlinc"
}
if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
- projectBuilder.error("Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar: run download_kotlin.gant script to download Kotlin JARs")
+ projectBuilder.error("Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar: run `./gradlew setupKotlin` in dependencies module to download Kotlin JARs")
return
}
setPathVariable("KOTLIN_BUNDLED", bundledKotlinPath)
@@ -136,6 +138,21 @@ binding.setVariable("removeJdkJarFiles", { Collection classpath ->
return classpath.findAll { jarPath -> jdkHomePaths.every { !FileUtil.isAncestor(it, jarPath, false) } }
})
+private void setupKotlin() {
+ def workingDirectory = getDependenciesProjectDir()
+ def gradleScript = System.getProperty('os.name').toLowerCase().contains('windows') ? "gradlew.bat" : "gradlew"
+ def process = new ProcessBuilder("${workingDirectory.absolutePath}/$gradleScript", 'setupKotlinPlugin', '--stacktrace', '--info')
+ .directory(workingDirectory)
+ .start()
+ process.consumeProcessOutputStream((OutputStream)System.out)
+ process.consumeProcessErrorStream((OutputStream)System.err)
+ process.waitFor()
+}
+
+private File getDependenciesProjectDir() {
+ return new File(home, new File(home).name == "community" ? "build/dependencies" : "community/build/dependencies")
+}
+
private String setupJdkPath(String propertyName, String defaultDir, String envVarName) {
try {
this[propertyName]
@@ -308,7 +325,7 @@ binding.setVariable("forceDelete", { String dirPath ->
})
binding.setVariable("collectUsedJars", { List modules, List approvedJars, List forbiddenJars, List modulesToBuild ->
- def usedJars = new HashSet();
+ def usedJars = new HashSet()
modules.each {
def module = findModule(it)
diff --git a/build/update.xml b/build/update.xml
index 6a1a2a0eda36..3decc239a398 100644
--- a/build/update.xml
+++ b/build/update.xml
@@ -25,19 +25,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy
index 0f04f1d87835..0997bc61d2c6 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy
@@ -15,6 +15,7 @@
*/
package org.jetbrains.intellij.build.impl
+import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
@@ -68,6 +69,8 @@ class CompilationContextImpl implements CompilationContext {
projectHome = toCanonicalPath(projectHome)
def jdk8Home = toCanonicalPath(JdkUtils.computeJdkHome(messages, "jdk8Home", "$projectHome/build/jdk/1.8", "JDK_18_x64"))
+
+ setupDependencies(messages, communityHome)
if (project.modules.isEmpty()) {
loadProject(communityHome, projectHome, jdk8Home, project, global, messages)
}
@@ -103,10 +106,10 @@ class CompilationContextImpl implements CompilationContext {
private static void loadProject(String communityHome, String projectHome, String jdkHome, JpsProject project, JpsGlobal global,
BuildMessages messages) {
- def bundledKotlinPath = "$communityHome/build/kotlinc"
+ def bundledKotlinPath = "$communityHome/build/dependencies/build/Kotlin/kotlinc"
if (!new File(bundledKotlinPath, "lib/kotlin-runtime.jar").exists()) {
messages.error(
- "Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar: run download_kotlin.gant script to download Kotlin JARs")
+ "Could not find Kotlin runtime at $bundledKotlinPath/lib/kotlin-runtime.jar: run `./gradlew setupKotlin` in dependencies module to download Kotlin JARs")
}
JpsModelSerializationDataService.getOrCreatePathVariablesConfiguration(global).addPathVariable("KOTLIN_BUNDLED", bundledKotlinPath)
@@ -118,6 +121,20 @@ class CompilationContextImpl implements CompilationContext {
messages.info("Loaded project $projectHome: ${project.modules.size()} modules, ${project.libraryCollection.libraries.size()} libraries")
}
+ private static void setupDependencies(BuildMessages messages, String communityHome) {
+ messages.info("Setting up dependencies")
+ def workingDirectory = new File(communityHome, 'build/dependencies/')
+ def gradleScript = SystemInfo.isWindows ? "gradlew.bat" : "gradlew"
+ def process = new ProcessBuilder("${workingDirectory.absolutePath}/$gradleScript", 'cleanDownloadJre', 'setupDependencies')
+ .directory(workingDirectory)
+ .start()
+ process.consumeProcessOutputStream((OutputStream)System.out)
+ process.consumeProcessErrorStream((OutputStream)System.err)
+ if (process.waitFor() != 0) {
+ messages.error("Cannot setup dependencies")
+ }
+ }
+
void prepareForBuild() {
checkCompilationOptions()
projectBuilder.buildIncrementally = options.incrementalCompilation
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationTasksImpl.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationTasksImpl.groovy
index 8995de6c7476..41064c16d540 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationTasksImpl.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationTasksImpl.groovy
@@ -84,14 +84,14 @@ class CompilationTasksImpl extends CompilationTasks {
catch (ClassNotFoundException ignored) {
}
- def kotlinPluginLibPath = "$context.paths.communityHome/build/kotlinc/plugin/Kotlin/lib"
+ def kotlinPluginLibPath = "$context.paths.communityHome/build/dependencies/build/Kotlin/lib"
if (new File(kotlinPluginLibPath).exists()) {
["jps/kotlin-jps-plugin.jar", "kotlin-plugin.jar", "kotlin-runtime.jar", "kotlin-reflect.jar"].each {
BuildUtils.addToJpsClassPath("$kotlinPluginLibPath/$it", context.ant)
}
}
else {
- context.messages.error("Could not find Kotlin JARs at $kotlinPluginLibPath: run download_kotlin.gant script to download them")
+ context.messages.error("Could not find Kotlin JARs at $kotlinPluginLibPath: run `./gradlew setupKotlin` in dependencies module to download Kotlin JARs")
}
}
}