From 32531ae7ec1c54bb228ccfe240a7edaf3582a21e Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 6 Jun 2016 20:02:59 +0300 Subject: [PATCH] build scripts redesign: get rid of product_properties.gant files, load ProductProperties implementation directly instead; BuildContext reused in layouts.gant --- .../build/IdeaCommunityProperties.groovy | 71 ++++++++++++++++++ build/scripts/dist.gant | 41 ++++++----- build/scripts/idea_properties.gant | 72 ------------------- build/scripts/layouts.gant | 65 +++++------------ 4 files changed, 111 insertions(+), 138 deletions(-) create mode 100644 build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy delete mode 100644 build/scripts/idea_properties.gant diff --git a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy new file mode 100644 index 000000000000..bc71483fd583 --- /dev/null +++ b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy @@ -0,0 +1,71 @@ +/* + * 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. + */ +package org.jetbrains.intellij.build + +/** + * @author nik + */ +class IdeaCommunityProperties extends ProductProperties { + IdeaCommunityProperties(String home) { + prefix = "idea" + platformPrefix = "Idea" + code = "IC" + appInfoModule = "community-resources" + fullNameIncludingEdition = "IntelliJ IDEA Community Edition" + additionalIDEPropertiesFilePath = "$home/build/conf/ideaCE.properties" + exe_launcher_properties = "$home/build/conf/ideaCE-launcher.properties" + exe64_launcher_properties = "$home/build/conf/ideaCE64-launcher.properties" + maySkipAndroidPlugin = true + relativeAndroidHome = "android" + relativeAndroidToolsBaseHome = "android/tools-base" + toolsJarRequired = true + + icon128 = "$home/platform/icons/src/icon_CE_128.png" + ico = "$home/platform/icons/src/idea_CE.ico" + + windows.bundleJre = true + windows.installerImagesPath = "$home/build/conf/ideaCE/win/images" + windows.fileAssociations = [".java", ".groovy", ".kt"] + + mac.helpId = "IJ" + mac.urlSchemes = ["idea"] + mac.includeYourkitAgentInEAP = false + mac.bundleIdentifier = "com.jetbrains.intellij.ce" + mac.dmgImagePath = "$home/build/conf/mac/communitydmg.png" + } + + @Override + String uninstallFeedbackPageUrl(ApplicationInfoProperties applicationInfo) { + return "https://www.jetbrains.com/idea/uninstall/?edition=IC-${applicationInfo.majorVersion}.${applicationInfo.minorVersion}" + } + + def String appInfoFile() { + "${projectBuilder.moduleOutput(findModule("community-resources"))}/idea/IdeaApplicationInfo.xml" + } + + def String systemSelector(ApplicationInfoProperties applicationInfo) { "IdeaIC$applicationInfo.majorVersion" } + + def String macAppRoot(ApplicationInfoProperties applicationInfo, String buildNumber) { + applicationInfo.isEAP ? "IntelliJ IDEA ${applicationInfo.majorVersion}.${applicationInfo.minorVersion} CE EAP.app/Contents" + : "IntelliJ IDEA CE.app/Contents" + } + + def String winAppRoot(String buildNumber) { "" } + + def String linuxAppRoot(String buildNumber) { "idea-IC-$buildNumber" } + + def String archiveName(String buildNumber) { "ideaIC-$buildNumber" } +} \ No newline at end of file diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 432108e6dd67..7102b38beeb5 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import org.apache.tools.ant.BuildException import org.jetbrains.intellij.build.BuildContext import org.jetbrains.intellij.build.BuildOptions import org.jetbrains.intellij.build.BuildTasks +import org.jetbrains.intellij.build.ProductProperties import org.jetbrains.jps.gant.LayoutInfo import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome @@ -29,22 +31,28 @@ requireProperty("out", "$home/out") // with mysterious errors String out = new File(out).getCanonicalPath() -loadProductProperties(home) - -def loadProductProperties(String home) { - //todo[nik] improve (load implementation class from groovy resources root directly?) - requireProperty("product", "idea") - requireProperty("productPropertiesPath", "") - if (productPropertiesPath.isEmpty()) { - productPropertiesPath = "$home/build/scripts/" + p("product") + "_properties.gant"; - } - if (!new File(productPropertiesPath).exists()) { - throw new BuildException("No product specific properties file found at: " + productPropertiesPath) - } - setProperty("productProperties", includeFile(productPropertiesPath).getProperties(home)) -} - private BuildContext createBuildContext(String out, BuildOptions options = new BuildOptions()) { + def classesRootPropertyName = "intellij.build.additional.classes.root" + def additionalClassesRoot = System.getProperty(classesRootPropertyName) + def classLoader = (GroovyClassLoader)this.class.classLoader + if (additionalClassesRoot != null) { + if (new File(additionalClassesRoot).exists()) { + projectBuilder.info("'$additionalClassesRoot' added to classpath.") + classLoader.addClasspath(additionalClassesRoot) + } + else { + projectBuilder.warning("'$classesRootPropertyName' property specifies non-existing file: $additionalClassesRoot") + } + } + def productPropertiesClassName = System.getProperty("intellij.build.product.properties.class", "org.jetbrains.intellij.build.IdeaCommunityProperties") + def productPropertiesClass + try { + productPropertiesClass = Class.forName(productPropertiesClassName, true, classLoader) + } + catch (ClassNotFoundException e) { + throw new BuildException("Cannot load product properties class '$productPropertiesClassName'. Specify its root with '$classesRootPropertyName' property.", e) + } + def productProperties = (ProductProperties)productPropertiesClass.newInstance([home].toArray()) //todo[nik] construct buildOutputRoot automatically based on product name BuildContext.createContext(ant, projectBuilder, project, global, home, home, "$out/release", productProperties, options) } @@ -87,8 +95,7 @@ target('build-dist-jars' : 'Target to build jars from locally compiled classes') def layoutAll(BuildContext buildContext, buildJps = false) { def layouts = includeFile("$buildContext.paths.communityHome/build/scripts/layouts.gant") def tasks = BuildTasks.create(buildContext) - def applicationInfo = tasks.patchApplicationInfo() - LayoutInfo info = layouts.layoutFull(buildContext.paths.projectHome, buildContext.paths.distAll, applicationInfo) + LayoutInfo info = layouts.layoutFull(buildContext) buildContext.messages.block("Build intellij-core") { String coreArtifactDir = "$buildContext.paths.artifacts/core" diff --git a/build/scripts/idea_properties.gant b/build/scripts/idea_properties.gant deleted file mode 100644 index 94c009b9194e..000000000000 --- a/build/scripts/idea_properties.gant +++ /dev/null @@ -1,72 +0,0 @@ -import org.jetbrains.intellij.build.ApplicationInfoProperties -import org.jetbrains.intellij.build.ProductProperties -/* - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - */ - - -def getProperties(String home) { - return new ProductProperties() { - { - prefix = "idea" - platformPrefix = "Idea" - code = "IC" - appInfoModule = "community-resources" - fullNameIncludingEdition = "IntelliJ IDEA Community Edition" - additionalIDEPropertiesFilePath = "$home/build/conf/ideaCE.properties" - exe_launcher_properties = "$home/build/conf/ideaCE-launcher.properties" - exe64_launcher_properties = "$home/build/conf/ideaCE64-launcher.properties" - maySkipAndroidPlugin = true - relativeAndroidHome = "android" - relativeAndroidToolsBaseHome = "android/tools-base" - toolsJarRequired = true - - icon128 = "$home/platform/icons/src/icon_CE_128.png" - ico = "$home/platform/icons/src/idea_CE.ico" - - windows.bundleJre = true - windows.installerImagesPath = "$home/build/conf/ideaCE/win/images" - windows.fileAssociations = [".java", ".groovy", ".kt"] - - mac.helpId = "IJ" - mac.urlSchemes = ["idea"] - mac.includeYourkitAgentInEAP = false - mac.bundleIdentifier = "com.jetbrains.intellij.ce" - mac.dmgImagePath = "$home/build/conf/mac/communitydmg.png" - } - - @Override - String uninstallFeedbackPageUrl(ApplicationInfoProperties applicationInfo) { - return "https://www.jetbrains.com/idea/uninstall/?edition=IC-${applicationInfo.majorVersion}.${applicationInfo.minorVersion}" - } - - def String appInfoFile() { - "${projectBuilder.moduleOutput(findModule("community-resources"))}/idea/IdeaApplicationInfo.xml" - } - - def String systemSelector(ApplicationInfoProperties applicationInfo) { "IdeaIC$applicationInfo.majorVersion" } - - def String macAppRoot(ApplicationInfoProperties applicationInfo, String buildNumber) { - applicationInfo.isEAP ? "IntelliJ IDEA ${applicationInfo.majorVersion}.${applicationInfo.minorVersion} CE EAP.app/Contents" - : "IntelliJ IDEA CE.app/Contents" - } - - def String winAppRoot(String buildNumber) { "" } - - def String linuxAppRoot(String buildNumber) { "idea-IC-$buildNumber" } - - def String archiveName(String buildNumber) { "ideaIC-$buildNumber" } - } -} \ No newline at end of file diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 2a35a70b6b83..d536b7e1a819 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -13,6 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import org.jetbrains.intellij.build.BuildContext +import org.jetbrains.intellij.build.BuildTasks +import org.jetbrains.intellij.build.IdeaCommunityProperties + import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant") @@ -20,38 +25,15 @@ includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant") target('default': "Developers update") { //when IDEA CE is updated from IDEA UE sources project should be loaded from IDEA UE directory String projectHome = isDefined("devIdeaHome") ? devIdeaHome : home - loadProjectFromPath(projectHome) - def patchedAppInfo = patchApplicationInfo(deploy) - layoutFull(home, deploy, patchedAppInfo) - ant.delete(dir: patchedAppInfo) -} - -String appInfoFileName() { - return isDefined("productProperties") ? productProperties.appInfoFile() : "idea/IdeaApplicationInfo.xml" -} - -boolean maySkipAndroidPlugin() { - return isDefined("productProperties") && productProperties.maySkipAndroidPlugin + def context = BuildContext.createContext(ant, projectBuilder, project, global, home, projectHome, "$out/release", new IdeaCommunityProperties(home)) + context.paths.distAll = deploy + layoutFull(context) } boolean setPluginAndIDEVersionInPluginXml() { return !isDefined("productProperties") || productProperties.setPluginAndIDEVersionInPluginXml } -String appInfoModule() { - return isDefined("productProperties") ? productProperties.appInfoModule : "community-resources" -} - -String productCode() { - return isDefined("productProperties") ? productProperties.code : "IC" -} - -void customLayout(String targetDirectory) { - if (isDefined("productProperties")) { - productProperties.customLayout(targetDirectory) - } -} - String relativeAndroidHome() { return isDefined("productProperties") ? productProperties.relativeAndroidHome : "android" } @@ -64,25 +46,11 @@ List getExcludedPlugins() { return isDefined("productProperties") ? productProperties.excludedPlugins : [] } -File patchApplicationInfo(String targetDirectory) { - def patchedDirectory = "${targetDirectory}/../patched" - - ant.delete(dir: patchedDirectory) - - layout(patchedDirectory) { - module(appInfoModule()) { - include(name: appInfoFileName()) - } - } - - def code = productCode() - ant.replace(file: "$patchedDirectory/${appInfoFileName()}", token: "__BUILD_NUMBER__", value: "${code}-$snapshot") - ant.replace(file: "$patchedDirectory/${appInfoFileName()}", token: "__BUILD_DATE__", value: new Date().format("yyyyMMddHHmm")) - - return new File(patchedDirectory, "idea/${appInfoFileName()}") -} - -def layoutFull(String home, String targetDirectory, File patchedApplicationInfo = null) { +def layoutFull(BuildContext context) { + binding.setVariable("productProperties", context.productProperties) + String home = context.paths.communityHome + String targetDirectory = context.paths.distAll + File patchedApplicationInfo = BuildTasks.create(context).patchApplicationInfo() projectBuilder.stage("layout to $targetDirectory") List jpsCommonModules = ["jps-model-impl", "jps-model-serialization"] @@ -196,7 +164,7 @@ def layoutFull(String home, String targetDirectory, File patchedApplicationInfo module("resources") module("platform-resources") - def appInfoModule = appInfoModule() + def appInfoModule = context.productProperties.appInfoModule if ("community-resources" == appInfoModule) { module("community-resources") { if (patchedApplicationInfo != null) { @@ -280,7 +248,7 @@ def layoutFull(String home, String targetDirectory, File patchedApplicationInfo } } - layoutCommunityPlugins(home, maySkipAndroidPlugin()) + layoutCommunityPlugins(home, context.productProperties.maySkipAndroidPlugin) dir("plugins") { dir("javaFX") { @@ -317,8 +285,7 @@ def layoutFull(String home, String targetDirectory, File patchedApplicationInfo } } - // product specific custom layout - customLayout(targetDirectory) + context.productProperties.customLayout(targetDirectory) reorder(home, targetDirectory) return info