Snapshot af729d01433bb5bbd6ca93c0fdf9778b36d624ce from master branch of git://git.jetbrains.org/idea/community.git

Change-Id: I214dd066d0d27444a26166c0eae1a5aaf3705d49
diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant
index ce60329..a03f512 100644
--- a/build/scripts/dist.gant
+++ b/build/scripts/dist.gant
@@ -28,7 +28,6 @@
   final distMac
   final artifacts
   final artifacts_core
-  final artifacts_core_upsource
   final artifacts_jps
 
   def Paths(String out) {
@@ -39,7 +38,6 @@
     distMac = "$sandbox/dist.mac.ce"
     artifacts = "$sandbox/artifacts"
     artifacts_core = "$artifacts/core"
-    artifacts_core_upsource = "$artifacts/core-upsource"
     artifacts_jps = "$artifacts/jps"
   }
 }
@@ -103,8 +101,6 @@
   layouts.layoutFull(home, paths.distAll, null)
   layouts.layout_core(home, paths.artifacts_core)
   notifyArtifactBuilt(paths.artifacts_core)
-  layouts.layout_core_upsource(home, paths.artifacts_core_upsource)
-  notifyArtifactBuilt(paths.artifacts_core_upsource)
   if (buildJps) {
     layouts.layoutCommunityJps(home, paths.artifacts_jps)
     notifyArtifactBuilt(paths.artifacts_jps)
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index 4ac31f9..b7475ea 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -80,9 +80,6 @@
     "platform-main",
     "testFramework",
     "tests_bootstrap",
-    "InspectionGadgetsAnalysis",
-    "InspectionGadgetsPlugin",
-    "IntentionPowerPackPlugin",
           ].flatten()
 
   ant.patternset(id: "resources.included") {
@@ -251,7 +248,6 @@
         module("ant-jps-plugin")
       }
     }
