NPE fix in XmlUtil
[fedora-idea.git] / build / scripts / layouts.gant
blob2ef163ed660df5dee5e917a6e7e3384316157a69
1 import org.jetbrains.jps.Module
2 import static org.jetbrains.jps.idea.IdeaProjectLoader.*
4 includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
6 target('default' : "Developers update") {
7   layoutFull(home, deploy)
10 def module(String name) {
11   ant.module(name: name)
12   markUsed(name)
15 def module(String name, Closure init) {
16   ant.module(name: name, init)
17   markUsed(name)
20 private def markUsed(String name) {
21   def module = project.modules[name]
22   // Can be null in "Developers update" since we are not actually loading modules.xml
23   if (module != null) {
24     module["used"] = true
25   }
28 private List platformImplementationModules() {
29   return [
30           "platform-impl",
31           "vcs-impl",
32           "lang-impl",
33           "testRunner",
34           "smRunner",
35           "xdebugger-impl",
36           "testFramework",
37           "xml",
38           "lvcs-impl",
39           "images",
40   ]
43 private List<String> platformApiModules() {
44   return ["platform-api", "lvcs-api", "lang-api", "vcs-api", "usageView", "xdebugger-api", "xml-openapi"]
47 def layoutFull(String home, String targetDirectory) {
48   project.stage("layout to $targetDirectory")
50   //noinspection GroovyAssignabilityCheck
51   List<String> openapiModules = [platformApiModules(),
52           "openapi", "testFramework-java", "debugger-openapi", "compiler-openapi", "dom-openapi", "execution-openapi",
53           "jsp-openapi", "jsp-base-openapi"].flatten()
55   //noinspection GroovyAssignabilityCheck
56   List<String> implementationModules = [platformImplementationModules(),
57           "notNull",
58           "platform-main",
59           "java-impl",
60           "compiler-impl",
61           "debugger-impl",
62           "dom-impl",
63           "execution-impl",
64           "jsp-spi",
65           "idea-ui",
66           "RegExpSupport"].flatten()
68   ant.patternset(id: "resources.included") {
69     include(name: "**/*.properties")
70     include(name: "fileTemplates/**/*")
71     include(name: "inspectionDescriptions/**/*")
72     include(name: "intentionDescriptions/**/*")
73     include(name: "tips/**/*")
74   }
76   ant.patternset(id: "resources.excluded") {
77     exclude(name: "**/*.properties")
78     exclude(name: "fileTemplates/**/*")
79     exclude(name: "fileTemplates")
80     exclude(name: "inspectionDescriptions/**/*")
81     exclude(name: "inspectionDescriptions")
82     exclude(name: "intentionDescriptions/**/*")
83     exclude(name: "intentionDescriptions")
84     exclude(name: "tips/**/*")
85     exclude(name: "tips")
86   }
88   layout(targetDirectory) {
89     dir("lib") {
90       jar("util.jar") { module("util") }
92       jar("openapi.jar") {
93         openapiModules.each { module it}
94       }
96       jar("annotations.jar") { module("annotations")}
97       jar("extensions.jar") { module("extensions")}
99       jar("idea.jar") {
100         implementationModules.each { module it}
101       }
103       jar("bootstrap.jar") { module("bootstrap")}
104       jar("resources.jar") {
105         module("resources")
106         module("platform-resources")
107         module("community-resources")
108       }
110       jar("idea_rt.jar") { module("java-runtime")}
112       jar("forms_rt.jar") {
113         module("forms_rt")
114         module("forms-compiler")
115       }
117       jar("resources_en.jar") {
118         module("resources-en")
119         module("platform-resources-en")
120       }
122       jar("icons.jar") { module("icons") }
123       jar("boot.jar") { module("boot") }
125       jar("javac2.jar") {
126         module("javac2")
127         module("forms-compiler")
128         module("forms_rt")
129         module("notNull")
130       }
132       fileset(dir: "$home/lib") {
133         include(name: "*.jar")
134         exclude(name: "eawtstub.jar")
135       }
137       fileset(dir: "$home/lib/src") {
138         include(name: "trove4j_changes.txt")
139         include(name: "trove4j_src.jar")
140       }
142       dir("ant") {
143         fileset(dir: "$home/lib/ant") {
144           exclude(name: "**/src/**")
145         }
146       }
147     }
149     dir("plugins") {
150       def simplePlugins = ["commander", "copyright", "properties", "java-i18n", "devkit", "eclipse"]
152       simplePlugins.each {
153         layoutPlugin it
154       }
156       layoutPlugin("ant", "ant", "antIntegration")
157       layoutPlugin("InspectionGadgets", "InspectionGadgetsPlugin")
158       layoutPlugin("IntelliLang", "IntelliLangJava")
159       layoutPlugin("IntentionPowerPack", "IntentionPowerPackPlugin")
160       layoutPlugin("ToString", "generate-tostring", "toString")
162       layoutPlugin("SpellChecker", "spellchecker", "spellchecker-core") {
163         fileset(dir: "$home/plugins/spellchecker/lib")
164       }
167       layoutPlugin("maven") {
168         fileset(dir: "$home/plugins/maven/lib")
169       }
172       layoutPlugin("git4idea") {
173         fileset(dir: "$home/plugins/git4idea/lib", excludes: "**/trilead-ssh2-src.zip")
174       }
176       layoutPlugin("svn4idea") {
177         fileset(dir: "$home/plugins/svn4idea/lib", excludes: "**/svnkitsrc.zip")
178       }
181       dir("junit") {
182         dir("lib") {
183           jar("junit-rt.jar") {
184             module("junit_rt")
185           }
186           jar("idea-junit.jar") {
187             noResources("junit")
188           }
189           resources("junit")
190         }
191       }
194       dir("cvsIntegration") {
195         dir("lib") {
196           jar("cvs_util.jar") {noResources("cvs-core")}
197           jar("cvsIntegration.jar") {noResources("cvs-plugin")}
198           jar("javacvs-src.jar") {noResources("javacvs-src")}
199           jar("smartcvs-src.jar") {noResources("smartcvs-src")}
201           resources(["cvs-core", "cvs-plugin", "javacvs-src", "smartcvs-src"])
203           fileset(dir: "${home}/plugins/cvs/lib")
204         }
205       }
208       dir("uiDesigner") {
209         dir("lib") {
210           jar("uiDesigner.jar") {
211             noResources("ui-designer")
212           }
213           resources("ui-designer")
214         }
215       }
217       dir("testng") {
218         dir("lib") {
219           jar("testng.jar") {
220             noResources("testng")
221             noResources("testng_rt")
222           }
224           resources("testng")
226           fileset(dir: "$home/plugins/testng/lib") {
227             include(name: "testng-jdk15.jar")
228           }
229         }
231         dir("lib-jdk14") {
232           fileset(dir: "$home/plugins/testng/lib") {
233             include(name: "testng-jdk14.jar")
234           }
235         }
236       }
239       dir("Groovy") {
240         dir("lib") {
241           jar("Groovy.jar") {
242             module("jetgroovy") {
243               exclude(name: "standardDsls/**")
244             }
245           }
247           jar("groovy_rt.jar") {module("groovy-rt")}
248           dir("standardDsls") {
249             fileset(dir: "$home/plugins/groovy/resources/standardDsls")
250           }
252           fileset(dir: "$home/plugins/groovy/resources/conf")
253           fileset(dir: "${home}/plugins/groovy/lib")
254         }
255       }
256     }
257   }
259   printUnusedModules()
261   //reorder(targetDirectory)
264 def printUnusedModules() {
265   project.modules.values().each {Module m ->
266     if (m["used"] == null && hasSourceRoots(m)) {
267       project.warning("Module ${m.getName()} is not used in project layout")
268     }
269   }
272 boolean hasSourceRoots(Module module) {
273   !module.sourceRoots.isEmpty()
276 def layoutPlugin(String moduleName) {
277   layoutPlugin(moduleName, moduleName, {})
280 def layoutPlugin(String moduleName, Closure custom) {
281   layoutPlugin(moduleName, moduleName, custom)
284 def layoutPlugin(String pluginName, String moduleName) {
285   layoutPlugin(pluginName, moduleName, {})
288 def layoutPlugin(String pluginName, String moduleName, Closure custom) {
289   layoutPlugin(pluginName, moduleName, pluginName, custom)
292 def layoutPlugin(String pluginName, String moduleName, String jarName) {
293   layoutPlugin(pluginName, moduleName, jarName, {})
296 def layoutPlugin(String pluginName, String moduleName, String jarName, Closure custom) {
297   dir(pluginName) {
298     dir("lib") {
299       jar("${jarName}.jar") {
300         noResources(moduleName)
301       }
303       resources(moduleName)
304       custom()
305     }
306   }
309 private def resources(List<String> modules) {
310   jar("resources_en.jar") {
311     modules.each {
312       module(it) {
313         patternset(refid: "resources.included")
314       }
315     }
316   }
319 private def resources(String moduleName) {
320   jar("resources_en.jar") {
321     module(moduleName) {
322       patternset(refid: "resources.included")
323     }
324   }
327 private def noResources(String moduleName) {
328   module(moduleName) {
329     patternset(refid: "resources.excluded")
330   }
333 def reorder(String home, String targetDirectory) {
334   if (isDefined("util")) {
335     ant.java(classname: "com.intellij.util.io.zip.ReorderJarsMain", fork: "true") {
336       arg(value: "$home/build/order.txt")
337       arg(value: targetDirectory)
338       arg(value: targetDirectory)
339       arg(value: "$home/lib")
340       classpath {
341         pathelement(location: util.output)
342       }
343     }
344   }