diff --git a/.idea/modules.xml b/.idea/modules.xml index 925853f02b9b..9cd02c270559 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -68,6 +68,7 @@ + diff --git a/build/dependencies/buildSrc/buildSrc.iml b/build/dependencies/buildSrc/buildSrc.iml new file mode 100644 index 000000000000..eb8f74b18393 --- /dev/null +++ b/build/dependencies/buildSrc/buildSrc.iml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/dependencies/buildSrc/src/main/groovy/org/jetbrains/intellij/build/DependenciesBuildUtils.groovy b/build/dependencies/buildSrc/src/main/groovy/org/jetbrains/intellij/build/DependenciesBuildUtils.groovy new file mode 100644 index 000000000000..bbb698a0d6fc --- /dev/null +++ b/build/dependencies/buildSrc/src/main/groovy/org/jetbrains/intellij/build/DependenciesBuildUtils.groovy @@ -0,0 +1,44 @@ +package org.jetbrains.intellij.build + +import groovy.transform.CompileStatic +import org.gradle.api.logging.Logger +import org.gradle.api.logging.Logging +import org.gradle.internal.os.OperatingSystem + +@CompileStatic +class DependenciesBuildUtils { + private static final Logger LOG = Logging.getLogger('DependenciesBuild') + private static Boolean isInJetBrainsNetwork = null + + static def getInJetBrainsNetwork() { + if (isInJetBrainsNetwork == null) { + try { + isInJetBrainsNetwork = InetAddress.getByName("repo.labs.intellij.net").isReachable(1000) + if (!isInJetBrainsNetwork && OperatingSystem.current().isWindows()) { + isInJetBrainsNetwork = Runtime.runtime.exec("ping -n 1 repo.labs.intellij.net").waitFor() == 0 + } + if (!isInJetBrainsNetwork) { + LOG.info('repo.labs.intellij.net is not reachable') + } + } + catch (UnknownHostException e) { + LOG.info('repo.labs.intellij.net is not reachable', e) + isInJetBrainsNetwork = false + } + } + return isInJetBrainsNetwork + } + + static def getJdkRepo() { + return inJetBrainsNetwork ? 'http://repo.labs.intellij.net/intellij-jdk' : 'https://dl.bintray.com/jetbrains/intellij-jdk' + } + + static def intellijProjectDir(File gradleProjectDir) { + def communityDir = new File(gradleProjectDir, "../..").canonicalFile + return communityDir.name == 'community' ? communityDir.parent : communityDir + } + + static def isInUltimateContext(File gradleProjectDir) { + return new File(gradleProjectDir, "../..").canonicalFile.name == 'community' + } +} \ No newline at end of file diff --git a/build/dependencies/setupJdk.gradle b/build/dependencies/setupJdk.gradle index dd9ae49fe6c9..d765f4583411 100644 --- a/build/dependencies/setupJdk.gradle +++ b/build/dependencies/setupJdk.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.intellij.build.DependenciesBuildUtils + /* * Copyright 2000-2016 JetBrains s.r.o. * @@ -16,9 +18,7 @@ task setupJdks(dependsOn: ['setupJdk18', 'setupJdk16']) cleanSetupJdks.dependsOn('cleanSetupJdk18', 'cleanSetupJdk16', 'cleanDownloadJdk18') -def jdkRepo = inJetBrainsNetwork ? 'http://repo.labs.intellij.net' : 'https://dl.bintray.com/jetbrains/' - -def checkoutDir = intellijProjectDir() +def checkoutDir = DependenciesBuildUtils.intellijProjectDir(file('.')) def jdkDir = "$checkoutDir/build/jdk" project.ext.jdk18OutputDir = "${System.getProperty("intellij.jdk18.output.dir", "$jdkDir/1.8")}" @@ -35,9 +35,9 @@ task downloadJdk18 { inputs.property('build', jdkBuild) outputs.file(outputFile) doLast { - logger.info("Downloading up JDK 1.8 to compile (using $jdkRepo repo)") + logger.info("Downloading up JDK 1.8 to compile (using $DependenciesBuildUtils.jdkRepo repo)") download { - src "$jdkRepo/intellij-jdk/${artifactName}" + src "$DependenciesBuildUtils.jdkRepo/intellij-jdk/${artifactName}" dest outputFile onlyIfNewer true } @@ -108,10 +108,7 @@ dependencies { } task setupJdk16(dependsOn: configurations.jdk16) { - if (!inJetBrainsNetwork) { - return - } - + onlyIf { DependenciesBuildUtils.inJetBrainsNetwork } def jdkArchive = { configurations.jdk16.singleFile } def outputDir = "$jdkDir/1.6" inputs.file(jdkArchive) @@ -134,13 +131,6 @@ private void deleteBrokenSymlink(def outputDir) { } } -setupJdk16.onlyIf { inJetBrainsNetwork } - -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()) { diff --git a/build/dependencies/setupJetSign.gradle b/build/dependencies/setupJetSign.gradle index ec641e90e71e..c76864e003a8 100644 --- a/build/dependencies/setupJetSign.gradle +++ b/build/dependencies/setupJetSign.gradle @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import org.jetbrains.intellij.build.DependenciesBuildUtils + repositories { maven { url 'http://repo.labs.intellij.net/jet-sign' @@ -28,22 +30,18 @@ dependencies { } task setupJetSign(dependsOn: configurations.jetSign) { - if (!inJetBrainsNetwork) { - return - } def ultimateProjectDir = ultimateProjectDir() - if (!ultimateProjectDir) { - return - } + onlyIf { DependenciesBuildUtils.inJetBrainsNetwork && ultimateProjectDir } - doFirst { logger.info("Setting up JetSign") } + if (!ultimateProjectDir) return def jetSignJar = { configurations.jetSign.singleFile } - def outputDir = file("$ultimateProjectDir/build/lib/") + def outputDir = "$ultimateProjectDir/build/lib/" + inputs.file(jetSignJar) outputs.file("$outputDir/jet-sign.jar") doLast { - logger.info("Copying $jetSignJar to $outputDir") + logger.info("Setting up JetSign. Copying $jetSignJar to $outputDir") copy { from file(jetSignJar) into outputDir