-    layoutPlugin("ToString", "generate-tostring", "toString")
     layoutPlugin("uiDesigner", "ui-designer", "uiDesigner") {
       dir("jps") {
         jar("ui-designer-jps-plugin.jar") {
@@ -438,7 +434,6 @@
       dir("lib") {
         jar("tasks-api.jar") { module("tasks-api") }
         jar("tasks-core.jar") { module("tasks-core") }
-        jar("jira-connector.jar") { module("jira-connector") }
         jar("tasks-java.jar") { moduleOptional("tasks-java") }
         fileset(dir: "${home}/plugins/tasks/tasks-core/lib") {
           include(name: "**/*.jar")
@@ -718,8 +713,6 @@
       module("extensions")
       module("java-psi-api")
       module("java-psi-impl")
-      module("analysis-api")
-      module("analysis-impl")
     }
 
     jar("annotations.jar") {
@@ -733,61 +726,8 @@
       include(name: "asm.jar")
       include(name: "asm-commons.jar")
       include(name: "cli-parser-1.1.jar")
-    }
-  }
-}
-
-def layout_core_upsource(String home, String target) {
-  layout(target) {
-    jar("intellij-core-upsource.jar") {
-      module("util-rt")
-      module("util")
-      module("icons")
-      module("core-api")
-      module("core-impl")
-      module("boot")
-      module("extensions")
-      module("indexing-api")
-      module("indexing-impl")
-      module("java-psi-api")
-      module("java-psi-impl")
-      module("projectModel-api")
-      module("projectModel-impl")
-      module("jps-model-api")
-      module("jps-model-impl")
-      module("jps-model-serialization")
-      module("java-indexing-api")
-      module("java-indexing-impl")
-      module("platform-resources")
-      module("platform-resources-en")
-      module("analysis-api")
-      module("analysis-impl")
-      module("java-analysis-api")
-      module("java-analysis-impl")
-      module("InspectionGadgetsAnalysis")
-      module("xml-psi-api")
-      module("xml-psi-impl")
-      module("resources") // IdeaPlugin.xml
-    }
-
-    jar("annotations.jar") {
-      module("annotations")
-    }
-
-    fileset(dir: "$home/lib") {
-      include(name: "guava-14.0.1.jar")
-      include(name: "picocontainer.jar")
-      include(name: "trove4j.jar")
-      include(name: "asm.jar")
-      include(name: "asm-commons.jar")
-      include(name: "asm4-all.jar")
-      include(name: "cli-parser-1.1.jar")
-      include(name: "jna.jar")
-      include(name: "log4j.jar")
-      include(name: "xstream-1.4.3.jar")
-      include(name: "xpp3-1.1.4-min.jar")
-      include(name: "jdom.jar")
-      include(name: "nanoxml*.jar")
+      include(name: "snappy-java-1.0.5.jar")
+      include(name: "jayatana-1.2.4.jar")
     }
   }
 }
diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant
index 3f86792..c6b526f 100644
--- a/build/scripts/libLicenses.gant
+++ b/build/scripts/libLicenses.gant
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -14,9 +14,11 @@
  * limitations under the License.
  */
 
-import org.jetbrains.jps.ClasspathKind
-import org.jetbrains.jps.Library
-import org.jetbrains.jps.Module
+import org.jetbrains.jps.model.java.JpsJavaClasspathKind
+import org.jetbrains.jps.model.java.JpsJavaExtensionService
+import org.jetbrains.jps.model.library.JpsLibrary
+import org.jetbrains.jps.model.library.JpsOrderRootType
+import org.jetbrains.jps.model.module.JpsModule
 
 class LibraryLicense {
   String name, url, version
@@ -44,27 +46,25 @@
   jetbrainsLibraries << name
 })
 
-def String getLibraryName(Library lib) {
+def String getLibraryName(JpsLibrary lib) {
   def name = lib.name
-  if (name.startsWith("moduleLibrary#")) {
-    if (lib.classpath.size() != 1) {
+  if (name.startsWith("#")) {
+    if (lib.getRoots(JpsOrderRootType.COMPILED).size() != 1) {
       projectBuilder.warning("Non-single entry module library $name: $lib.classpath");
     }
-    String filePath = lib.classpath[0]
-    return filePath.substring(filePath.lastIndexOf('/')+1)
+    File file = lib.getFiles(JpsOrderRootType.COMPILED)[0]
+    return file.name
   }
   return name
 }
 
 binding.setVariable("checkLibLicenses", {
-  def libraries = new HashSet<Library>()
-  def lib2Module = new HashMap<Library, Module>();
-  allModules().each {Module module ->
-    module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each {
-      if (it instanceof Library) {
-        lib2Module[it] = module
-        libraries << it
-      }
+  def libraries = new HashSet<JpsLibrary>()
+  def lib2Module = new HashMap<JpsLibrary, JpsModule>();
+  allModules().each {JpsModule module ->
+    JpsJavaExtensionService.dependencies(module).includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).getLibraries().each {
+      lib2Module[it] = module
+      libraries << it
     }
   }
 
@@ -72,7 +72,7 @@
   libWithLicenses.addAll(jetbrainsLibraries)
 
   List<String> withoutLicenses = []
-  libraries.each {Library lib ->
+  libraries.each {JpsLibrary lib ->
     def name = getLibraryName(lib)
     if (!libWithLicenses.contains(name)) {
       withoutLicenses << "$name (used in module ${lib2Module[lib].name})".toString()
@@ -94,13 +94,11 @@
 binding.setVariable("generateLicensesTable", {String filePath, Set<String> usedModulesNames ->
   projectBuilder.info("Generating licenses table")
   projectBuilder.info("Used modules: $usedModulesNames")
-  Set<Module> usedModules = allModules().findAll {usedModulesNames.contains(it.name)}
+  Set<JpsModule> usedModules = allModules().findAll {usedModulesNames.contains(it.name)}
   Map<String, String> usedLibraries = [:]
-  usedModules.each {Module module ->
-    module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each {item ->
-      if (item instanceof Library) {
-        usedLibraries[getLibraryName(item)] = module.name
-      }
+  usedModules.each {JpsModule module ->
+    JpsJavaExtensionService.dependencies(module).includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).getLibraries().each {item ->
+      usedLibraries[getLibraryName(item)] = module.name
     }
   }
 
@@ -200,10 +198,11 @@
 libraryLicense(name: "JGoodies Looks", libraryName: "jgoodies-looks", version: "2.4.2", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
 libraryLicense(name: "JGoodies Common", libraryName: "jgoodies-common", version: "1.2.1", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html")
 libraryLicense(name: "JNA", libraryName: "jna", version: "3.4.0", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php")
-libraryLicense(name: "JSch", libraryName: "JSch", version: "0.1.49", license: "BSD", url: "http://www.jcraft.com/jsch/", licenseUrl: "http://www.jcraft.com/jsch/LICENSE.txt")
+libraryLicense(name: "JSch", libraryName: "JSch", version: "0.1.50", license: "BSD", url: "http://www.jcraft.com/jsch/", licenseUrl: "http://www.jcraft.com/jsch/LICENSE.txt")
 libraryLicense(name: "JUnit", libraryName: "JUnit3", version: "3.8.1", license: "CPL 1.0", url: "http://junit.org/")
 libraryLicense(name: "JUnit", libraryName: "JUnit4", version: "4.8", license: "CPL 1.0", url: "http://junit.org/")
 libraryLicense(name: "Log4j", libraryName: "Log4J", version: "1.2.17", license: "Apache 2.0", url: "http://logging.apache.org/log4j/1.2/index.html", licenseUrl: "http://logging.apache.org/license.html")
+libraryLicense(name: "markdownj", libraryName: "markdownj", version: "0.4.2", license: "New BSD", url: "https://code.google.com/p/markdownj/", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause")
 libraryLicense(name: "Maven", version: "2.2.1", license: "Apache 2.0", url: "http://maven.apache.org/", licenseUrl: "http://maven.apache.org/license.html")
 libraryLicense(name: "plexus-util", version: "2.0.6", license: "Apache 2.0", url: "http://maven.apache.org/", libraryNames:['plexus-utils-2.0.6.jar'], licenseUrl: "http://apache.org/licenses/LICENSE-2.0")
 libraryLicense(name: "aether-api", version: "1.11", libraryNames: ["aether-api-1.11.jar"], license: "Apache 2.0", url: "http://maven.apache.org/", licenseUrl: "http://maven.apache.org/license.html")
@@ -212,7 +211,7 @@
 libraryLicense(name: "maven-core", version: "3.0.3", libraryNames: ["maven-core-3.0.3.jar"], license: "Apache 2.0", url: "http://maven.apache.org/", licenseUrl: "http://maven.apache.org/license.html")
 libraryLicense(name: "plexus-component-annotations", version: "1.5.5", libraryNames: ["plexus-component-annotations-1.5.5.jar"], license: "Apache 2.0", url: "http://maven.apache.org/", licenseUrl: "http://maven.apache.org/license.html")
 libraryLicense(name: "Maven3", libraryNames: ["Maven3", "maven-dependency-tree-1.2.jar", "archetype-catalog-2.2.jar", "archetype-common-2.2.jar"], version: "3.0.3", license: "Apache 2.0", url: "http://maven.apache.org/", licenseUrl: "http://maven.apache.org/license.html")
-libraryLicense(name: "Gradle", version: "1.6", license: "Apache 2.0", url: "http://gradle.org/", licenseUrl: "http://gradle.org/license")
+libraryLicense(name: "Gradle", version: "1.8", license: "Apache 2.0", url: "http://gradle.org/", licenseUrl: "http://gradle.org/license")
 libraryLicense(name: "Slf4j", version: "1.7.2", license: "MIT License", url: "http://slf4j.org/", licenseUrl: "http://slf4j.org/license.html")
 libraryLicense(name: "GradleGuava", version: "11.0.2", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0")
 libraryLicense(name: "Jsr305", version: "1.3.9", license: "New BSD", url: "http://code.google.com/p/jsr-305/", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause")
@@ -266,6 +265,8 @@
 libraryLicense(name: "bouncy-castle", version: "1.48", license: "MIT License", url: "http://bouncycastle.org", licenseUrl: "http://bouncycastle.org/licence.html")
 libraryLicense(name: "kXML2", libraryName: "kxml2", version: "2.3.0", license: "BSD", url: "http://sourceforge.net/projects/kxml/")
 libraryLicense(name: "Lombok AST", libraryName: "lombok-ast", version: "0.2.1", license: "MIT", url: "http://projectlombok.org/", licenseUrl: "http://opensource.org/licenses/mit-license.php")
+libraryLicense(name: "fxg-utils", libraryName: "fxg-utils", version: "4.9.1", license: "Apache 2.0", url: "http://flex.apache.org", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
+libraryLicense(name: "jayatana", libraryName: "jayatana", version: "1.2.4", license: "MIT License", url: "https://code.google.com/p/java-swing-ayatana/", licenseUrl: "http://opensource.org/licenses/mit-license.php")
 jetbrainsLibrary("JPS")
 jetbrainsLibrary("Maven Embedder")
 jetbrainsLibrary("tcServiceMessages")
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index 8df9913..28edd4a 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -14,11 +14,12 @@
  * limitations under the License.
  */
 
-import org.jetbrains.jps.Jps
-import org.jetbrains.jps.Module
-import org.jetbrains.jps.idea.IdeaProjectLoader
+import org.jetbrains.jps.gant.JpsGantTool
+import org.jetbrains.jps.gant.TeamCityBuildInfoPrinter
+import org.jetbrains.jps.model.java.JavaSourceRootType
+import org.jetbrains.jps.model.module.JpsModule
 
-includeTool << Jps
+includeTool << JpsGantTool
 
 binding.setVariable("p", {String key ->
   return getProperty(key) as String
@@ -122,23 +123,24 @@
       classpath "$jdkHome/lib/tools.jar"
     }
   }
-  IdeaProjectLoader.loadFromPath(project, "${home}")
+  projectBuilder.dataStorageRoot = new File("$home/.jps-build-data")
+  loadProjectFromPath(home)
 })
 
-boolean hasSourceRoots(Module module) {
-  return !module.sourceRoots.isEmpty()
+boolean hasSourceRoots(JpsModule module) {
+  return module.getSourceRoots(JavaSourceRootType.SOURCE).iterator().hasNext()
 }
 
 binding.setVariable("findModule", {String name ->
-  project.modules[name]
+  project.modules.find { it.name == name }
 })
 
 binding.setVariable("allModules", {
-  return project.modules.values()
+  return project.modules
 })
 
 binding.setVariable("printUnusedModules", {Set<String> usedModules ->
-  allModules().each {Module m ->
+  allModules().each {JpsModule m ->
     if (!usedModules.contains(m.name) && hasSourceRoots(m)) {
       projectBuilder.warning("Module $m.name is not used in project layout")
     }
@@ -158,7 +160,7 @@
 
 binding.setVariable("snapshot", readSnapshotBuild())
 
-projectBuilder.buildInfoPrinter = new org.jetbrains.jps.teamcity.TeamcityBuildInfoPrinter()
+projectBuilder.buildInfoPrinter = new TeamCityBuildInfoPrinter()
 projectBuilder.compressJars = false
 
 binding.setVariable("notifyArtifactBuilt", { String artifactPath ->