• 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 copyright/profiles_settings.xml
197XML_COPYRIGHT_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 template content of inspectionProfiles/profiles_settings.xml
207XML_INSPECTION_PROFILES_SETTINGS = """<component name="InspectionProjectProfileManager">
208  <settings>
209    <option name="PROJECT_PROFILE" value="Aidegen_Inspections" />
210    <version value="1.0" />
211  </settings>
212</component>
213"""
214
215# The template content of inspectionProfiles/Aidegen_Inspections.xml
216# N.b. this minimal configuration leaves most of the options unspecified,
217# which means that they will be filled with default values set by Jetbrains.
218XML_INSPECTIONS = """<component name="InspectionProjectProfileManager">
219  <profile version="1.0">
220    <option name="myName" value="Aidegen_Inspections" />
221    <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
222      <option name="myAdditionalJavadocTags" value="hide,attr" />
223    </inspection_tool>
224    <inspection_tool class="MissortedModifiers" enabled="true" level="WARNING" enabled_by_default="true">
225      <option name="m_requireAnnotationsFirst" value="true" />
226    </inspection_tool>
227  </profile>
228</component>
229"""
230
231# The configuration of JDK on Linux.
232LINUX_JDK_XML = """    <jdk version="2">
233      <name value="JDK18" />
234      <type value="JavaSDK" />
235      <version value="java version &quot;1.8.0_152&quot;" />
236      <homePath value="{JDKpath}" />
237      <roots>
238        <annotationsPath>
239          <root type="composite">
240            <root url="jar://$APPLICATION_HOME_DIR$/lib/jdkAnnotations.jar!/" type="simple" />
241          </root>
242        </annotationsPath>
243        <classPath>
244          <root type="composite">
245            <root url="jar://{JDKpath}/jre/lib/charsets.jar!/" type="simple" />
246            <root url="jar://{JDKpath}/jre/lib/ext/cldrdata.jar!/" type="simple" />
247            <root url="jar://{JDKpath}/jre/lib/ext/dnsns.jar!/" type="simple" />
248            <root url="jar://{JDKpath}/jre/lib/ext/jaccess.jar!/" type="simple" />
249            <root url="jar://{JDKpath}/jre/lib/ext/localedata.jar!/" type="simple" />
250            <root url="jar://{JDKpath}/jre/lib/ext/nashorn.jar!/" type="simple" />
251            <root url="jar://{JDKpath}/jre/lib/ext/sunec.jar!/" type="simple" />
252            <root url="jar://{JDKpath}/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
253            <root url="jar://{JDKpath}/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
254            <root url="jar://{JDKpath}/jre/lib/ext/zipfs.jar!/" type="simple" />
255            <root url="jar://{JDKpath}/jre/lib/jce.jar!/" type="simple" />
256            <root url="jar://{JDKpath}/jre/lib/jsse.jar!/" type="simple" />
257            <root url="jar://{JDKpath}/jre/lib/management-agent.jar!/" type="simple" />
258            <root url="jar://{JDKpath}/jre/lib/resources.jar!/" type="simple" />
259            <root url="jar://{JDKpath}/jre/lib/rt.jar!/" type="simple" />
260          </root>
261        </classPath>
262        <javadocPath>
263          <root type="composite" />
264        </javadocPath>
265        <sourcePath>
266          <root type="composite">
267            <root url="jar://{JDKpath}/src.zip!/" type="simple" />
268          </root>
269        </sourcePath>
270      </roots>
271      <additional />
272    </jdk>
273"""
274
275# The configuration of JDK on Mac.
276MAC_JDK_XML = """    <jdk version="2">
277      <name value="JDK18" />
278      <type value="JavaSDK" />
279      <version value="java version &quot;1.8.0_152&quot;" />
280      <homePath value="{JDKpath}" />
281      <roots>
282        <annotationsPath>
283          <root type="composite">
284            <root url="jar://$APPLICATION_HOME_DIR$/lib/jdkAnnotations.jar!/" type="simple" />
285          </root>
286        </annotationsPath>
287        <classPath>
288          <root type="composite">
289            <root url="jar://{JDKpath}/jre/lib/charsets.jar!/" type="simple" />
290            <root url="jar://{JDKpath}/jre/lib/ext/cldrdata.jar!/" type="simple" />
291            <root url="jar://{JDKpath}/jre/lib/ext/dnsns.jar!/" type="simple" />
292            <root url="jar://{JDKpath}/jre/lib/ext/jaccess.jar!/" type="simple" />
293            <root url="jar://{JDKpath}/jre/lib/ext/localedata.jar!/" type="simple" />
294            <root url="jar://{JDKpath}/jre/lib/ext/nashorn.jar!/" type="simple" />
295            <root url="jar://{JDKpath}/jre/lib/ext/sunec.jar!/" type="simple" />
296            <root url="jar://{JDKpath}/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
297            <root url="jar://{JDKpath}/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
298            <root url="jar://{JDKpath}/jre/lib/ext/zipfs.jar!/" type="simple" />
299            <root url="jar://{JDKpath}/jre/lib/jce.jar!/" type="simple" />
300            <root url="jar://{JDKpath}/jre/lib/jsse.jar!/" type="simple" />
301            <root url="jar://{JDKpath}/jre/lib/management-agent.jar!/" type="simple" />
302            <root url="jar://{JDKpath}/jre/lib/resources.jar!/" type="simple" />
303            <root url="jar://{JDKpath}/jre/lib/rt.jar!/" type="simple" />
304            <root url="jar://{JDKpath}/jre/lib/management-agent.jar!/" type="simple" />
305            <root url="jar://{JDKpath}/jre/lib/resources.jar!/" type="simple" />
306            <root url="jar://{JDKpath}/jre/lib/rt.jar!/" type="simple" />
307            <root url="jar://{JDKpath}/lib/dt.jar!/" type="simple" />
308            <root url="jar://{JDKpath}/lib/jconsole.jar!/" type="simple" />
309            <root url="jar://{JDKpath}/lib/sa-jdi.jar!/" type="simple" />
310            <root url="jar://{JDKpath}/lib/tools.jar!/" type="simple" />
311          </root>
312        </classPath>
313        <javadocPath>
314          <root type="composite" />
315        </javadocPath>
316        <sourcePath>
317          <root type="composite">
318            <root url="jar://{JDKpath}/src.zip!/" type="simple" />
319          </root>
320        </sourcePath>
321      </roots>
322      <additional />
323    </jdk>
324"""
325
326# The file's header of CLion project file.
327CMAKELISTS_HEADER = """# THIS FILE WAS AUTOMATICALLY GENERATED!
328# ANY MODIFICATION WILL BE OVERWRITTEN!
329
330# To improve project view in Clion    :
331# Tools > CMake > Change Project Root
332
333cmake_minimum_required(VERSION @MINVERSION@)
334project(@PROJNAME@)
335set(ANDROID_ROOT @ANDROIDROOT@)
336"""
337
338# The configuration of Android SDK.
339ANDROID_SDK_XML = """    <jdk version="2">
340      <name value="Android API {CODE_NAME} Platform" />
341      <type value="Android SDK" />
342      <version value="java version &quot;1.8.0_152&quot;" />
343      <homePath value="{ANDROID_SDK_PATH}" />
344      <roots>
345        <annotationsPath>
346          <root type="composite" />
347        </annotationsPath>
348        <classPath>
349          <root type="composite">
350            <root url="file://{ANDROID_SDK_PATH}/platforms/android-{CODE_NAME}/data/res" type="simple" />
351          </root>
352        </classPath>
353        <javadocPath>
354          <root type="composite" />
355        </javadocPath>
356        <sourcePath>
357          <root type="composite" />
358        </sourcePath>
359      </roots>
360      <additional jdk="JDK18" sdk="android-{CODE_NAME}" />
361    </jdk>
362"""
363
364# The configuration of TEST_MAPPING in jsonSchemas.xml.
365TEST_MAPPING_SCHEMAS_XML = """<?xml version="1.0" encoding="UTF-8"?>
366<project version="4">
367  <component name="JsonSchemaMappingsProjectConfiguration">
368    <state>
369      <map>
370        <entry key="TEST_MAPPING.config">
371          <value>
372            <SchemaInfo>
373              <option name="name" value="TEST_MAPPING.config" />
374              <option name="relativePathToSchema" value="{SCHEMA_PATH}" />
375              <option name="schemaVersion" value="JSON schema version 7" />
376              <option name="patterns">
377                <list>
378                  <Item>
379                    <option name="path" value="TEST_MAPPING" />
380                  </Item>
381                </list>
382              </option>
383            </SchemaInfo>
384          </value>
385        </entry>
386      </map>
387    </state>
388  </component>
389</project>
390"""
391
392# The xml templates for Eclipse.
393# .classpath template
394ECLIPSE_CLASSPATH_XML = """<?xml version="1.0" encoding="UTF-8"?>
395<classpath>
396{SRC}
397{LIB}
398    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
399</classpath>
400"""
401
402# .project template
403ECLIPSE_PROJECT_XML = """<?xml version="1.0" encoding="UTF-8"?>
404<projectDescription>
405        <name>{PROJECTNAME}</name>
406        <comment></comment>
407        <projects>
408        </projects>
409        <buildSpec>
410                <buildCommand>
411                        <name>org.eclipse.jdt.core.javabuilder</name>
412                        <arguments>
413                        </arguments>
414                </buildCommand>
415        </buildSpec>
416        <natures>
417                <nature>org.eclipse.jdt.core.javanature</nature>
418        </natures>
419        <linkedResources>
420{LINKEDRESOURCES}
421        </linkedResources>
422</projectDescription>
423"""
424
425# The template of default AndroidManifest.xml.
426ANDROID_MANIFEST_CONTENT = """<?xml version="1.0" encoding="utf-8"?>
427<manifest xmlns:android="http://schemas.android.com/apk/res/android"
428          android:versionCode="1"
429          android:versionName="1.0" >
430</manifest>
431"""
432
433# The xml template for enabling debugger.
434XML_ENABLE_DEBUGGER = """<?xml version="1.0" encoding="UTF-8"?>
435<module type="JAVA_MODULE" version="4">
436  <component name="FacetManager">
437    <facet type="android" name="Android">
438      <configuration />
439    </facet>
440  </component>
441  <component name="NewModuleRootManager" inherit-compiler-output="true">
442    <exclude-output />
443    <content url="file://$MODULE_DIR$">
444      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
445      <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
446    </content>
447    <orderEntry type="jdk" jdkName="{ANDROID_SDK_VERSION}" jdkType="Android SDK" />
448    <orderEntry type="sourceFolder" forTests="false" />
449  </component>
450</module>
451"""
452
453# The default empty template of the jdk.table.xml.
454JDK_TABLE_XML = """<application>
455  <component name="ProjectJdkTable">
456  </component>
457</application>
458"""
459
460XML_WORKSPACE = """<?xml version="1.0" encoding="UTF-8"?>
461<project version="4">
462    <component name="VcsManagerConfiguration">
463        <ignored-roots>
464{GITS}
465        </ignored-roots>
466    </component>
467</project>
468"""
469
470IGNORED_GITS = """<component name="VcsManagerConfiguration">
471    <ignored-roots>{GITS}</ignored-roots>
472  </component>
473"""