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