Build scripts: build list of provided modules by IDE

This commit is contained in:
Alexander Zolotov
2017-07-04 13:07:37 +03:00
parent b8d59290fd
commit 8f48c97518
3 changed files with 61 additions and 43 deletions
@@ -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<String> buildStepsToSkip = System.getProperty("intellij.build.skip.build.steps", "").split(",") as Set<String>
/** 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"
@@ -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<String> modules, List<String> 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<String> modulesToIndex, List<String> 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<String>()
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<String> modules, List<String> pathsToLicenses, List<String> 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<String>()
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")
@@ -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"