Commit 65f055aa authored by Alexander Zolotov's avatar Alexander Zolotov
Browse files

Manage external dependencies of IntellIJ project sources via Gradle (IDEA-162511)

- add dependencies module
- download and unpack JBSDK
- download and unpack Java 1.6
- download and unpack Kotlin
- download and unpack JetSign
- download JBREX and creating JBRE
- use Gradle dependencies while building IDE and while developer's
  updating
parent 5b38bb6d
Branches unavailable Tags unavailable
No related merge requests found
Showing with 717 additions and 110 deletions
+717 -110
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
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$/build/dependencies" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$/build/dependencies" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useAutoImport" value="true" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
......@@ -65,6 +65,7 @@
<module fileurl="file://$PROJECT_DIR$/android/tools-base/ddmlib/ddmlib.iml" filepath="$PROJECT_DIR$/android/tools-base/ddmlib/ddmlib.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/java/debugger/impl/debugger-impl.iml" filepath="$PROJECT_DIR$/java/debugger/impl/debugger-impl.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/debugger/openapi/debugger-openapi.iml" filepath="$PROJECT_DIR$/java/debugger/openapi/debugger-openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/build/dependencies/dependencies.iml" filepath="$PROJECT_DIR$/build/dependencies/dependencies.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/devkit/devkit.iml" filepath="$PROJECT_DIR$/plugins/devkit/devkit.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/devkit/jps-plugin/devkit-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/devkit/jps-plugin/devkit-jps-plugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/devkit/devkit-tests.iml" filepath="$PROJECT_DIR$/plugins/devkit/devkit-tests.iml" group="plugins" />
......@@ -167,7 +168,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/lang-impl/lang-tests.iml" filepath="$PROJECT_DIR$/platform/lang-impl/lang-tests.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/android/layoutlib/layoutlib.iml" filepath="$PROJECT_DIR$/android/layoutlib/layoutlib.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/layoutlib-api/layoutlib-api.iml" filepath="$PROJECT_DIR$/android/tools-base/layoutlib-api/layoutlib-api.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/layoutlib-resources.iml" filepath="$PROJECT_DIR$/android/tools-base/layoutlib-resources.iml" group="android/sdktools"/>
<module fileurl="file://$PROJECT_DIR$/android/tools-base/layoutlib-resources.iml" filepath="$PROJECT_DIR$/android/tools-base/layoutlib-resources.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/lint/libs/lint-api/lint-api.iml" filepath="$PROJECT_DIR$/android/tools-base/lint/libs/lint-api/lint-api.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/lint/libs/lint-checks/lint-checks.iml" filepath="$PROJECT_DIR$/android/tools-base/lint/libs/lint-checks/lint-checks.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/platform/lvcs-api/lvcs-api.iml" filepath="$PROJECT_DIR$/platform/lvcs-api/lvcs-api.iml" group="platform" />
......@@ -194,7 +195,7 @@
<module fileurl="file://$PROJECT_DIR$/android/tools-base/perflib/perflib.iml" filepath="$PROJECT_DIR$/android/tools-base/perflib/perflib.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/pixelprobe/pixelprobe.iml" filepath="$PROJECT_DIR$/android/tools-base/pixelprobe/pixelprobe.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-api/platform-api.iml" filepath="$PROJECT_DIR$/platform/platform-api/platform-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/build-scripts/platform-build-scripts.iml" filepath="$PROJECT_DIR$/platform/build-scripts/platform-build-scripts.iml" group="platform"/>
<module fileurl="file://$PROJECT_DIR$/platform/build-scripts/platform-build-scripts.iml" filepath="$PROJECT_DIR$/platform/build-scripts/platform-build-scripts.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-impl/platform-impl.iml" filepath="$PROJECT_DIR$/platform/platform-impl/platform-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-main/platform-main.iml" filepath="$PROJECT_DIR$/platform/platform-main/platform-main.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-resources/platform-resources.iml" filepath="$PROJECT_DIR$/platform/platform-resources/platform-resources.iml" group="platform" />
......@@ -263,7 +264,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/testFramework/extensions/testExtensions.iml" filepath="$PROJECT_DIR$/platform/testFramework/extensions/testExtensions.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/testFramework/testFramework.iml" filepath="$PROJECT_DIR$/platform/testFramework/testFramework.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/java/testFramework/testFramework-java.iml" filepath="$PROJECT_DIR$/java/testFramework/testFramework-java.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/platform/testGuiFramework/testGuiFramework.iml" filepath="$PROJECT_DIR$/platform/testGuiFramework/testGuiFramework.iml" group="platform"/>
<module fileurl="file://$PROJECT_DIR$/platform/testGuiFramework/testGuiFramework.iml" filepath="$PROJECT_DIR$/platform/testGuiFramework/testGuiFramework.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/testRunner/testRunner.iml" filepath="$PROJECT_DIR$/platform/testRunner/testRunner.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/testng/testng.iml" filepath="$PROJECT_DIR$/plugins/testng/testng.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/testng_rt/testng_rt.iml" filepath="$PROJECT_DIR$/plugins/testng_rt/testng_rt.iml" group="plugins" />
......
......@@ -37,16 +37,13 @@
<target name="init">
<mkdir dir="${out.dir}"/>
<mkdir dir="${tmp.dir}"/>
<java classname="org.apache.tools.ant.Main" fork="true" failonerror="true" dir="${project.home}">
<sysproperty key="gant.script" value="${project.home}/build/scripts/download_kotlin.gant"/>
<classpath>
<fileset dir="${project.home}/lib/ant/lib">
<include name="*.jar"/>
</fileset>
</classpath>
<arg value="-f"/>
<arg value="${project.home}/build/gant.xml"/>
</java>
<condition property="gradle.executable" value="${project.home}/build/dependencies/gradlew.bat"
else="${project.home}/build/dependencies/gradlew">
<os family="windows"/>
</condition>
<exec executable="${gradle.executable}" dir="${project.home}/build/dependencies" failonerror="true">
<arg value="setupKotlin"/>
</exec>
</target>
<macrodef name="call_gant">
......
......@@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/scripts" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/groovy" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/dependencies/build" />
<excludeFolder url="file://$MODULE_DIR$/jdk" />
<excludeFolder url="file://$MODULE_DIR$/restApiDocGenerator/node_modules" />
</content>
......
/*
* 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
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="dependencies" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.intellij.build" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
jdkBuild=u112b752.4
kotlinPluginBuild=1.1.0-release-IJ2017.1-1
jetSignBuild=42.30
\ No newline at end of file
File added
#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
#!/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" "$@"
@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
/*
* 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
/*
* 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<String>()
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
/*
* 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
/*
* 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
......@@ -21,14 +21,14 @@
<pathelement path="${project.home}/platform/build-scripts/groovy"/>
<pathelement path="${project.home}/build/groovy"/>
<fileset file="${project.home}/jps/lib/optimizedFileManager.jar"/>
<fileset dir="${project.home}/build/kotlinc/jps" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<fileset dir="${project.home}/build/dependencies/build/Kotlin/lib/jps" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<include name="*.jar"/>
</fileset>
<fileset dir="${project.home}/build/kotlinc/lib" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<fileset dir="${project.home}/build/dependencies/build/Kotlin/kotlinc/lib" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<include name="kotlin-runtime.jar"/>
<include name="kotlin-reflect.jar"/>
</fileset>
<fileset dir="${project.home}/build/kotlinc/plugin/Kotlin/lib" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<fileset dir="${project.home}/build/dependencies/build/Kotlin/lib" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<include name="kotlin-plugin.jar"/>
</fileset>
<fileset dir="${idea.lib}">
......
......@@ -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")
}
......
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.
*/
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)")
}
includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
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}'")
target(default: "Unpack JDKs") {
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
......@@ -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<String> 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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment