From 8f48c975185be823d96fa27c48a7e8b80af8de15 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Mon, 3 Jul 2017 14:58:09 +0300 Subject: [PATCH] Build scripts: build list of provided modules by IDE --- .../intellij/build/BuildOptions.groovy | 3 +- .../intellij/build/impl/BuildTasksImpl.groovy | 97 +++++++++++-------- .../build/impl/DistributionJARsBuilder.groovy | 4 + 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.groovy index ed6b4ba61687..06abe02a0ad2 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -50,6 +50,7 @@ class BuildOptions { Set buildStepsToSkip = System.getProperty("intellij.build.skip.build.steps", "").split(",") as Set /** generate actual searchableOptions.xml file. If it is skipped the version of this file located in sources will be used, it may be outdated. */ static final SEARCHABLE_OPTIONS_INDEX_STEP = "search_index" + static final PROVIDED_MODULES_LIST_STEP = "provided_modules_list" static final SOURCES_ARCHIVE_STEP = "sources_archive" /** product DMG file for Mac OS X. If it is skipped only sit archive will be produced. */ static final MAC_DMG_STEP = "mac_dmg" diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy index 5ed5873561d7..966bb276e06f 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy @@ -87,63 +87,76 @@ class BuildTasksImpl extends BuildTasks { buildContext.notifyArtifactBuilt(targetFilePath) } } + + /** + * Build a list with modules that the IDE will provide for plugins. + */ + void buildProvidedModulesList(File targetDirectory, List modules, List pathsToLicenses) { + buildContext.executeStep("Build provided modules list", BuildOptions.PROVIDED_MODULES_LIST_STEP, { + buildContext.messages.progress("Building provided modules list for modules $modules") + String targetFile = "${targetDirectory.absolutePath}/builtinModules.json" + FileUtil.delete(new File(targetFile)) + runApplicationStarter("$buildContext.paths.temp/builtinModules", modules, pathsToLicenses, ['listBundledPlugins', targetFile]) + if (!new File(targetFile).exists()) { + buildContext.messages.error("Failed to build provided modules list: $targetFile doesn't exist") + } + }) + } /** * Build index which is used to search options in the Settings dialog. */ void buildSearchableOptionsIndex(File targetDirectory, List modulesToIndex, List pathsToLicenses) { buildContext.executeStep("Build searchable options index", BuildOptions.SEARCHABLE_OPTIONS_INDEX_STEP, { - def javaRuntimeClasses = "${buildContext.projectBuilder.moduleOutput(buildContext.findModule("java-runtime"))}" - if (!new File(javaRuntimeClasses).exists()) { - buildContext.messages.error("Cannot build searchable options, 'java-runtime' module isn't compiled ($javaRuntimeClasses doesn't exist)") - } - buildContext.messages.progress("Building searchable options for modules $modulesToIndex") - String targetFile = "${targetDirectory.absolutePath}/search/searchableOptions.xml" FileUtil.delete(new File(targetFile)) - - def tempDir = "$buildContext.paths.temp/searchableOptions" - String systemPath = "$tempDir/system" - String configPath = "$tempDir/config" - buildContext.ant.mkdir(dir: tempDir) - pathsToLicenses.each { - //todo[nik] previously licenses were copied to systemPath - buildContext.ant.copy(file: it, todir: configPath) - } - - def ideClasspath = new LinkedHashSet() - modulesToIndex.collectMany(ideClasspath) { buildContext.projectBuilder.moduleRuntimeClasspath(buildContext.findModule(it), false) } - - String classpathFile = "$tempDir/classpath.txt" - new File(classpathFile).text = ideClasspath.join("\n") - - //Start the product in headless mode using com.intellij.ide.ui.search.TraverseUIStarter. It'll process all UI elements in Settings dialog - // and build index for them. - buildContext.ant.java(classname: "com.intellij.rt.execution.CommandLineWrapper", fork: true, failonerror: true) { - jvmarg(line: "-ea -Xmx500m") - jvmarg(value: "-Xbootclasspath/a:${buildContext.projectBuilder.moduleOutput(buildContext.findModule("boot"))}") - sysproperty(key: "idea.home.path", value: buildContext.paths.projectHome) - sysproperty(key: "idea.system.path", value: systemPath) - sysproperty(key: "idea.config.path", value: configPath) - if (buildContext.productProperties.platformPrefix != null) { - sysproperty(key: "idea.platform.prefix", value: buildContext.productProperties.platformPrefix) - } - arg(value: "$classpathFile") - arg(line: "com.intellij.idea.Main traverseUI") - arg(value: targetFile) - - classpath() { - pathelement(location: "$javaRuntimeClasses") - } - } - + runApplicationStarter("$buildContext.paths.temp/searchableOptions", modulesToIndex, pathsToLicenses, ['traverseUI', targetFile]) if (!new File(targetFile).exists()) { buildContext.messages.error("Failed to build searchable options index: $targetFile doesn't exist") } }) } + private void runApplicationStarter(String tempDir, List modules, List pathsToLicenses, List arguments) { + def javaRuntimeClasses = "${buildContext.projectBuilder.moduleOutput(buildContext.findModule("java-runtime"))}" + if (!new File(javaRuntimeClasses).exists()) { + buildContext.messages.error("Cannot run application starter ${arguments}, 'java-runtime' module isn't compiled ($javaRuntimeClasses doesn't exist)") + } + + buildContext.ant.mkdir(dir: tempDir) + String systemPath = "$tempDir/system" + String configPath = "$tempDir/config" + pathsToLicenses.each { + //todo[nik] previously licenses were copied to systemPath + buildContext.ant.copy(file: it, todir: "$tempDir/config") + } + + def ideClasspath = new LinkedHashSet() + modules.collectMany(ideClasspath) { buildContext.projectBuilder.moduleRuntimeClasspath(buildContext.findModule(it), false) } + + String classpathFile = "$tempDir/classpath.txt" + new File(classpathFile).text = ideClasspath.join("\n") + + buildContext.ant.java(classname: "com.intellij.rt.execution.CommandLineWrapper", fork: true, failonerror: true) { + jvmarg(line: "-ea -Xmx500m") + jvmarg(value: "-Xbootclasspath/a:${buildContext.projectBuilder.moduleOutput(buildContext.findModule("boot"))}") + sysproperty(key: "idea.home.path", value: buildContext.paths.projectHome) + sysproperty(key: "idea.system.path", value: systemPath) + sysproperty(key: "idea.config.path", value: configPath) + if (buildContext.productProperties.platformPrefix != null) { + sysproperty(key: "idea.platform.prefix", value: buildContext.productProperties.platformPrefix) + } + arg(value: "$classpathFile") + arg(line: "com.intellij.idea.Main") + arguments.each { arg(value: it) } + + classpath() { + pathelement(location: "$javaRuntimeClasses") + } + } + } + File patchIdeaPropertiesFile() { File originalFile = new File("$buildContext.paths.communityHome/bin/idea.properties") diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy index 296b77d38c8b..e8ad09e9d85b 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy @@ -215,6 +215,10 @@ class DistributionJARsBuilder { if (!buildContext.options.buildStepsToSkip.contains(BuildOptions.SEARCHABLE_OPTIONS_INDEX_STEP)) { layoutBuilder.patchModuleOutput(productLayout.searchableOptionsModule, FileUtil.toSystemIndependentName(searchableOptionsDir.absolutePath)) } + + if (!buildContext.options.buildStepsToSkip.contains(BuildOptions.PROVIDED_MODULES_LIST_STEP)) { + buildTasks.buildProvidedModulesList(new File(buildContext.paths.artifacts), productLayout.mainModules, productLayout.licenseFilesToBuildSearchableOptions) + } def applicationInfoFile = FileUtil.toSystemIndependentName(patchedApplicationInfo.absolutePath) def applicationInfoDir = "$buildContext.paths.temp/applicationInfo"