build scripts cleanup: obsolete unused gant scripts removed

This commit is contained in:
nik
2016-10-25 10:56:56 +03:00
parent 3ac1b3276a
commit f367d0c436
2 changed files with 3 additions and 1036 deletions
-107
View File
@@ -1,107 +0,0 @@
import com.intellij.openapi.util.SystemInfo
target(nsis: 'Build nsis windows installer') {
nsis_installer()
}
String p(String key) {
return getProperty(key)
}
def nsis_installer(pathsToInclude, stringsFile, pathsFile, outNamePrefix, includeToolsJar = true, associateIpr = true,
system_selector = getProperty("system_selector"), failOnSignError = false, outFileName = null,
boolean hasBundledJRE = false) {
// p.s: Groovy reevaluates default value of system_selector on each call, so it always uses actual property value.
if (outFileName == null) {
outFileName = "${outNamePrefix}${buildNumber}"
}
ant.taskdef(name: "nsis", classname: "com.intellij.internalUtilities.ant.NsiFiles", classpath: "${home}/community/build/lib/NsiFiles.jar")
def box = paths.sandbox
ant.mkdir(dir: "$box/bin")
ant.mkdir(dir: "$box/nsiconf")
if (!hasBundledJRE) {
ant.copy(todir: "$box/bin") {
fileset(dir: "${box}/jdk.win/jre") {
include(name: "**/msvcr71.dll")
}
}
}
ant.copy(todir: "$box/nsiconf") {
fileset(dir: "$home/community/build/conf/nsis") {
include(name: "*")
exclude(name: "version*")
exclude(name: "strings*")
exclude(name: "paths*")
}
}
if (isEap()) {
ant.copy(file: "$home/community/build/conf/nsis/version.eap.nsi",
tofile: "$box/nsiconf/version.nsi", overwrite: true)
}
else {
ant.copy(file: "$home/community/build/conf/nsis/version.nsi",
tofile: "$box/nsiconf/version.nsi", overwrite: true)
}
ant.copy(file: pathsFile, toFile: "$box/nsiconf/paths.nsi", overwrite: true)
ant.nsis(instfile: "$box/nsiconf/idea_win.nsh", uninstfile: "$box/nsiconf/unidea_win.nsh") {
pathsToInclude.each {
fileset(dir: it, includes: "**/*") {
exclude(name: "**/idea.properties")
exclude(name: "**/*.vmoptions")
}
}
fileset(dir: box, includes: "bin/msvcr71.dll")
if (!hasBundledJRE) {
fileset(dir: "${box}/jdk.win", includes: "jre/**/*")
}
}
ant.replace(file: "$stringsFile") {
replacefilter(token: "__VERSION_MAJOR__", value: p("component.version.major"))
replacefilter(token: "__VERSION_MINOR__", value: p("component.version.minor"))
}
ant.copy(file: stringsFile, toFile: "$box/nsiconf/strings.nsi", overwrite: true)
ant.replace(file: "$box/nsiconf/version.nsi") {
replacefilter(token: "__BUILD_NUMBER__", value: buildNumber)
replacefilter(token: "__VERSION_MAJOR__", value: p("component.version.major"))
replacefilter(token: "__VERSION_MINOR__", value: p("component.version.minor"))
replacefilter(token: "__PRODUCT_PATHS_SELECTOR__", value: system_selector)
}
ant.unzip(src: "$home/build/tools/NSIS.zip", dest: box)
if (SystemInfo.isWindows) {
ant.exec(command: "\"${box}/NSIS/makensis.exe\"" +
" /DBASE_DIR=\"$home\"" +
" /DCOMMUNITY_DIR=\"$home/community\"" +
" /DIPR=\"${associateIpr}\"" +
" /DOUT_FILE=\"${outFileName}\"" +
" /DOUT_DIR=\"$paths.artifacts\"" +
" \"${box}/nsiconf/idea.nsi\"")
}
else if (SystemInfo.isLinux) {
ant.exec(command: "makensis" +
" '-X!AddPluginDir \"${box}/NSIS/Plugins\"'" +
" '-X!AddIncludeDir \"${box}/NSIS/Include\"'" +
" -DBASE_DIR=\"$home\"" +
" -DCOMMUNITY_DIR=\"$home/community\"" +
" -DIPR=\"${associateIpr}\"" +
" -DOUT_FILE=\"${outFileName}\"" +
" -DOUT_DIR=\"$paths.artifacts\"" +
" \"${box}/nsiconf/idea.nsi\"")
}
projectBuilder.stage("Signing binaries")
executeExternalAnt(["dirName": "${paths.artifacts}", "fileName": "${outFileName}.exe"], "$home/build/signBuild.xml")
projectBuilder.stage("Signing done")
return "${paths.artifacts}/${outFileName}.exe"
}
+3 -929
View File
@@ -17,12 +17,12 @@
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.jps.gant.JpsGantTool
import org.jetbrains.jps.gant.TeamCityBuildInfoPrinter
import org.jetbrains.jps.model.java.*
import org.jetbrains.jps.model.java.JdkVersionDetector
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.java.JpsJavaSdkType
import org.jetbrains.jps.model.library.JpsOrderRootType
import org.jetbrains.jps.model.module.JpsModule
import org.jetbrains.jps.model.serialization.JpsModelSerializationDataService
includeTool << JpsGantTool
@@ -63,41 +63,9 @@ binding.setVariable("includeFile", {String filePath ->
s
})
binding.setVariable("isMac", {
return System.getProperty("os.name").toLowerCase().startsWith("mac")
})
binding.setVariable("isWin", {
return System.getProperty("os.name").toLowerCase().startsWith("windows")
})
binding.setVariable("isEap", {
return "true" == p("component.version.eap")
})
/**
* @deprecated these properies aren't used in new build scripts anymore (they are still used in CLion and AppCode build scripts which aren't rewritten yet;
* modify {@link org.jetbrains.intellij.build.impl.VmOptionsGenerator} instead
*/
binding.setVariable("mem32", "-server -Xms128m -Xmx512m -XX:ReservedCodeCacheSize=240m")
binding.setVariable("mem64", "-Xms128m -Xmx750m -XX:ReservedCodeCacheSize=240m")
binding.setVariable("common_vmoptions", "-XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea " +
"-Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true " +
"-XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow")
binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:MaxJavaStackTraceDepth=-1' : ''}".trim() })
binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() })
binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() })
binding.setVariable("yjpOptions", { String sessionName, String platformSuffix = "" ->
"-agentlib:yjpagent$platformSuffix=probe_disable=*,disablealloc,disabletracing,onlylocal,disableexceptiontelemetry,delay=10000,sessionname=$sessionName".trim()
})
binding.setVariable("vmOptions32yjp", { String sessionName ->
"${vmOptions32()} ${yjpOptions(sessionName)}".trim()
})
binding.setVariable("vmOptions64yjp", { String sessionName ->
"${vmOptions64()} ${yjpOptions(sessionName, "64")}".trim()
})
binding.setVariable("isDefined", {String key ->
try {
@@ -252,10 +220,6 @@ binding.setVariable("clearBuildCaches", {
}
})
boolean hasSourceRoots(JpsModule module) {
return module.getSourceRoots(JavaSourceRootType.SOURCE).iterator().hasNext()
}
binding.setVariable("findModule", {String name ->
project.modules.find { it.name == name }
})
@@ -306,41 +270,6 @@ if (debugSuspend == 'y') {
"""
}
binding.setVariable("patchFiles", { List files, Map args, String marker = "__" ->
files.each { file ->
args.each { arg ->
ant.replace(file: file, token: "${marker}${arg.key}${marker}", value: arg.value)
}
}
})
binding.setVariable("copyAndPatchFile", { String file, String target, Map args, String marker = "__" ->
ant.copy(file: file, tofile: target, overwrite: "true") {
filterset(begintoken: marker, endtoken: marker) {
args.each {
filter(token: it.key, value: it.value)
}
}
}
})
binding.setVariable("copyAndPatchFiles", { Closure files, String target, Map args, String marker = "__" ->
ant.copy(todir: target, overwrite: "true") {
files()
filterset(begintoken: marker, endtoken: marker) {
args.each {
filter(token: it.key, value: it.value)
}
}
}
})
binding.setVariable("wireBuildDate", { String buildNumber, String appInfoFile ->
ant.tstamp()
patchFiles([appInfoFile], ["BUILD_NUMBER": buildNumber, "BUILD_DATE": DSTAMP])
})
binding.setVariable("commonJvmArgsForTests", {
def jdwp = "-Xrunjdwp:transport=dt_socket,server=y,suspend=$debugSuspend"
if (debugPort != null) jdwp += ",address=$debugPort"
@@ -365,327 +294,6 @@ binding.setVariable("commonJvmArgsForTests", {
]
})
binding.setVariable("classPathLibs", [
"bootstrap.jar",
"extensions.jar",
"util.jar",
"jdom.jar",
"log4j.jar",
"trove4j.jar",
"jna.jar"
])
/**
* @deprecated these properies aren't used in new build scripts anymore (they are still used in CLion and AppCode build scripts which aren't rewritten yet;
* modify {@link org.jetbrains.intellij.build.CommunityRepositoryModules} instead
*/
binding.setVariable("platformApiModules", [
"analysis-api",
"built-in-server-api",
"core-api",
"diff-api",
"dvcs-api",
"editor-ui-api",
"external-system-api",
"indexing-api",
"jps-model-api",
"lang-api",
"lvcs-api",
"platform-api",
"projectModel-api",
"remote-servers-agent-rt",
"remote-servers-api",
"usageView",
"vcs-api-core",
"vcs-api",
"vcs-log-api",
"vcs-log-graph-api",
"xdebugger-api",
"xml-analysis-api",
"xml-openapi",
"xml-psi-api",
"xml-structure-view-api"
])
binding.setVariable("platformImplementationModules", [
"analysis-impl",
"built-in-server",
"core-impl",
"credential-store",
"diff-impl",
"dvcs-impl",
"editor-ui-ex",
"images",
"indexing-impl",
"jps-model-impl",
"jps-model-serialization",
"json",
"lang-impl",
"lvcs-impl",
"platform-impl",
"projectModel-impl",
"protocol-reader-runtime",
"RegExpSupport",
"relaxng",
"remote-servers-impl",
"script-debugger-backend",
"script-debugger-ui",
"smRunner",
"spellchecker",
"structure-view-impl",
"testRunner",
"vcs-impl",
"vcs-log-graph",
"vcs-log-impl",
"xdebugger-impl",
"xml-analysis-impl",
"xml-psi-impl",
"xml-structure-view-impl",
"xml",
"configuration-store-impl",
])
binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
ant.copy(todir: "$path/bin") {
fileset(dir: "$ch/bin/mac")
}
ant.copy(todir: path) {
fileset(dir: "$ch/build/conf/mac/Contents")
}
ant.tstamp() {
format(property: "todayYear", pattern: "yyyy")
}
String executable = args.executable != null ? args.executable : p("component.names.product").toLowerCase()
String helpId = args.help_id != null ? args.help_id : "IJ"
String icns = "idea.icns"
String helpIcns = "$path/Resources/${helpId}.help/Contents/Resources/Shared/product.icns"
if (args.icns != null) {
ant.delete(file: "$path/Resources/idea.icns")
ant.copy(file: args.icns, todir: "$path/Resources")
ant.copy(file: args.icns, tofile: helpIcns)
icns = new File((String)args.icns).getName();
} else {
ant.copy(file: "$path/Resources/idea.icns", tofile: helpIcns)
}
String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
String vmOptions = "-Dfile.encoding=UTF-8 ${vmOptions()} -Xverify:none"
String minor = p("component.version.minor")
String version = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "EAP $args.buildNumber" : "${p("component.version.major")}.${minor}"
String EAP = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "-EAP" : ""
Map properties = readIdeaProperties(args)
def coreKeys = ["idea.platform.prefix", "idea.paths.selector", "idea.executable"]
String coreProperties = submapToXml(properties, coreKeys);
StringBuilder effectiveProperties = new StringBuilder()
properties.each { k, v ->
if (!coreKeys.contains(k)) {
effectiveProperties.append("$k=$v\n");
}
}
new File("$path/bin/idea.properties").text = effectiveProperties.toString()
String ideaVmOptions = "$mem64 -XX:+UseCompressedOops"
if (isEap() && !args.mac_no_yjp) {
ideaVmOptions += " ${yjpOptions(args.system_selector)}"
}
new File("$path/bin/${executable}.vmoptions").text = ideaVmOptions.split(" ").join("\n")
String classPath = classPathLibs.collect {"\$APP_PACKAGE/Contents/lib/${it}" }.join(":")
String archs = """
<key>LSArchitecturePriority</key>
<array>"""
(args.archs != null ? args.archs : ["x86_64"]).each {
archs += "<string>${it}</string>"
}
archs +="</array>\n"
String urlSchemes = ""
if (args.urlSchemes != null) {
urlSchemes += """
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>Stacktrace</string>
<key>CFBundleURLSchemes</key>
<array>
"""
args.urlSchemes.each { scheme ->
urlSchemes += " <string>${scheme}</string>"
}
urlSchemes += """
</array>
</dict>
</array>
"""
}
ant.replace(file: "$path/Info.plist") {
replacefilter(token: "@@build@@", value: args.buildNumber)
replacefilter(token: "@@doc_types@@", value: ifNull(args.doc_types, ""))
replacefilter(token: "@@executable@@", value: executable)
replacefilter(token: "@@icns@@", value: icns)
replacefilter(token: "@@bundle_name@@", value: fullName)
replacefilter(token: "@@product_state@@", value: EAP)
replacefilter(token: "@@bundle_identifier@@", value: args.bundleIdentifier)
replacefilter(token: "@@year@@", value: "$todayYear")
replacefilter(token: "@@company_name@@", value: p("component.company.name"))
replacefilter(token: "@@min_year@@", value: "2000")
replacefilter(token: "@@max_year@@", value: "$todayYear")
replacefilter(token: "@@version@@", value: version)
replacefilter(token: "@@vmoptions@@", value: vmOptions)
replacefilter(token: "@@idea_properties@@", value: coreProperties)
replacefilter(token: "@@idea.paths.selector@@", value: args.system_selector)
replacefilter(token: "@@class_path@@", value: classPath)
replacefilter(token: "@@help_id@@", value: helpId)
replacefilter(token: "@@url_schemes@@", value: urlSchemes)
replacefilter(token: "@@archs@@", value: archs)
replacefilter(token: "@@min_osx@@", value: ifNull(args.min_osx, "10.8"))
}
if (executable != "idea") {
ant.move(file: "$path/MacOS/idea", tofile: "$path/MacOS/$executable")
}
ant.replace(file: "$path/bin/format.sh") {
replacefilter(token: "@@product_full@@", value: fullName)
replacefilter(token: "@@script_name@@", value: executable)
}
ant.replace(file: "$path/bin/inspect.sh") {
replacefilter(token: "@@product_full@@", value: fullName)
replacefilter(token: "@@script_name@@", value: executable)
}
if (args.inspect_script != null && args.inspect_script != "inspect") {
ant.move(file: "$path/bin/inspect.sh", tofile: "$path/bin/${args.inspect_script}.sh")
}
ant.fixcrlf(srcdir: "$path/bin", includes: "*.sh", eol: "unix")
ant.fixcrlf(srcdir: "$path/bin", includes: "*.py", eol: "unix")
})
binding.setVariable("winScripts", { String target, String home, String name, Map args ->
String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
String vm_options = args.vm_options != null ? args.vm_options : "${p("component.names.product").toLowerCase()}.exe"
if (vm_options.endsWith(".exe")) {
vm_options = vm_options.replace(".exe", "%BITS%.exe")
}
else {
vm_options = vm_options + "%BITS%"
}
String classPath = "SET CLASS_PATH=%IDE_HOME%\\lib\\${classPathLibs[0]}\n"
classPath += classPathLibs[1..-1].collect {"SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\\lib\\${it}"}.join("\n")
if (args.tools_jar) classPath += "\nSET CLASS_PATH=%CLASS_PATH%;%JDK%\\lib\\tools.jar"
ant.copy(todir: "$target/bin") {
fileset(dir: "$home/bin/scripts/win")
filterset(begintoken: "@@", endtoken: "@@") {
filter(token: "product_full", value: fullName)
filter(token: "product_uc", value: product_uc)
filter(token: "vm_options", value: vm_options)
filter(token: "isEap", value: isEap())
filter(token: "system_selector", value: args.system_selector)
filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, ""))
filter(token: "class_path", value: classPath)
filter(token: "script_name", value: name)
}
}
if (name != "idea.bat") {
ant.move(file: "$target/bin/idea.bat", tofile: "$target/bin/$name")
}
if (args.inspect_script != null && args.inspect_script != "inspect") {
ant.move(file: "$target/bin/inspect.bat", tofile: "$target/bin/${args.inspect_script}.bat")
}
ant.fixcrlf(srcdir: "$target/bin", includes: "*.bat", eol: "dos")
})
private ifNull(v, defVal) { v != null ? v : defVal }
binding.setVariable("unixScripts", { String target, String home, String name, Map args ->
String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
String vm_options = args.vm_options != null ? args.vm_options : p("component.names.product").toLowerCase()
String classPath = "CLASSPATH=\"\$IDE_HOME/lib/${classPathLibs[0]}\"\n"
classPath += classPathLibs[1..-1].collect {"CLASSPATH=\"\$CLASSPATH:\$IDE_HOME/lib/${it}\""}.join("\n")
if (args.tools_jar) classPath += "\nCLASSPATH=\"\$CLASSPATH:\$JDK/lib/tools.jar\""
ant.copy(todir: "$target/bin") {
fileset(dir: "$home/bin/scripts/unix")
filterset(begintoken: "@@", endtoken: "@@") {
filter(token: "product_full", value: fullName)
filter(token: "product_uc", value: product_uc)
filter(token: "vm_options", value: vm_options)
filter(token: "isEap", value: isEap())
filter(token: "system_selector", value: args.system_selector)
filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, ""))
filter(token: "class_path", value: classPath)
filter(token: "script_name", value: name)
}
}
if (name != "idea.sh") {
ant.move(file: "$target/bin/idea.sh", tofile: "$target/bin/$name")
}
if (args.inspect_script != null && args.inspect_script != "inspect") {
ant.move(file: "$target/bin/inspect.sh", tofile: "$target/bin/${args.inspect_script}.sh")
}
ant.fixcrlf(srcdir: "$target/bin", includes: "*.sh", eol: "unix")
})
binding.setVariable("winVMOptions", { String target, String yjpSessionName, String name, String name64 = null ->
if (name != null) {
def options = isEap() && yjpSessionName != null ? vmOptions32yjp(yjpSessionName) : vmOptions32()
ant.echo(file: "$target/bin/${name}.vmoptions", message: options.replace(' ', '\n'))
}
if (name64 != null) {
def options = isEap() && yjpSessionName != null ? vmOptions64yjp(yjpSessionName) : vmOptions64()
ant.echo(file: "$target/bin/${name64}.vmoptions", message: options.replace(' ', '\n'))
}
ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "dos")
})
binding.setVariable("unixVMOptions", { String target, String name, String name64 = (name + "64") ->
if (name != null) {
ant.echo(file: "$target/bin/${name}.vmoptions", message: "${vmOptions32()} -Dawt.useSystemAAFontSettings=lcd".trim().replace(' ', '\n'))
}
if (name64 != null) {
ant.echo(file: "$target/bin/${name64}.vmoptions", message: "${vmOptions64()} -Dawt.useSystemAAFontSettings=lcd".trim().replace(' ', '\n'))
}
ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "unix")
})
binding.setVariable("unixReadme", { String target, String home, Map args ->
String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
String settings_dir = args.system_selector.replaceFirst("\\d+", "")
copyAndPatchFile("$home/build/Install-Linux-tar.txt", "$target/Install-Linux-tar.txt",
["product_full": fullName,
"product": p("component.names.product").toLowerCase(),
"system_selector": args.system_selector,
"settings_dir": settings_dir], "@@")
ant.fixcrlf(file: "$target/bin/Install-Linux-tar.txt", eol: "unix")
})
binding.setVariable("forceDelete", { String dirPath ->
// if wasn't deleted - retry several times
attempt = 1
@@ -709,491 +317,6 @@ binding.setVariable("forceDelete", { String dirPath ->
}
})
binding.setVariable("patchPropertiesFile", { String target, Map args = [:] ->
String file = "$target/bin/idea.properties"
if (args.appendices != null) {
ant.concat(destfile: file, append: true) {
args.appendices.each {
fileset(file: it)
}
}
}
String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
String settings_dir = args.system_selector.replaceFirst("\\d+(\\.\\d+)?", "")
ant.replace(file: file) {
replacefilter(token: "@@product_uc@@", value: product_uc)
replacefilter(token: "@@settings_dir@@", value: settings_dir)
}
String message = (isEap() ? """
#-----------------------------------------------------------------------
# Change to 'disabled' if you don't want to receive instant visual notifications
# about fatal errors that happen to an IDE or plugins installed.
#-----------------------------------------------------------------------
idea.fatal.error.notification=enabled
"""
: """
#-----------------------------------------------------------------------
# Change to 'enabled' if you want to receive instant visual notifications
# about fatal errors that happen to an IDE or plugins installed.
#-----------------------------------------------------------------------
idea.fatal.error.notification=disabled
""")
ant.echo(file: file, append: true, message: message)
})
binding.setVariable("zipSources", { String home, String targetDir ->
String sources = "$targetDir/sources.zip"
projectBuilder.stage("zip sources to $sources")
ant.mkdir(dir: targetDir)
ant.delete(file: sources)
ant.zip(destfile: sources) {
fileset(dir: home) {
["java", "groovy", "ipr", "iml", "form", "xml", "properties", "kt"].each {
include(name: "**/*.$it")
}
exclude(name: "**/testData/**")
exclude(name: "out/**")
}
}
notifyArtifactBuilt(sources)
})
binding.setVariable("zipSourcesOfModules", { String targetFilePath, Collection<String> modules ->
projectBuilder.stage("zip sources of ${modules.size()} modules to $targetFilePath")
ant.mkdir(dir: new File(targetFilePath).getParent())
ant.delete(file: targetFilePath)
ant.zip(destfile: targetFilePath) {
modules.each {
JpsModule module = findModule(it)
module.getSourceRoots(JavaSourceRootType.SOURCE).each { root ->
ant.zipfileset(dir: root.file.absolutePath, prefix: root.properties.packagePrefix.replace('.', '/'), erroronmissingdir: false)
}
module.getSourceRoots(JavaResourceRootType.RESOURCE).each { root ->
ant.zipfileset(dir: root.file.absolutePath, prefix: root.properties.relativeOutputPath, erroronmissingdir: false)
}
}
}
notifyArtifactBuilt(targetFilePath)
})
binding.setVariable("moduleSrc", {String moduleName ->
result = []
JpsModule module = findModule(moduleName)
if (module == null) projectBuilder.error("Module $moduleName not found")
module.getSourceRoots(JavaSourceRootType.SOURCE).each { root ->
result << ant.zipfileset(dir: root.file.absolutePath , prefix: root.properties.packagePrefix.replace('.', '/'), erroronmissingdir: false)
}
result
})
/**
* E.g.
*
* Load all properties from file:
* readIdeaProperties("idea.properties.path" : "$home/ruby/build/idea.properties")
*
* Load all properties except "idea.cycle.buffer.size", change "idea.max.intellisense.filesize" to 3000
* and enable "idea.is.internal" mode:
* readIdeaProperties("idea.properties.path" : "$home/ruby/build/idea.properties",
* "idea.properties" : ["idea.max.intellisense.filesize" : 3000,
* "idea.cycle.buffer.size" : null,
* "idea.is.internal" : true ])
* @param args
* @return text xml properties description in xml
*/
private Map readIdeaProperties(Map args) {
String ideaPropertiesPath = args == null ? null : args.get("idea.properties.path")
if (ideaPropertiesPath == null) {
return [:]
}
// read idea.properties file
Properties ideaProperties = new Properties();
FileInputStream ideaPropertiesFile = new FileInputStream(ideaPropertiesPath);
ideaProperties.load(ideaPropertiesFile);
ideaPropertiesFile.close();
def defaultProperties = ["CVS_PASSFILE": "~/.cvspass",
"com.apple.mrj.application.live-resize": "false",
"idea.paths.selector": args.system_selector,
"idea.executable": args.executable,
"java.endorsed.dirs": "",
"idea.smooth.progress": "false",
"apple.laf.useScreenMenuBar": "true",
"apple.awt.fileDialogForDirectories": "true",
"apple.awt.graphics.UseQuartz": "true",
"apple.awt.fullscreencapturealldisplays": "false"]
if (args.platform_prefix != null) {
defaultProperties.put("idea.platform.prefix", args.platform_prefix)
}
Map properties = defaultProperties
def customProperties = args.get("idea.properties")
if (customProperties != null) {
properties += customProperties
}
properties.each {k, v ->
if (v == null) {
// if overridden with null - ignore property
ideaProperties.remove(k)
} else {
// if property is overridden in args map - use new value
ideaProperties.put(k, v)
}
}
return ideaProperties;
}
private String submapToXml(Map properties, List keys) {
// generate properties description for Info.plist
StringBuilder buff = new StringBuilder()
keys.each { key ->
String value = properties[key]
if (value != null) {
String string =
"""
<key>$key</key>
<string>$value</string>
"""
buff.append(string)
}
}
return buff.toString()
}
private List<File> getChildren(File file) {
if (!file.isDirectory()) return []
return file.listFiles().sort { File f -> f.name.toLowerCase() }
}
binding.setVariable("signExecutableFiles", { String binDir ->
projectBuilder.stage("Signing binaries")
def fileBinDir = new File(binDir)
def fileName = ""
getChildren(fileBinDir).each {
fileName = it.getName()
if (fileName.endsWith(".exe")) {
executeExternalAnt(["dirName": binDir, "fileName": fileName], "$home/build/signBuild.xml")
}
}
projectBuilder.stage("Signing done")
})
binding.setVariable("bundledJDKs"){
bundledJDK(false)
}
binding.setVariable("bundledJDK64s"){
bundledJDK(true)
}
private bundledJDK(boolean win64) {
requireProperty("artifact.linux.no.jdk", "true")
requireProperty("artifact.mac.no.jdk", "true")
requireProperty("jdk.oracle.win", "jdk8u")
requireProperty("jdk.win", "jbre8")
requireProperty("jdk.mac", "jbre8")
requireProperty("jdk.linux", "jbre8")
if (new File("${home}/build/jdk").exists()) {
def jdkDir = new File("${home}/build/jdk/win")
if (p("jdk.oracle.win") != "false" && (jdkDir.exists() && jdkDir.isDirectory())) {
setProperty("winJDK", getPathToBundledJDK(jdkDir, p("jdk.oracle.win"), (win64 ? "x64.tar.gz": "x86.tar.gz")))
extractRedistJre(winJDK, "${paths.sandbox}/jdk.oracle.win/jre")
}
if (p("jdk.win") != "false" && (jdkDir.exists() && jdkDir.isDirectory())) {
setProperty("winCustomJDKx32", getPathToBundledJDK(jdkDir, p("jdk.win"), (win64 ? "x64.tar.gz": "x86.tar.gz")))
extractRedistJre(winCustomJDKx32, "${paths.sandbox}/jdk.win/jre")
}
jdkDir = new File("${home}/build/jdk/mac")
if (p("jdk.mac") != "false" && (jdkDir.exists() && jdkDir.isDirectory())) {
setProperty("macCustomJDK", getPathToBundledJDK(jdkDir, p("jdk.mac"), ".tar.gz"))
}
jdkDir = new File("${home}/build/jdk/linux")
if (p("jdk.linux") != "false" && (jdkDir.exists() && jdkDir.isDirectory())) {
setProperty("linuxJDK", getPathToBundledJDK(jdkDir, p("jdk.linux"), ".tar.gz"))
extractRedistJre(linuxJDK, "${paths.sandbox}/jdk.linux/jre")
}
}
}
binding.setVariable("getPathToBundledJDK", { File jdkDir, String prefix, String ext ->
def JdkFileName = ""
getChildren(jdkDir).each {
if (it.getName().startsWith(prefix) && it.getName().endsWith(ext)) {
JdkFileName = it.getAbsolutePath()
if (ext.endsWith(".tar.gz")) {
def OriginalJdkFileName = JdkFileName.substring(0, JdkFileName.length() - 3)
JdkFileName = JdkFileName.substring(0, JdkFileName.length() - 7) + "_${buildNumber}.tar"
if (new File(JdkFileName).exists()) { ant.delete(file: JdkFileName) }
ant.gunzip(src: it.getAbsolutePath())
ant.copy(file: OriginalJdkFileName, tofile: JdkFileName)
}
}
}
return JdkFileName.replace('\\', '/')
})
binding.setVariable("buildWinZip", { String zipPath, List paths, String zipPrefix = "" ->
projectBuilder.stage(".win.zip")
fixIdeaPropertiesEol(paths, "dos")
ant.zip(zipfile: zipPath) {
paths.each {
zipfileset(dir: it, prefix: zipPrefix)
}
}
notifyArtifactBuilt(zipPath)
})
binding.setVariable("buildCrossPlatformZip", { String zipPath, String sandbox, List commonPaths, String distWin, String distUnix, String distMac ->
projectBuilder.stage("Building cross-platform zip")
def executableName = StringUtil.trimEnd(new File(distMac, "bin").list().find { it.endsWith(".vmoptions") }, ".vmoptions")
def zipDir = "$sandbox/cross-platform-zip"
def ideaPropertiesFile = commonPaths.collect { new File(it, "bin/idea.properties") }.find { it.exists() }
["win", "linux"].each {
ant.mkdir(dir: "$zipDir/bin/$it")
ant.copy(file: ideaPropertiesFile.absolutePath, todir: "$zipDir/bin/$it")
}
ant.fixcrlf(file: "$zipDir/bin/win/idea.properties", eol: "dos")
ant.copy(todir: "$zipDir/bin/linux") {
fileset(dir: "$distUnix/bin") {
include(name: "*.vmoptions")
}
}
ant.copy(todir: "$zipDir/bin/mac") {
fileset(dir: "$distMac/bin") {
include(name: "${executableName}.vmoptions")
include(name: "idea.properties")
}
}
ant.copy(file: "$distMac/bin/${executableName}.vmoptions", tofile: "$zipDir/bin/mac/${executableName}64.vmoptions")
ant.copy(todir: "$zipDir/bin") {
fileset(dir: "$distMac/bin") {
include(name: "*.jnilib")
}
mapper(type: "glob", from: "*.jnilib", to: "*.dylib")
}
ant.zip(zipfile: zipPath, duplicate: "fail") {
commonPaths.each {
fileset(dir: it) {
exclude(name: "bin/idea.properties")
}
}
fileset(dir: zipDir)
fileset(dir: distWin) {
exclude(name: "bin/fsnotifier*.exe")
exclude(name: "bin/*.exe.vmoptions")
exclude(name: "bin/${executableName}*.exe")
}
zipfileset(dir: "$distWin/bin", prefix: "bin/win") {
include(name: "fsnotifier*.exe")
include(name: "*.exe.vmoptions")
}
fileset(dir: distUnix) {
exclude(name: "bin/fsnotifier*")
exclude(name: "bin/*.vmoptions")
exclude(name: "bin/*.sh")
exclude(name: "bin/*.py")
exclude(name: "help/**")
}
zipfileset(dir: "$distUnix/bin", prefix: "bin", filemode: "775") {
include(name: "*.sh")
include(name: "*.py")
}
zipfileset(dir: "$distUnix/bin", prefix: "bin/linux", filemode: "775") {
include(name: "fsnotifier*")
}
fileset(dir: distMac) {
exclude(name: "bin/fsnotifier*")
exclude(name: "bin/restarter*")
exclude(name: "bin/*.sh")
exclude(name: "bin/*.py")
exclude(name: "bin/*.jnilib")
exclude(name: "bin/idea.properties")
exclude(name: "bin/*.vmoptions")
}
zipfileset(dir: "$distMac/bin", prefix: "bin", filemode: "775") {
include(name: "restarter*")
include(name: "*.py")
}
zipfileset(dir: "$distMac/bin", prefix: "bin/mac", filemode: "775") {
include(name: "fsnotifier*")
}
}
notifyArtifactBuilt(zipPath)
})
binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths, String macPath, List extraBins = [] ->
projectBuilder.stage(".mac.zip")
allPaths = paths + [macPath]
ant.zip(zipfile: zipPath) {
allPaths.each {
zipfileset(dir: it, prefix: zipRoot) {
exclude(name: "bin/*.sh")
exclude(name: "bin/*.py")
exclude(name: "bin/fsnotifier")
exclude(name: "bin/restarter")
exclude(name: "MacOS/*")
exclude(name: "build.txt")
exclude(name: "NOTICE.txt")
extraBins.each {
exclude(name: it)
}
exclude(name: "bin/idea.properties")
}
}
allPaths.each {
zipfileset(dir: it, prefix: zipRoot, filemode: "755") {
include(name: "bin/*.sh")
include(name: "bin/*.py")
include(name: "bin/fsnotifier")
include(name: "bin/restarter")
include(name: "MacOS/*")
extraBins.each {
include(name: it)
}
}
}
allPaths.each {
zipfileset(dir: it, prefix: "$zipRoot/Resources") {
include(name: "build.txt")
include(name: "NOTICE.txt")
}
}
zipfileset(file: "$macPath/bin/idea.properties", prefix: "$zipRoot/bin")
}
})
binding.setVariable("buildTarGz", { String tarRoot, String tarPath, List paths, List extraBins = [] ->
projectBuilder.stage(".tar.gz")
fixIdeaPropertiesEol(paths, "unix")
ant.tar(tarfile: tarPath, longfile: "gnu") {
paths.each {
tarfileset(dir: it, prefix: tarRoot) {
exclude(name: "bin/*.sh")
exclude(name: "bin/*.py")
exclude(name: "bin/fsnotifier*")
extraBins.each {
exclude(name: it)
}
type(type: "file")
}
}
paths.each {
tarfileset(dir: it, prefix: tarRoot, filemode: "755") {
include(name: "bin/*.sh")
include(name: "bin/*.py")
include(name: "bin/fsnotifier*")
extraBins.each {
include(name: it)
}
type(type: "file")
}
}
}
String gzPath = "${tarPath}.gz"
ant.gzip(src: tarPath, zipfile: gzPath)
ant.delete(file: tarPath)
notifyArtifactBuilt(gzPath)
})
binding.setVariable("extractRedistJre", { String jdk_file_name, String destination ->
def jre_redist = "${destination}"
def jdkArchive = new File(jdk_file_name)
if (jdkArchive.exists()) {
ant.mkdir(dir: jre_redist)
if (jdk_file_name.endsWith(".tar")) {
ant.untar(dest: jre_redist, src: "${jdk_file_name}")
}
else {
ant.unzip(dest: jre_redist, src: "${jdk_file_name}")
}
} else {
projectBuilder.error("${jdk_file_name} doesn't exist.")
}
})
private void fixIdeaPropertiesEol(List paths, String eol) {
paths.each {
String file = "$it/bin/idea.properties"
if (new File(file).exists()) {
ant.fixcrlf(file: file, eol: eol)
}
}
}
binding.setVariable("buildWinLauncher", { String ch, String inputPath, String outputPath, String appInfo,
String launcherProperties, String pathsSelector, List resourcePaths ->
projectBuilder.stage("winLauncher")
if (pathsSelector != null) {
def paths = getProperty("paths")
def launcherPropertiesTemp = "${paths.sandbox}/launcher.properties"
copyAndPatchFile(launcherProperties, launcherPropertiesTemp, ["PRODUCT_PATHS_SELECTOR": pathsSelector,
"product_uc" : p("component.names.product").toLowerCase(),
"IDE-NAME": p("component.names.product").toUpperCase()])
launcherProperties = launcherPropertiesTemp
}
ant.java(classname: "com.pme.launcher.LauncherGeneratorMain", fork: "true", failonerror: "true") {
sysproperty(key: "java.awt.headless", value: "true")
arg(value: inputPath)
arg(value: appInfo)
arg(value: "$ch/native/WinLauncher/WinLauncher/resource.h")
arg(value: launcherProperties)
arg(value: outputPath)
classpath {
pathelement(location: "$ch/build/lib/launcher-generator.jar")
fileset(dir: "$ch/lib") {
include(name: "guava*.jar")
include(name: "jdom.jar")
include(name: "sanselan*.jar")
}
resourcePaths.each {
pathelement(location: it)
}
}
}
})
binding.setVariable("layoutUpdater", { String target, String jarName = "updater.jar" ->
layout(target) {
jar(jarName) {
module("updater")
manifest {
attribute(name: "Main-Class", value: "com.intellij.updater.Bootstrap")
}
}
}
})
binding.setVariable("collectUsedJars", { List modules, List approvedJars, List forbiddenJars, List modulesToBuild ->
def usedJars = new HashSet();
@@ -1236,55 +359,6 @@ binding.setVariable("buildModulesAndCollectUsedJars", { List modules, List appro
return usedJars
})
binding.setVariable("buildSearchableOptions", { String target, List licenses, Closure cp, String jvmArgs = null,
def paths = getProperty("paths") ->
def pathToJRT = "${projectBuilder.moduleOutput(findModule(javaRT))}"
projectBuilder.stage("Building searchable options JRT:" + pathToJRT)
String targetFile = "${target}/searchableOptions.xml"
ant.delete(file: targetFile)
licenses.each {
ant.copy(file: it, todir: paths.ideaSystem)
}
ant.path(id: "searchable.options.classpath") { cp() }
String classpathFile = "${paths.sandbox}/classpath.txt"
ant.echo(file: classpathFile, append: false, message: "\${toString:searchable.options.classpath}")
ant.replace(file: classpathFile, token: File.pathSeparator, value: "\n")
ant.java(classname: "com.intellij.rt.execution.CommandLineWrapper", fork: true, failonerror: true) {
jvmarg(line: "-ea -Xmx500m -XX:MaxPermSize=200m")
jvmarg(value: "-Xbootclasspath/a:${projectBuilder.moduleOutput(findModule("boot"))}")
jvmarg(value: "-Didea.home.path=${home}")
jvmarg(value: "-Didea.system.path=${paths.ideaSystem}")
jvmarg(value: "-Didea.config.path=${paths.ideaConfig}")
if (jvmArgs != null) {
jvmarg(line: jvmArgs)
}
arg(value: "${classpathFile}")
arg(line: "com.intellij.idea.Main traverseUI")
arg(value: "${target}/searchableOptions.xml")
classpath() {
pathelement(location: "${pathToJRT}")
}
}
ant.available(file: targetFile, property: "searchable.options.exists");
ant.fail(unless: "searchable.options.exists", message: "Searchable options were not built.")
})
binding.setVariable("reassignAltClickToMultipleCarets", {String communityHome ->
String defaultKeymapContent = new File("$communityHome/platform/platform-resources/src/idea/Keymap_Default.xml").text
defaultKeymapContent = defaultKeymapContent.replace("<mouse-shortcut keystroke=\"alt button1\"/>", "")
defaultKeymapContent = defaultKeymapContent.replace("<mouse-shortcut keystroke=\"alt shift button1\"/>",
"<mouse-shortcut keystroke=\"alt button1\"/>")
patchedKeymapFile = new File("${paths.sandbox}/classes/production/platform-resources/idea/Keymap_Default.xml")
patchedKeymapFile.write(defaultKeymapContent)
})
// modules used in Upsource and in Kotlin as an API to IDEA
binding.setVariable("analysisApiModules", [
"analysis-api",