Merge branch 'svn1_8_new'
[idea/community.git] / build / scripts / layouts.gant
1 /*
2  * Copyright 2000-2013 JetBrains s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
17
18 includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
19
20 target('default': "Developers update") {
21   def patchedDescriptorDir = patchAppDescriptor(deploy)
22   layoutFull(home, deploy, patchedDescriptorDir)
23   ant.delete(dir: patchedDescriptorDir)
24 }
25
26 String appInfoFileName() {
27   return "idea/IdeaApplicationInfo.xml"
28 }
29
30 String patchAppDescriptor(String targetDirectory) {
31   def patchedDirectory = "${targetDirectory}/../patched"
32
33   ant.delete(dir: patchedDirectory)
34
35   layout(patchedDirectory) {
36     module("community-resources") {
37       include(name: appInfoFileName())
38     }
39   }
40
41   ant.replace(file: "$patchedDirectory/${appInfoFileName()}", token: "__BUILD_NUMBER__", value: "IC-$snapshot")
42   ant.replace(file: "$patchedDirectory/${appInfoFileName()}", token: "__BUILD_DATE__", value: new Date().format("yyyyMMddHHmm"))
43
44   return patchedDirectory
45 }
46
47 def layoutFull(String home, String targetDirectory, String patchedDescriptorDir = null) {
48   projectBuilder.stage("layout to $targetDirectory")
49
50   //noinspection GroovyAssignabilityCheck
51   List<String> openapiModules = [platformApiModules,
52     "java-psi-api",
53     "java-analysis-api",
54     "java-indexing-api",
55     "openapi",
56     "testFramework-java",
57     "debugger-openapi",
58     "compiler-openapi",
59     "remote-servers-api",
60     "remote-servers-java-api",
61     "dom-openapi",
62     "execution-openapi",
63     "jsp-openapi",
64     "jsp-base-openapi"].flatten()
65
66   //noinspection GroovyAssignabilityCheck
67   List<String> implementationModules = [platformImplementationModules,
68     "compiler-impl",
69     "remote-servers-impl",
70     "remote-servers-java-impl",
71     "debugger-impl",
72     "dom-impl",
73     "execution-impl",
74     "external-system-impl",
75     "idea-ui",
76     "instrumentation-util",
77     "java-analysis-impl",
78     "java-indexing-impl",
79     "java-impl",
80     "java-psi-impl",
81     "jsp-spi",
82     "manifest",
83     "platform-main",
84     "testFramework",
85     "tests_bootstrap"].flatten()
86
87   ant.patternset(id: "resources.included") {
88     include(name: "**/*.properties")
89     include(name: "fileTemplates/**/*")
90     include(name: "inspectionDescriptions/**/*")
91     include(name: "intentionDescriptions/**/*")
92     include(name: "tips/**/*")
93   }
94
95   ant.patternset(id: "resources.excluded") {
96     exclude(name: "**/*.properties")
97     exclude(name: "fileTemplates/**/*")
98     exclude(name: "fileTemplates")
99     exclude(name: "inspectionDescriptions/**/*")
100     exclude(name: "inspectionDescriptions")
101     exclude(name: "intentionDescriptions/**/*")
102     exclude(name: "intentionDescriptions")
103     exclude(name: "tips/**/*")
104     exclude(name: "tips")
105   }
106
107   def info = layout(targetDirectory) {
108     dir("lib") {
109       dir("rt") {
110         fileset(dir: "${home}/lib/rt", includesfile: "${home}/lib/rt/required_for_dist.txt")
111       }
112
113       jar("util.jar") {
114         module("util")
115         module("util-rt")
116       }
117
118       jar("openapi.jar") {
119         openapiModules.each { module it}
120       }
121
122       jar("annotations.jar") { module("annotations")}
123       jar("jdkAnnotations.jar") {
124         fileset(dir: "${home}/java/jdkAnnotations")
125       }
126
127       jar("extensions.jar") { module("extensions")}
128
129       jar("idea.jar") {
130         implementationModules.each { module it}
131       }
132
133       jar("bootstrap.jar") { module("bootstrap") }
134
135       jar("resources.jar") {
136         module("colorSchemes")
137         module("resources")
138         module("platform-resources")
139         module("community-resources") {
140           if (patchedDescriptorDir != null) {
141             exclude(name: appInfoFileName())
142           }
143         }
144         if (patchedDescriptorDir != null) {
145           fileset(dir: patchedDescriptorDir)
146         }
147       }
148
149       jar("idea_rt.jar") { module("java-runtime")}
150
151       jar("forms_rt.jar") {
152         module("forms_rt")
153         module("forms-compiler")
154       }
155
156       jar("resources_en.jar") {
157         module("resources-en")
158         module("platform-resources-en")
159       }
160
161       jar("icons.jar") { module("icons") }
162       jar("boot.jar") { module("boot") }
163
164       jar("javac2.jar") {
165         module("javac2")
166         module("forms-compiler")
167         module("forms_rt")
168         module("instrumentation-util")
169       }
170
171       jar("jps-server.jar") {
172         module("jps-builders")
173       }
174
175       fileset(dir: "$home/jps/lib") {
176         include(name: "optimizedFileManager.jar")
177       }
178
179       fileset(dir: "$home/lib", includesfile: "${home}/lib/required_for_dist.txt")
180
181       fileset(dir: "$home/lib/src") {
182         include(name: "trove4j_changes.txt")
183         include(name: "trove4j_src.jar")
184       }
185       fileset(dir: "$home/xml/relaxng/lib", includes: "*.jar")
186
187       dir("ant") {
188         fileset(dir: "$home/lib/ant") {
189           exclude(name: "**/src/**")
190         }
191       }
192     }
193
194     layoutCommunityPlugins(home)
195
196     dir("plugins") {
197       dir("javaFX") {
198         dir("lib") {
199           jar("javaFX.jar") {
200             noResources("javaFX")
201             noResources("javaFX-CE")
202           }
203           resources(["javaFX", "javaFX-CE"])
204           jar("javaFX-jps-plugin.jar") {
205             module("javaFX-jps-plugin")
206           }
207           jar("common-javaFX-plugin.jar") {
208             module("common-javaFX-plugin")
209           }
210         }
211       }
212     }
213
214     dir("plugins") {
215       dir("IntelliLang") {
216         dir("lib") {
217           jar("IntelliLang.jar") {
218             module("IntelliLang")
219             module("IntelliLang-java")
220             module("IntelliLang-xml")
221             module("IntelliLang-javaee")
222           }
223           jar("intellilang-jps-plugin.jar") {
224             module("intellilang-jps-plugin")
225           }
226         }
227       }
228     }
229   }
230
231   printUnusedModules(info.usedModules)
232
233   //reorder(targetDirectory)
234 }
235
236 public def layoutCommunityPlugins(String home) {
237   if (isDefined("androidPluginHome")) {
238     layoutAndroid(p("androidPluginHome"))
239   }
240
241   dir("plugins") {
242     def simplePlugins = ["commander", "copyright", "properties", "java-i18n", "hg4idea", "github", "ui-designer-core"] //, "tasks-time-tracking"]
243
244     simplePlugins.each {
245       layoutPlugin it
246     }
247
248     layoutPlugin("ant", "ant", "antIntegration") {
249       jar("ant-jps-plugin.jar") {
250         module("ant-jps-plugin")
251       }
252     }
253     layoutPlugin("uiDesigner", "ui-designer", "uiDesigner") {
254       dir("jps") {
255         jar("ui-designer-jps-plugin.jar") {
256           module("ui-designer-jps-plugin")
257         }
258       }
259     }
260
261     layoutPlugin("maven") {
262       jar("maven-jps-plugin.jar") {
263         module("maven-jps-plugin")
264       }
265       jar("maven-server-api.jar") {
266         module("maven-server-api")
267       }
268       jar("maven2-server-impl.jar") {
269         module("maven2-server-impl")
270       }
271       jar("maven3-server-impl.jar") {
272         module("maven3-server-impl")
273       }
274
275       jar("artifact-resolver-m2.jar") {
276         module("maven-artifact-resolver-m2")
277       }
278
279       jar("artifact-resolver-m3.jar") {
280         module("maven-artifact-resolver-m3")
281         module("maven-artifact-resolver-m2") {
282           include(name: 'org/jetbrains/idea/maven/artifactResolver/common/*')
283         }
284       }
285
286       dir("maven3") {
287         fileset(dir: "$home/plugins/maven/maven3-server-impl/lib") {include(name: "*.jar")}
288         fileset(dir: "$home/plugins/maven/maven3-server-impl/lib/maven3/lib") {include(name: "*.jar")}
289         fileset(dir: "$home/plugins/maven/maven3-server-impl/lib/maven3/boot")
290       }
291
292       dir("maven2") {
293         fileset(dir: "$home/lib/") { include(name: "jaxb*.jar")}
294         fileset(dir: "$home/plugins/maven/maven2-server-impl/lib")
295       }
296
297       fileset(dir: "$home/plugins/maven/lib") {exclude(name: "plexus-utils-*") }
298       fileset(dir: "$home/plugins/maven/maven-server-api/lib")
299     }
300
301     layoutPlugin("gradle") {
302       jar("gradle.jar") {
303         module("gradle")
304       }
305       fileset(dir: "$home/plugins/gradle/lib") { include(name: "*.jar") }
306     }
307
308     layoutPlugin("git4idea") {
309       jar("git4idea-rt.jar") {
310         module("git4idea-rt")
311       }
312       fileset(dir: "$home/plugins/git4idea/lib") {
313         include(name: "trilead-ssh2.jar")
314       }
315       fileset(dir: "$home/plugins/git4idea/lib/ini4j") {
316         include(name: "ini4j*.jar")
317         exclude(name: "ini4j*sources.jar")
318       }
319       fileset(dir: "$home/plugins/git4idea/lib/jgit") {
320         include(name: "org.eclipse.jgit*.jar")
321         exclude(name: "*.zip")
322       }
323     }
324
325     layoutPlugin("svn4idea") {
326       fileset(dir: "$home/plugins/svn4idea/lib", excludes: "**/svnkitsrc.zip")
327     }
328
329     layoutPlugin("junit", "junit", "idea-junit") {
330       jar("junit-rt.jar") {
331         module("junit_rt")
332       }
333     }
334
335     pluginDir("ByteCodeViewer") {
336       dir("lib") {
337         jar("byteCodeViewer.jar") {
338           noResources("ByteCodeViewer")
339         }
340       }
341     }
342
343     pluginDir("cvsIntegration") {
344       dir("lib") {
345         jar("cvs_util.jar") {noResources("cvs-core")}
346         jar("cvsIntegration.jar") {noResources("cvs-plugin")}
347         jar("javacvs-src.jar") {noResources("javacvs-src")}
348         jar("smartcvs-src.jar") {noResources("smartcvs-src")}
349
350         resources(["cvs-core", "cvs-plugin", "javacvs-src", "smartcvs-src"])
351
352         fileset(dir: "${home}/plugins/cvs/lib")
353       }
354     }
355
356     pluginDir("testng") {
357       dir("lib") {
358         jar("testng-plugin.jar") {
359           noResources("testng")
360           noResources("testng_rt")
361         }
362
363         resources("testng")
364
365         fileset(dir: "$home/plugins/testng/lib") {
366           include(name: "testng.jar")
367         }
368       }
369     }
370
371     layoutPlugin("xpath") {
372       dir("rt") {
373         jar("xslt-rt.jar") {module("xslt-rt")}
374       }
375     }
376
377     layoutPlugin("xslt-debugger") {
378       jar("xslt-debugger-engine.jar") {
379         module("xslt-debugger-engine") {
380           excludes: "lib"
381         }
382       }
383       fileset(dir: "$home/plugins/xslt-debugger/engine/lib") {
384         include(name: "**/rmi-stubs.jar")
385       }
386       dir("rt") {
387         jar("xslt-debugger-engine-impl.jar") {
388           module("xslt-debugger-engine-impl") {
389             exclude(name: "lib")
390             exclude(name: "**/*.jar")
391             exclude(name: "**/*.html")
392           }
393         }
394         fileset(dir: "$home/plugins/xslt-debugger/engine/impl/lib") {
395           include(name: "**/*.jar")
396           exclude(name: "**/rmi-stubs.jar")
397           include(name: "**/*.html")
398         }
399       }
400     }
401
402     pluginDir("Groovy") {
403       dir("lib") {
404         jar("Groovy.jar") {
405           module("jetgroovy") {
406             exclude(name: "standardDsls/**")
407           }
408         }
409         //layout of groovy jars must be consistent with GroovyBuilder.getGroovyRtRoot method
410         jar("groovy-jps-plugin.jar") {
411           module("groovy-jps-plugin")
412           module("groovy-rt-constants")
413         }
414         jar("groovy_rt.jar") {
415           module("groovy_rt")
416           module("groovy-rt-constants")
417         }
418         dir("standardDsls") {
419           fileset(dir: "$home/plugins/groovy/resources/standardDsls")
420         }
421         dir("agent") {
422           fileset(dir: "${home}/plugins/groovy/hotswap") {
423             include(name: "gragent.jar")
424           }
425         }
426
427
428         fileset(dir: "$home/plugins/groovy/resources/conf")
429       }
430     }
431
432     pluginDir("tasks") {
433       dir("lib") {
434         jar("tasks-api.jar") { module("tasks-api") }
435         jar("tasks-core.jar") { module("tasks-core") }
436         jar("tasks-java.jar") { moduleOptional("tasks-java") }
437         fileset(dir: "${home}/plugins/tasks/tasks-core/lib") {
438           include(name: "**/*.jar")
439         }
440       }
441     }
442
443     layoutPlugin("devkit") {
444       dir("jps") {
445         jar("devkit-jps-plugin.jar") {
446           module("devkit-jps-plugin")
447         }
448       }
449       fileset(dir: "${home}/plugins/devkit/lib") {
450         include(name: "**/*.jar")
451       }
452     }
453     layoutPlugin("eclipse") {
454       jar("eclipse-jps-plugin.jar") {
455         module("eclipse-jps-plugin")
456       }
457       jar("common-eclipse-util.jar") {
458         module("common-eclipse-util")
459       }
460     }
461
462     layoutPlugin("terminal") {
463       jar("terminal.jar") {
464         module("terminal")
465       }
466       fileset(dir: "$home/plugins/terminal/lib") {
467         include(name: "*.jar")
468         include(name: "*.in")
469         include(name: "**/*.dll")
470         include(name: "**/*.exe")
471         include(name: "**/*.dylib")
472         include(name: "**/*.so")
473       }
474     }
475   }
476 }
477
478
479 def layoutPlugin(String moduleName) {
480   layoutPlugin(moduleName, moduleName, {})
481 }
482
483 def layoutPlugin(String moduleName, Closure custom) {
484   layoutPlugin(moduleName, moduleName, custom)
485 }
486
487 def layoutPlugin(String pluginName, String moduleName) {
488   layoutPlugin(pluginName, moduleName, {})
489 }
490
491 def layoutPlugin(String pluginName, String moduleName, Closure custom) {
492   layoutPlugin(pluginName, moduleName, pluginName, custom)
493 }
494
495 def layoutPlugin(String pluginName, String moduleName, String jarName) {
496   layoutPlugin(pluginName, moduleName, jarName, {})
497 }
498
499 def layoutPlugin(String pluginName, String moduleName, String jarName, Closure custom) {
500   if (isDefined("pluginFilter")) {
501     if (!pluginFilter.contains(moduleName) && !pluginFilter.contains(pluginName)) return
502   }
503
504   dir(pluginName) {
505     dir("lib") {
506       jar("${jarName}.jar") {
507         noResources(moduleName)
508       }
509
510       resources(moduleName)
511       custom()
512     }
513   }
514 }
515
516 def pluginDir(String dirName, Closure initializer) {
517   if (isDefined("pluginFilter")) {
518     if (!pluginFilter.contains(dirName)) return
519   }
520
521   dir(dirName) {
522     initializer()
523   }
524 }
525
526 private def resources(List<String> modules) {
527   jar("resources_en.jar") {
528     modules.each {
529       module(it) {
530         patternset(refid: "resources.included")
531       }
532     }
533   }
534 }
535
536 private def resources(String moduleName) {
537   jar("resources_en.jar") {
538     module(moduleName) {
539       patternset(refid: "resources.included")
540     }
541   }
542 }
543
544 private def noResources(String moduleName) {
545   module(moduleName) {
546     patternset(refid: "resources.excluded")
547   }
548 }
549
550 def moduleOptional(String name) {
551   if (isDefined("pluginFilter")) {
552     if (!pluginFilter.contains(name)) return
553   }
554
555   module(name)
556 }
557
558 def moduleOptional(String name, Closure init) {
559   if (isDefined("pluginFilter")) {
560     if (!pluginFilter.contains(name)) return
561   }
562
563   module(name, init)
564 }
565
566 def reorder(String home, String targetDirectory) {
567   if (findModule("util") != null) {
568     ant.java(classname: "com.intellij.util.io.zip.ReorderJarsMain", fork: "true") {
569       arg(value: "$home/build/order.txt")
570       arg(value: targetDirectory)
571       arg(value: targetDirectory)
572       arg(value: "$home/lib")
573       classpath {
574         pathelement(location: projectBuilder.moduleOutput(findModule("util")))
575         pathelement(location: projectBuilder.moduleOutput(findModule("util-rt")))
576         pathelement(location: "$home/lib/jna.jar")
577         pathelement(location: "$home/lib/trove4j.jar")
578       }
579     }
580   }
581 }
582
583 def layoutAndroid(String androidHome) {
584   dir("plugins") {
585     layoutPlugin("android") {
586       fileset(dir: "${androidHome}/android/lib") {
587         include(name: "**/*.jar")
588         exclude(name: "**/ddmlib_1.jar")
589         exclude(name: "src/*.jar")
590       }
591
592       jar("android-common.jar") {
593         module("android-common")
594       }
595
596       jar("android-rt.jar") {
597         module("android-rt")
598       }
599
600       jar("common.jar") {
601         module("common")
602       }
603       jar("sdklib.jar") {
604         module("sdklib")
605       }
606       jar("layoutlib-api.jar") {
607         module("layoutlib-api")
608       }
609       jar("manifest-merger.jar") {
610         module("manifest-merger")
611       }
612       jar("sdk-tools.jar") {
613         module("assetstudio")
614         module("ddmlib")
615         module("dvlib")
616         module("draw9patch")
617         module("lint-cli")
618         module("lint-api")
619         module("lint-checks")
620         module("ninepatch")
621         module("sdk-common")
622       }
623       jar("androidAnnotations.jar") {
624         fileset(dir: "$androidHome/android/annotations")
625       }
626       dir("jps") {
627         jar("android-gradle-jps.jar") { module("android-gradle-jps") }
628       }
629       dir("device-art-resources") {
630         fileset(dir: "$androidHome/android/device-art-resources")
631       }
632
633       dir("jps") {
634         jar("android-jps-plugin.jar") { module("android-jps-plugin") }
635       }
636     }
637
638     layoutPlugin("android-designer") {
639       jar("android-designer.jar") {
640         module("android-designer")
641       }
642     }
643   }
644 }
645
646 def layoutCommunityJps(String home, String target) {
647   layout(target) {
648     jar("util.jar") {
649       module("annotations")
650       module("util-rt")
651       module("util")
652     }
653     jar("jps-model.jar") {
654       module("jps-model-api")
655       module("jps-model-impl")
656       module("jps-model-serialization")
657     }
658     jar("jps-builders.jar") {
659       module("forms_rt")
660       module("forms-compiler")
661       module("instrumentation-util")
662       module("jps-builders")
663       module("jps-standalone-builder")
664       module("java-runtime")
665     }
666     jar("groovy-jps-plugin.jar") {
667       module("groovy-jps-plugin")
668       module("groovy-rt-constants")
669     }
670     jar("groovy_rt.jar") {
671       module("groovy_rt")
672     }
673     jar("ui-designer-jps-plugin.jar") { module("ui-designer-jps-plugin") }
674
675
676     jar("maven-jps-plugin.jar") { module("maven-jps-plugin") }
677     fileset(dir: "$home/plugins/maven/maven3-server-impl/lib/maven3/lib") {include(name: "plexus-utils-*.jar")}
678
679     jar("eclipse-jps-plugin.jar") {
680       module("common-eclipse-util")
681       module("eclipse-jps-plugin")
682     }
683     jar("devkit-jps-plugin.jar") { module("devkit-jps-plugin") }
684     jar("intellilang-jps-plugin.jar") { module("intellilang-jps-plugin") }
685     fileset(dir: "$home/lib") {
686       include(name: "jdom.jar")
687       include(name: "jna.jar")
688       include(name: "trove4j.jar")
689       include(name: "asm4-all.jar")
690       include(name: "nanoxml-*.jar")
691       include(name: "protobuf-*.jar")
692       include(name: "cli-parser-*.jar")
693       include(name: "optimizedFileManager.jar")
694       include(name: "log4j.jar")
695       include(name: "jgoodies-forms.jar")
696       include(name: "ecj*.jar")
697     }
698     dir("test") {
699       jar("jps-build-test.jar") {
700         moduleTests("jps-builders")
701         moduleTests("jps-model-impl")
702         moduleTests("jps-model-serialization")
703       }
704     }
705     jar("ant-jps-plugin.jar") { module("ant-jps-plugin") }
706   }
707 }
708
709 def layout_core(String home, String target) {
710   layout(target) {
711     jar("intellij-core.jar") {
712       module("util-rt")
713       module("util")
714       module("core-api")
715       module("core-impl")
716       module("boot")
717       module("extensions")
718       module("java-psi-api")
719       module("java-psi-impl")
720     }
721
722     jar("annotations.jar") {
723       module("annotations")
724     }
725
726     fileset(dir: "$home/lib") {
727       include(name: "guava-14.0.1.jar")
728       include(name: "picocontainer.jar")
729       include(name: "trove4j.jar")
730       include(name: "asm.jar")
731       include(name: "asm-commons.jar")
732       include(name: "cli-parser-1.1.jar")
733       include(name: "snappy-java-1.0.5.jar")
734       include(name: "jayatana-1.2.4.jar")
735     }
736   }
737 }