• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3# Copyright 2020 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16"""The iml/xml templates of AIDEgen."""
17
18# Content of iml file.
19FILE_IML = """<?xml version="1.0" encoding="UTF-8"?>
20<module type="JAVA_MODULE" version="4">
21@FACETS@
22    <component name="NewModuleRootManager" inherit-compiler-output="true">
23        <exclude-output />
24@SOURCES@
25@SRCJAR@
26        <orderEntry type="sourceFolder" forTests="false" />
27@MODULE_DEPENDENCIES@
28        <orderEntry type="inheritedJdk" />
29    </component>
30</module>
31"""
32# TODO(b/153704028): Refactor to create iml file.
33IML = """<?xml version="1.0" encoding="UTF-8"?>
34<module type="JAVA_MODULE" version="4">{FACET}
35    <component name="NewModuleRootManager" inherit-compiler-output="true">
36        <exclude-output />{SOURCES}
37        <orderEntry type="sourceFolder" forTests="false" />{SRCJARS}{DEPENDENCIES}{JARS}
38        <orderEntry type="inheritedJdk" />
39    </component>
40</module>
41"""
42FACET = """
43    <facet type="android" name="Android">
44        <configuration />
45    </facet>"""
46CONTENT = """
47        <content url="file://{MODULE_PATH}">{EXCLUDES}{SOURCES}
48        </content>"""
49SOURCE = """
50            <sourceFolder url="file://{SRC}" isTestSource="{IS_TEST}" />"""
51OTHER_SOURCE = """
52        <content url="file://{SRC}">
53            <sourceFolder url="file://{SRC}" isTestSource="{IS_TEST}" />
54        </content>"""
55SRCJAR = """
56        <content url="jar://{SRCJAR}!/">
57            <sourceFolder url="jar://{SRCJAR}!/" isTestSource="False" />
58        </content>"""
59JAR = """
60        <orderEntry type="module-library" exported="">
61          <library>
62            <CLASSES>
63              <root url="jar://{JAR}!/" />
64            </CLASSES>
65            <JAVADOC />
66            <SOURCES />
67          </library>
68        </orderEntry>"""
69DEPENDENCIES = """
70        <orderEntry type="module" module-name="{MODULE}" />"""
71
72# The template content of modules.xml.
73XML_MODULES = """<?xml version="1.0" encoding="UTF-8"?>
74<project version="4">
75    <component name="ProjectModuleManager">
76        <modules>
77@MODULES@
78@ENABLE_DEBUGGER_MODULE@
79        </modules>
80    </component>
81</project>
82"""
83
84# The template content of vcs.xml.
85XML_VCS = """<?xml version="1.0" encoding="UTF-8"?>
86<project version="4">
87    <component name="VcsDirectoryMappings">
88{GIT_MAPPINGS}
89    </component>
90</project>
91"""
92
93# The template content of misc.xml
94XML_MISC = """<?xml version="1.0" encoding="UTF-8"?>
95<project version="4">
96    <component name="ConfigCheckProjectState">
97        <option name="disabledCheckers">
98            <list>
99                <option value="com.google.devtools.intellig.configcheck.JavacHeapChecker"/>
100                <option value="com.google.devtools.intellig.configcheck.VcsMappingsChecker"/>
101            </list>
102        </option>
103    </component>
104    <component name="FrameworkDetectionExcludesConfiguration">
105        <type id="android" />
106    </component>
107    <component name="ContinuousBuildConfigurationComponent">
108        <builds>
109            <build intervalToCheckBuild="1" buildKey="" buildLabel=""
110                   enabled="false" tapBuild="false"/>
111        </builds>
112    </component>
113    <component name="DependencyValidationManager">
114        <option name="SKIP_IMPORT_STATEMENTS" value="false"/>
115    </component>
116    <component name="EntryPointsManager">
117        <entry_points version="2.0"/>
118    </component>
119    <component name="JavadocGenerationManager">
120        <option name="HEAP_SIZE"/>
121        <option name="LOCALE"/>
122        <option name="OPEN_IN_BROWSER" value="true"/>
123        <option name="OPTION_DEPRECATED_LIST" value="true"/>
124        <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false"/>
125        <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true"/>
126        <option name="OPTION_DOCUMENT_TAG_USE" value="false"/>
127        <option name="OPTION_DOCUMENT_TAG_VERSION" value="false"/>
128        <option name="OPTION_HIERARCHY" value="true"/>
129        <option name="OPTION_INDEX" value="true"/>
130        <option name="OPTION_NAVIGATOR" value="true"/>
131        <option name="OPTION_SCOPE" value="protected"/>
132        <option name="OPTION_SEPARATE_INDEX" value="true"/>
133        <option name="OTHER_OPTIONS" value=""/>
134        <option name="OUTPUT_DIRECTORY"/>
135    </component>
136    <component name="Mach LOCAL_PREFIX stripper" stripping="true"/>
137    <component name="ProjectResources">
138        <default-html-doctype>http://www.w3.org/1999/xhtml
139        </default-html-doctype>
140    </component>
141    <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8"
142               assert-keyword="true" project-jdk-name="JDK18"
143               project-jdk-type="JavaSDK"/>
144    <component name="WebServicesPlugin" addRequiredLibraries="true"/>
145</project>
146
147"""
148
149# The template content of compiler.xml
150XML_COMPILER = """<?xml version="1.0" encoding="UTF-8"?>
151<project version="4">
152    <component name="CompilerConfiguration">
153        <option name="DEFAULT_COMPILER" value="Javac"/>
154        <resourceExtensions/>
155        <wildcardResourcePatterns>
156            <entry name="?*.dtd"/>
157            <entry name="?*.ftl"/>
158            <entry name="?*.gif"/>
159            <entry name="?*.html"/>
160            <entry name="?*.jpeg"/>
161            <entry name="?*.jpg"/>
162            <entry name="?*.png"/>
163            <entry name="?*.properties"/>
164            <entry name="?*.tld"/>
165            <entry name="?*.xml"/>
166        </wildcardResourcePatterns>
167        <annotationProcessing enabled="false" useClasspath="true"/>
168    </component>
169    <component name="JavacSettings">
170        <option name="MAXIMUM_HEAP_SIZE" value="1024"/>
171    </component>
172</project>
173"""
174
175# The template content of codeStyleConfig.xml
176XML_CODE_STYLE_CONFIG = """<component name="ProjectCodeStyleConfiguration">
177  <state>
178    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
179  </state>
180</component>
181"""
182
183# The template content of Apache_2.xml
184XML_APACHE_2 = """<component name="CopyrightManager">
185    <copyright>
186        <option name="notice"
187                value="Copyright (C) &amp;#36;today.year The Android Open Source Project&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;     http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License."/>
188        <option name="keyword" value="Copyright"/>
189        <option name="allowReplaceKeyword" value=""/>
190        <option name="myName" value="Apache 2"/>
191        <option name="myLocal" value="true"/>
192    </copyright>
193</component>
194"""
195
196# The template content of profiles_settings.xml
197XML_PROFILES_SETTINGS = """<component name="CopyrightManager">
198    <settings default="">
199        <module2copyright>
200            <element module="Project Files" copyright="Apache 2"/>
201        </module2copyright>
202    </settings>
203</component>
204"""
205
206# The configuration of JDK on Linux.
207LINUX_JDK_XML = """    <jdk version="2">
208      <name value="JDK18" />
209      <type value="JavaSDK" />
210      <version value="java version &quot;1.8.0_152&quot;" />
211      <homePath value="{JDKpath}" />
212      <roots>
213        <annotationsPath>
214          <root type="composite">
215            <root url="jar://$APPLICATION_HOME_DIR$/lib/jdkAnnotations.jar!/" type="simple" />
216          </root>
217        </annotationsPath>
218        <classPath>
219          <root type="composite">
220            <root url="jar://{JDKpath}/jre/lib/charsets.jar!/" type="simple" />
221            <root url="jar://{JDKpath}/jre/lib/ext/cldrdata.jar!/" type="simple" />
222            <root url="jar://{JDKpath}/jre/lib/ext/dnsns.jar!/" type="simple" />
223            <root url="jar://{JDKpath}/jre/lib/ext/jaccess.jar!/" type="simple" />
224            <root url="jar://{JDKpath}/jre/lib/ext/localedata.jar!/" type="simple" />
225            <root url="jar://{JDKpath}/jre/lib/ext/nashorn.jar!/" type="simple" />
226            <root url="jar://{JDKpath}/jre/lib/ext/sunec.jar!/" type="simple" />
227            <root url="jar://{JDKpath}/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
228            <root url="jar://{JDKpath}/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
229            <root url="jar://{JDKpath}/jre/lib/ext/zipfs.jar!/" type="simple" />
230            <root url="jar://{JDKpath}/jre/lib/jce.jar!/" type="simple" />
231            <root url="jar://{JDKpath}/jre/lib/jsse.jar!/" type="simple" />
232            <root url="jar://{JDKpath}/jre/lib/management-agent.jar!/" type="simple" />
233            <root url="jar://{JDKpath}/jre/lib/resources.jar!/" type="simple" />
234            <root url="jar://{JDKpath}/jre/lib/rt.jar!/" type="simple" />
235          </root>
236        </classPath>
237        <javadocPath>
238          <root type="composite" />
239        </javadocPath>
240        <sourcePath>
241          <root type="composite">
242            <root url="jar://{JDKpath}/src.zip!/" type="simple" />
243          </root>
244        </sourcePath>
245      </roots>
246      <additional />
247    </jdk>
248"""
249
250# The configuration of JDK on Mac.
251MAC_JDK_XML = """    <jdk version="2">
252      <name value="JDK18" />
253      <type value="JavaSDK" />
254      <version value="java version &quot;1.8.0_152&quot;" />
255      <homePath value="{JDKpath}" />
256      <roots>
257        <annotationsPath>
258          <root type="composite">
259            <root url="jar://$APPLICATION_HOME_DIR$/lib/jdkAnnotations.jar!/" type="simple" />
260          </root>
261        </annotationsPath>
262        <classPath>
263          <root type="composite">
264            <root url="jar://{JDKpath}/jre/lib/charsets.jar!/" type="simple" />
265            <root url="jar://{JDKpath}/jre/lib/ext/cldrdata.jar!/" type="simple" />
266            <root url="jar://{JDKpath}/jre/lib/ext/dnsns.jar!/" type="simple" />
267            <root url="jar://{JDKpath}/jre/lib/ext/jaccess.jar!/" type="simple" />
268            <root url="jar://{JDKpath}/jre/lib/ext/localedata.jar!/" type="simple" />
269            <root url="jar://{JDKpath}/jre/lib/ext/nashorn.jar!/" type="simple" />
270            <root url="jar://{JDKpath}/jre/lib/ext/sunec.jar!/" type="simple" />
271            <root url="jar://{JDKpath}/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
272            <root url="jar://{JDKpath}/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
273            <root url="jar://{JDKpath}/jre/lib/ext/zipfs.jar!/" type="simple" />
274            <root url="jar://{JDKpath}/jre/lib/jce.jar!/" type="simple" />
275            <root url="jar://{JDKpath}/jre/lib/jsse.jar!/" type="simple" />
276            <root url="jar://{JDKpath}/jre/lib/management-agent.jar!/" type="simple" />
277            <root url="jar://{JDKpath}/jre/lib/resources.jar!/" type="simple" />
278            <root url="jar://{JDKpath}/jre/lib/rt.jar!/" type="simple" />
279            <root url="jar://{JDKpath}/jre/lib/management-agent.jar!/" type="simple" />
280            <root url="jar://{JDKpath}/jre/lib/resources.jar!/" type="simple" />
281            <root url="jar://{JDKpath}/jre/lib/rt.jar!/" type="simple" />
282            <root url="jar://{JDKpath}/lib/dt.jar!/" type="simple" />
283            <root url="jar://{JDKpath}/lib/jconsole.jar!/" type="simple" />
284            <root url="jar://{JDKpath}/lib/sa-jdi.jar!/" type="simple" />
285            <root url="jar://{JDKpath}/lib/tools.jar!/" type="simple" />
286          </root>
287        </classPath>
288        <javadocPath>
289          <root type="composite" />
290        </javadocPath>
291        <sourcePath>
292          <root type="composite">
293            <root url="jar://{JDKpath}/src.zip!/" type="simple" />
294          </root>
295        </sourcePath>
296      </roots>
297      <additional />
298    </jdk>
299"""
300
301# The file's header of CLion project file.
302CMAKELISTS_HEADER = """# THIS FILE WAS AUTOMATICALLY GENERATED!
303# ANY MODIFICATION WILL BE OVERWRITTEN!
304
305# To improve project view in Clion    :
306# Tools > CMake > Change Project Root
307
308cmake_minimum_required(VERSION @MINVERSION@)
309project(@PROJNAME@)
310set(ANDROID_ROOT @ANDROIDROOT@)
311"""
312
313# The configuration of Android SDK.
314ANDROID_SDK_XML = """    <jdk version="2">
315      <name value="Android API {CODE_NAME} Platform" />
316      <type value="Android SDK" />
317      <version value="java version &quot;1.8.0_152&quot;" />
318      <homePath value="{ANDROID_SDK_PATH}" />
319      <roots>
320        <annotationsPath>
321          <root type="composite" />
322        </annotationsPath>
323        <classPath>
324          <root type="composite">
325            <root url="file://{ANDROID_SDK_PATH}/platforms/android-{CODE_NAME}/data/res" type="simple" />
326          </root>
327        </classPath>
328        <javadocPath>
329          <root type="composite" />
330        </javadocPath>
331        <sourcePath>
332          <root type="composite" />
333        </sourcePath>
334      </roots>
335      <additional jdk="JDK18" sdk="android-{CODE_NAME}" />
336    </jdk>
337"""
338
339# The configuration of TEST_MAPPING in jsonSchemas.xml.
340TEST_MAPPING_SCHEMAS_XML = """<?xml version="1.0" encoding="UTF-8"?>
341<project version="4">
342  <component name="JsonSchemaMappingsProjectConfiguration">
343    <state>
344      <map>
345        <entry key="TEST_MAPPING.config">
346          <value>
347            <SchemaInfo>
348              <option name="name" value="TEST_MAPPING.config" />
349              <option name="relativePathToSchema" value="{SCHEMA_PATH}" />
350              <option name="schemaVersion" value="JSON schema version 7" />
351              <option name="patterns">
352                <list>
353                  <Item>
354                    <option name="path" value="TEST_MAPPING" />
355                  </Item>
356                </list>
357              </option>
358            </SchemaInfo>
359          </value>
360        </entry>
361      </map>
362    </state>
363  </component>
364</project>
365"""
366
367# The xml templates for Eclipse.
368# .classpath template
369ECLIPSE_CLASSPATH_XML = """<?xml version="1.0" encoding="UTF-8"?>
370<classpath>
371{SRC}
372{LIB}
373    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
374</classpath>
375"""
376
377# .project template
378ECLIPSE_PROJECT_XML = """<?xml version="1.0" encoding="UTF-8"?>
379<projectDescription>
380        <name>{PROJECTNAME}</name>
381        <comment></comment>
382        <projects>
383        </projects>
384        <buildSpec>
385                <buildCommand>
386                        <name>org.eclipse.jdt.core.javabuilder</name>
387                        <arguments>
388                        </arguments>
389                </buildCommand>
390        </buildSpec>
391        <natures>
392                <nature>org.eclipse.jdt.core.javanature</nature>
393        </natures>
394        <linkedResources>
395{LINKEDRESOURCES}
396        </linkedResources>
397</projectDescription>
398"""
399
400# The template of default AndroidManifest.xml.
401ANDROID_MANIFEST_CONTENT = """<?xml version="1.0" encoding="utf-8"?>
402<manifest xmlns:android="http://schemas.android.com/apk/res/android"
403          android:versionCode="1"
404          android:versionName="1.0" >
405</manifest>
406"""
407
408# The xml template for enabling debugger.
409XML_ENABLE_DEBUGGER = """<?xml version="1.0" encoding="UTF-8"?>
410<module type="JAVA_MODULE" version="4">
411  <component name="FacetManager">
412    <facet type="android" name="Android">
413      <configuration />
414    </facet>
415  </component>
416  <component name="NewModuleRootManager" inherit-compiler-output="true">
417    <exclude-output />
418    <content url="file://$MODULE_DIR$">
419      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
420      <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
421    </content>
422    <orderEntry type="jdk" jdkName="{ANDROID_SDK_VERSION}" jdkType="Android SDK" />
423    <orderEntry type="sourceFolder" forTests="false" />
424  </component>
425</module>
426"""
427
428# The default empty template of the jdk.table.xml.
429JDK_TABLE_XML = """<application>
430  <component name="ProjectJdkTable">
431  </component>
432</application>
433"""
434
435XML_WORKSPACE = """<?xml version="1.0" encoding="UTF-8"?>
436<project version="4">
437    <component name="VcsManagerConfiguration">
438        <ignored-roots>
439{GITS}
440        </ignored-roots>
441    </component>
442</project>
443"""
444
445IGNORED_GITS = """<component name="VcsManagerConfiguration">
446    <ignored-roots>{GITS}</ignored-roots>
447  </component>
448"""