From fe907be8fe56a6f0ea93343110278133fd01cb51 Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Fri, 19 Aug 2022 21:57:57 +0530 Subject: [PATCH] Added basic implementation of ResourceTableRegistry --- build-tools/aaptcompiler/build.gradle | 13 +- .../android/aaptcompiler/ResourceCompiler.kt | 246 ++--- .../com/android/aaptcompiler/ResourceTable.kt | 7 +- .../android/aaptcompiler/TableExtractor.kt | 859 +++++++++++------- .../androidide/aapt/logging/IDELogger.kt | 58 ++ .../androidide/aaptcompiler/CompilerTest.kt | 3 +- .../internal/impl/msg/DOMMessages.properties | 0 .../impl/msg/DOMMessages_de.properties | 0 .../impl/msg/DOMMessages_es.properties | 0 .../impl/msg/DOMMessages_fr.properties | 0 .../impl/msg/DOMMessages_it.properties | 0 .../impl/msg/DOMMessages_ja.properties | 0 .../impl/msg/DOMMessages_ko.properties | 0 .../impl/msg/DOMMessages_pt_BR.properties | 0 .../impl/msg/DOMMessages_sv.properties | 0 .../impl/msg/DOMMessages_zh_CN.properties | 0 .../impl/msg/DOMMessages_zh_TW.properties | 0 .../impl/msg/DatatypeMessages.properties | 0 .../impl/msg/DatatypeMessages_de.properties | 0 .../impl/msg/DatatypeMessages_es.properties | 0 .../impl/msg/DatatypeMessages_fr.properties | 0 .../impl/msg/DatatypeMessages_it.properties | 0 .../impl/msg/DatatypeMessages_ja.properties | 0 .../impl/msg/DatatypeMessages_ko.properties | 0 .../msg/DatatypeMessages_pt_BR.properties | 0 .../impl/msg/DatatypeMessages_sv.properties | 0 .../msg/DatatypeMessages_zh_CN.properties | 0 .../msg/DatatypeMessages_zh_TW.properties | 0 .../msg/JAXPValidationMessages.properties | 0 .../msg/JAXPValidationMessages_de.properties | 0 .../msg/JAXPValidationMessages_es.properties | 0 .../msg/JAXPValidationMessages_fr.properties | 0 .../msg/JAXPValidationMessages_it.properties | 0 .../msg/JAXPValidationMessages_ja.properties | 0 .../msg/JAXPValidationMessages_ko.properties | 0 .../JAXPValidationMessages_pt_BR.properties | 0 .../msg/JAXPValidationMessages_sv.properties | 0 .../JAXPValidationMessages_zh_CN.properties | 0 .../JAXPValidationMessages_zh_TW.properties | 0 .../internal/impl/msg/SAXMessages.properties | 0 .../impl/msg/SAXMessages_de.properties | 0 .../impl/msg/SAXMessages_es.properties | 0 .../impl/msg/SAXMessages_fr.properties | 0 .../impl/msg/SAXMessages_it.properties | 0 .../impl/msg/SAXMessages_ja.properties | 0 .../impl/msg/SAXMessages_ko.properties | 0 .../impl/msg/SAXMessages_pt_BR.properties | 0 .../impl/msg/SAXMessages_sv.properties | 0 .../impl/msg/SAXMessages_zh_CN.properties | 0 .../impl/msg/SAXMessages_zh_TW.properties | 0 .../impl/msg/XIncludeMessages.properties | 0 .../impl/msg/XIncludeMessages_de.properties | 0 .../impl/msg/XIncludeMessages_es.properties | 0 .../impl/msg/XIncludeMessages_fr.properties | 0 .../impl/msg/XIncludeMessages_it.properties | 0 .../impl/msg/XIncludeMessages_ja.properties | 0 .../impl/msg/XIncludeMessages_ko.properties | 0 .../msg/XIncludeMessages_pt_BR.properties | 0 .../impl/msg/XIncludeMessages_sv.properties | 0 .../msg/XIncludeMessages_zh_CN.properties | 0 .../msg/XIncludeMessages_zh_TW.properties | 0 .../internal/impl/msg/XMLMessages.properties | 0 .../impl/msg/XMLMessages_de.properties | 0 .../impl/msg/XMLMessages_es.properties | 0 .../impl/msg/XMLMessages_fr.properties | 0 .../impl/msg/XMLMessages_it.properties | 0 .../impl/msg/XMLMessages_ja.properties | 0 .../impl/msg/XMLMessages_ko.properties | 0 .../impl/msg/XMLMessages_pt_BR.properties | 0 .../impl/msg/XMLMessages_sv.properties | 0 .../impl/msg/XMLMessages_zh_CN.properties | 0 .../impl/msg/XMLMessages_zh_TW.properties | 0 .../impl/msg/XMLSchemaMessages.properties | 0 .../impl/msg/XMLSchemaMessages_de.properties | 0 .../impl/msg/XMLSchemaMessages_es.properties | 0 .../impl/msg/XMLSchemaMessages_fr.properties | 0 .../impl/msg/XMLSchemaMessages_it.properties | 0 .../impl/msg/XMLSchemaMessages_ja.properties | 0 .../impl/msg/XMLSchemaMessages_ko.properties | 0 .../msg/XMLSchemaMessages_pt_BR.properties | 0 .../impl/msg/XMLSchemaMessages_sv.properties | 0 .../msg/XMLSchemaMessages_zh_CN.properties | 0 .../msg/XMLSchemaMessages_zh_TW.properties | 0 .../impl/msg/XMLSerializerMessages.properties | 0 .../msg/XMLSerializerMessages_de.properties | 0 .../msg/XMLSerializerMessages_es.properties | 0 .../msg/XMLSerializerMessages_fr.properties | 0 .../msg/XMLSerializerMessages_it.properties | 0 .../msg/XMLSerializerMessages_ja.properties | 0 .../msg/XMLSerializerMessages_ko.properties | 0 .../XMLSerializerMessages_pt_BR.properties | 0 .../msg/XMLSerializerMessages_sv.properties | 0 .../XMLSerializerMessages_zh_CN.properties | 0 .../XMLSerializerMessages_zh_TW.properties | 0 .../impl/msg/XPointerMessages.properties | 0 .../impl/msg/XPointerMessages_de.properties | 0 .../impl/msg/XPointerMessages_es.properties | 0 .../impl/msg/XPointerMessages_fr.properties | 0 .../impl/msg/XPointerMessages_it.properties | 0 .../impl/msg/XPointerMessages_ja.properties | 0 .../impl/msg/XPointerMessages_ko.properties | 0 .../msg/XPointerMessages_pt_BR.properties | 0 .../impl/msg/XPointerMessages_sv.properties | 0 .../msg/XPointerMessages_zh_CN.properties | 0 .../msg/XPointerMessages_zh_TW.properties | 0 .../internal/serializer/Encodings.properties | 0 .../serializer/HTMLEntities.properties | 0 .../serializer/XMLEntities.properties | 0 .../serializer/output_html.properties | 0 .../serializer/output_text.properties | 0 .../serializer/output_unknown.properties | 0 .../internal/serializer/output_xml.properties | 0 .../utils/SerializerMessagers.properties | 0 build-tools/layoutlib-api/build.gradle | 5 +- build-tools/xml-utils/.gitignore | 1 + build-tools/xml-utils/build.gradle | 65 ++ .../xml/res/ResourceTableRegistry.kt | 54 ++ .../internal/DefaultResourceTableRegistry.kt | 122 +++ .../xml/res/ResourceTableRegistryTest.kt | 143 +++ dependencies.gradle | 10 +- settings.gradle | 1 + tests/test-home/.androidide/init/model.jar | Bin 58116 -> 58116 bytes 122 files changed, 1109 insertions(+), 478 deletions(-) create mode 100644 build-tools/aaptcompiler/src/main/java/com/itsaky/androidide/aapt/logging/IDELogger.kt rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_de.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_es.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_fr.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_it.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ja.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ko.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_pt_BR.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_sv.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_CN.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_TW.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/Encodings.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/HTMLEntities.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/XMLEntities.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/output_html.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/output_text.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/output_unknown.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/output_xml.properties (100%) rename build-tools/jaxp/src/main/resources/{org/openjdk/com => jaxp}/sun/org/apache/xml/internal/serializer/utils/SerializerMessagers.properties (100%) create mode 100644 build-tools/xml-utils/.gitignore create mode 100644 build-tools/xml-utils/build.gradle create mode 100644 build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/ResourceTableRegistry.kt create mode 100644 build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/internal/DefaultResourceTableRegistry.kt create mode 100644 build-tools/xml-utils/src/test/java/com/itsaky/androidide/xml/res/ResourceTableRegistryTest.kt diff --git a/build-tools/aaptcompiler/build.gradle b/build-tools/aaptcompiler/build.gradle index a9f62de97..866ea6e84 100644 --- a/build-tools/aaptcompiler/build.gradle +++ b/build-tools/aaptcompiler/build.gradle @@ -55,14 +55,17 @@ android { dependencies { implementation common.kotlin - implementation project (':build-tools:layoutlib-api') + implementation project (':logger') implementation project (':build-tools:jaxp') - api 'com.android.tools:common:30.2.2' - implementation 'com.android.tools:annotations:30.2.2' - implementation 'com.android.tools.build:aapt2-proto:7.2.2-7984345' - implementation 'com.google.protobuf:protobuf-java:3.10.0' + api aapt.common + api project (':build-tools:layoutlib-api') + + implementation aapt.annotations + implementation aapt.proto + implementation google.protobuf testImplementation tests.junit + testImplementation tests.robolectric testImplementation tests.google_truth } \ No newline at end of file diff --git a/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceCompiler.kt b/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceCompiler.kt index 0c39f749a..6b37b72b1 100755 --- a/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceCompiler.kt +++ b/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceCompiler.kt @@ -18,9 +18,9 @@ package com.android.aaptcompiler import com.android.aaptcompiler.proto.serializeTableToPb +import com.android.utils.FileUtils import com.itsaky.androidide.layoutlib.resources.ResourceType import com.itsaky.androidide.layoutlib.resources.ResourceVisibility -import com.android.utils.FileUtils import java.io.File private const val VALUES_DIRECTORY_PREFIX = "values" @@ -33,29 +33,30 @@ private const val PNG_EXTENSION = "png" * The different options available while compiling resources. * * @param generateSymbolsPathData Path where the R.txt file should be written to. If null, symbols - * will not be generated. + * will not be generated. * @param visibility The visibility of resources in the given file to process. If specified, then - * compilation of table files will fail if either the "public" or "public group" tags are - * encountered. + * compilation of table files will fail if either the "public" or "public group" tags are + * encountered. * @param requirePngCrunching whether PNG file crunching is enabled * @param pseudolocalize Whether or not the pseudolocales en-XA and ar-XB are generated for default - * string resources. - * @param partialRFile file to output symbols defined in the resource file (currently only - * supported for non-raw XML files (e.g. values or layouts) to match AAPT2's behaviour) + * string resources. + * @param partialRFile file to output symbols defined in the resource file (currently only supported + * for non-raw XML files (e.g. values or layouts) to match AAPT2's behaviour) * @param legacyMode Whether or not to error or warn on positional args not being specified in a - * translatable string with parameters. + * translatable string with parameters. * @param verbose Whether or not to show verbose logs. * @param sourcePath Specified source path to be written in the compiled resource. */ data class ResourceCompilerOptions( - val generateSymbolsPathData: ResourcePathData?= null, + val generateSymbolsPathData: ResourcePathData? = null, val visibility: ResourceVisibility? = null, val requirePngCrunching: Boolean = false, val pseudolocalize: Boolean = false, val partialRFile: File? = null, val legacyMode: Boolean = false, val verbose: Boolean = false, - val sourcePath: String? = null) + val sourcePath: String? = null +) /** * Shows whether the ResourceCompiler can compile the given Resource File. @@ -68,8 +69,9 @@ fun canCompileResourceInJvm(file: File, requirePngCrunching: Boolean): Boolean { if (file.isHidden) return true val pathData = extractPathData(file) - if (pathData.resourceDirectory == VALUES_DIRECTORY_PREFIX - && pathData.extension == XML_EXTENSION) { + if ( + pathData.resourceDirectory == VALUES_DIRECTORY_PREFIX && pathData.extension == XML_EXTENSION + ) { // file is a values table. return true } else { @@ -91,7 +93,7 @@ fun canCompileResourceInJvm(file: File, requirePngCrunching: Boolean): Boolean { * * @param file file to processed. How it is processed is determined by the resource compiler. * @param options the [ResourceCompilerOptions] that should be considered while compiling the - * resource. + * resource. * * Values files are compiled by extracting the all the resources and their values into a Resource * Table to be used in Linking. @@ -106,7 +108,11 @@ fun canCompileResourceInJvm(file: File, requirePngCrunching: Boolean): Boolean { * See [canCompileResourceInJvm] to see what is supported. */ fun compileResource( - file: File, outputDirectory: File, options: ResourceCompilerOptions, logger: BlameLogger) { + file: File, + outputDirectory: File, + options: ResourceCompilerOptions, + logger: BlameLogger +) { // Skip hidden files. if (file.isHidden) { @@ -123,24 +129,28 @@ fun compileResource( compileFunction(pathData, outputDirectory, options, logger) } catch (e: Exception) { logger?.info("Failed to compile file", blameSource(pathData.source)) - val message = - "Resource compilation failed (${e.message}. Cause: ${e.cause}). " + - "Check logs for more details." - throw ResourceCompilationException(message, e) + val message = + "Resource compilation failed (${e.message}. Cause: ${e.cause}). " + + "Check logs for more details." + throw ResourceCompilationException(message, e) } } -private fun getCompileMethod(pathData: ResourcePathData, logger: BlameLogger): - (ResourcePathData, File, ResourceCompilerOptions, BlameLogger) -> Unit { - if (pathData.resourceDirectory == VALUES_DIRECTORY_PREFIX && - pathData.extension == XML_EXTENSION) { +private fun getCompileMethod( + pathData: ResourcePathData, + logger: BlameLogger +): (ResourcePathData, File, ResourceCompilerOptions, BlameLogger) -> Unit { + if ( + pathData.resourceDirectory == VALUES_DIRECTORY_PREFIX && pathData.extension == XML_EXTENSION + ) { pathData.extension = RESOURCE_TABLE_EXTENSION return ::compileTable } else { val type = ResourceType.fromFolderName(pathData.resourceDirectory) if (type == null) { - val errorMsg = "Invalid resource type '${pathData.resourceDirectory}'" + - " for file ${pathData.file.absolutePath}" + val errorMsg = + "Invalid resource type '${pathData.resourceDirectory}'" + + " for file ${pathData.file.absolutePath}" logger?.warning(errorMsg) error(errorMsg) } @@ -158,41 +168,45 @@ private fun getCompileMethod(pathData: ResourcePathData, logger: BlameLogger): /** * Compiles a xml values file into a flattened [ResourceTable] proto. * - * After all resources are extracted from the given xml, if pseudolocalization is set, - * pseudolocale strings are created for each default string resource in the xml. The result is - * flattened to a file in the output directory. + * After all resources are extracted from the given xml, if pseudolocalization is set, pseudolocale + * strings are created for each default string resource in the xml. The result is flattened to a + * file in the output directory. * * @param pathData the file to be processed. * @param outputDirectory the directory to which the compiled file is to be placed. * @throws IllegalStateException A failure occurred in processing this resource. */ private fun compileTable( - pathData: ResourcePathData, - outputDirectory: File, - options: ResourceCompilerOptions, - logger: BlameLogger) { + pathData: ResourcePathData, + outputDirectory: File, + options: ResourceCompilerOptions, + logger: BlameLogger +) { val outputFile = File(outputDirectory, pathData.getIntermediateContainerFilename()) logger?.info("Compiling XML table ${pathData.file.absolutePath} to $outputFile") val table = ResourceTable(logger = logger) - val extractorOptions = TableExtractorOptions( - translatable = !pathData.name.contains("donottranslate"), - errorOnPositionalArgs = !options.legacyMode, - visibility = options.visibility) + val extractorOptions = + TableExtractorOptions( + translatable = !pathData.name.contains("donottranslate"), + errorOnPositionalArgs = !options.legacyMode, + visibility = options.visibility + ) val tableExtractor = TableExtractor(table, pathData.source, pathData.config, extractorOptions, logger) pathData.file.inputStream().use { - try { - tableExtractor.extract(it) - } catch (e: Exception) { - // For merged values there's no need to re-write as we don't know which line failed. The - // actual error will be raised by the table extractor. - throw ResourceCompilationException( - "Failed to compile values resource file ${pathData.file}", e - ) - } + try { + tableExtractor.extract(it) + } catch (e: Exception) { + // For merged values there's no need to re-write as we don't know which line failed. The + // actual error will be raised by the table extractor. + throw ResourceCompilationException( + "Failed to compile values resource file ${pathData.file}", + e + ) + } // Adds the fake locales: en-XA and ar-XB for each default-defined string resource. This is used // for debugging apps with long text (en-XA) or rtl (ar-XB) language support. @@ -218,20 +232,23 @@ private fun compileTable( pkg.groups.forEach { group -> // Macros do not define resources and therefore don't belong in the R.txt. if (group.type != AaptResourceType.MACRO) { - val javaType = if (group.type == AaptResourceType.STYLEABLE) "int[]" else "int" - group.entries.forEach { entry -> - val visibility = getVisibility(entry.value.values, group.type) - builder.appendln("${visibility.getName()} $javaType ${group.type.tagName} ${entry.key}") - if (group.type == AaptResourceType.STYLEABLE) { - // We also need to write down styleable children (entries) - group.getStyleable(entry).entries.forEach { - val childPackage = - if (!it.name.pck.isNullOrEmpty()) "_${it.name.pck}" else "" - // styleables and their children are always public - builder.appendln("public int styleable ${entry.key}${childPackage}_${it.name.entry}") - } - } + val javaType = if (group.type == AaptResourceType.STYLEABLE) "int[]" else "int" + group.entries.forEach { entry -> + val visibility = getVisibility(entry.value.values, group.type) + builder.appendLine( + "${visibility.getName()} $javaType ${group.type.tagName} ${entry.key}" + ) + if (group.type == AaptResourceType.STYLEABLE) { + // We also need to write down styleable children (entries) + group.getStyleable(entry).entries.forEach { + val childPackage = if (!it.name.pck.isNullOrEmpty()) "_${it.name.pck}" else "" + // styleables and their children are always public + builder.appendln( + "public int styleable ${entry.key}${childPackage}_${it.name.entry}" + ) + } } + } } } } @@ -240,21 +257,24 @@ private fun compileTable( } } -private fun getVisibility(values: Collection, type: AaptResourceType): ResourceVisibility { - // all declare styleables need to be marked as public so they're visible in the R classes - if (type == AaptResourceType.STYLEABLE) return ResourceVisibility.PUBLIC - var foundPublic = false - var foundPrivate = false - values.forEach { - // We only care about public and private since only these can clash - if (it.visibility.level == ResourceVisibility.PUBLIC) foundPublic = true - else if (it.visibility.level == ResourceVisibility.PRIVATE) foundPrivate = true - } - if (foundPublic && foundPrivate) - error("Resource cannot be both public and private: ${type.tagName} ${values.first().name}") - if (foundPublic) return ResourceVisibility.PUBLIC - if (foundPrivate) return ResourceVisibility.PRIVATE - return ResourceVisibility.PRIVATE_XML_ONLY // default +private fun getVisibility( + values: Collection, + type: AaptResourceType +): ResourceVisibility { + // all declare styleables need to be marked as public so they're visible in the R classes + if (type == AaptResourceType.STYLEABLE) return ResourceVisibility.PUBLIC + var foundPublic = false + var foundPrivate = false + values.forEach { + // We only care about public and private since only these can clash + if (it.visibility.level == ResourceVisibility.PUBLIC) foundPublic = true + else if (it.visibility.level == ResourceVisibility.PRIVATE) foundPrivate = true + } + if (foundPublic && foundPrivate) + error("Resource cannot be both public and private: ${type.tagName} ${values.first().name}") + if (foundPublic) return ResourceVisibility.PUBLIC + if (foundPrivate) return ResourceVisibility.PRIVATE + return ResourceVisibility.PRIVATE_XML_ONLY // default } /** @@ -264,19 +284,21 @@ private fun getVisibility(values: Collection, type: AaptResourceT * @param outputDirectory the directory to which the compiled file is to be placed. */ private fun compileFile( - pathData: ResourcePathData, - outputDirectory: File, - options: ResourceCompilerOptions, - logger: BlameLogger?) { + pathData: ResourcePathData, + outputDirectory: File, + options: ResourceCompilerOptions, + logger: BlameLogger? +) { val outputFile = File(outputDirectory, pathData.getIntermediateContainerFilename()) logger?.info("Compiling file ${pathData.file.absolutePath} to $outputFile") pathData.file.inputStream().use { - val resourceFile = ResourceFile( - ResourceName("", resourceTypeFromTag(pathData.resourceDirectory)!!, pathData.name), - pathData.config, - pathData.source, - ResourceFile.Type.Unknown - ) + val resourceFile = + ResourceFile( + ResourceName("", resourceTypeFromTag(pathData.resourceDirectory)!!, pathData.name), + pathData.config, + pathData.source, + ResourceFile.Type.Unknown + ) val container = Container(outputFile.outputStream(), 1) container.addFileEntry(it, resourceFile) @@ -306,34 +328,34 @@ private fun compileFile( * @throws IllegalStateException A failure occurred in processing this resource. */ private fun compileXml( - pathData: ResourcePathData, - outputDirectory: File, - options: ResourceCompilerOptions, - logger: BlameLogger?) { + pathData: ResourcePathData, + outputDirectory: File, + options: ResourceCompilerOptions, + logger: BlameLogger? +) { val outputFile = File(outputDirectory, pathData.getIntermediateContainerFilename()) logger?.info("Compiling xml file ${pathData.file.absolutePath} to $outputFile") - val fileToProcess = ResourceFile( - ResourceName("", pathData.type!!, pathData.name), - pathData.config, - pathData.source, - ResourceFile.Type.ProtoXml - ) + val fileToProcess = + ResourceFile( + ResourceName("", pathData.type!!, pathData.name), + pathData.config, + pathData.source, + ResourceFile.Type.ProtoXml + ) pathData.file.inputStream().use { val xmlProcessor = XmlProcessor(source = pathData.source, logger = logger) - try { - xmlProcessor.process(fileToProcess, it) - } catch (e: Exception) { - throw ResourceCompilationException( - "Failed to compile resource file: " + - logger?.getOutputSource(blameSource(pathData.source)), - e - ) - } + try { + xmlProcessor.process(fileToProcess, it) + } catch (e: Exception) { + throw ResourceCompilationException( + "Failed to compile resource file: " + logger?.getOutputSource(blameSource(pathData.source)), + e + ) + } - val container = - Container(outputFile.outputStream(), xmlProcessor.xmlResources.size) + val container = Container(outputFile.outputStream(), xmlProcessor.xmlResources.size) for (resource in xmlProcessor.xmlResources) { container.addXmlEntry(resource) @@ -341,9 +363,9 @@ private fun compileXml( if (options.partialRFile != null) { val builder = StringBuilder() - builder.appendln("default int ${pathData.type.tagName} ${pathData.name}") + builder.appendLine("default int ${pathData.type.tagName} ${pathData.name}") fileToProcess.exportedSymbols.forEach { id -> - builder.appendln("default int id ${id.name.entry}") + builder.appendLine("default int id ${id.name.entry}") } FileUtils.writeToFile(options.partialRFile, builder.toString()) } @@ -359,18 +381,18 @@ private fun compileXml( * * If we are not running in debug mode, the png will undergo additional crunching. * - * Finally, the processed file is written to the output directory. It is possible that no - * processing is done to the png file, and if so it will just be written exactly as if it were - * a raw file. + * Finally, the processed file is written to the output directory. It is possible that no processing + * is done to the png file, and if so it will just be written exactly as if it were a raw file. * * @param pathData the file to process. * @param outputDirectory the directory in which the processed file will be placed. */ private fun compilePng( - pathData: ResourcePathData, - outputDirectory: File, - options: ResourceCompilerOptions, - logger: BlameLogger?) { + pathData: ResourcePathData, + outputDirectory: File, + options: ResourceCompilerOptions, + logger: BlameLogger? +) { logger?.info("Compiling image file ${pathData.file.absolutePath}") if (pathData.extension == PATCH_9_EXTENSION) { error("Patch 9 PNG processing is not supported with the JVM Android resource compiler.") diff --git a/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceTable.kt b/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceTable.kt index 71dd931a5..fbbf7321a 100755 --- a/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceTable.kt +++ b/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/ResourceTable.kt @@ -23,7 +23,7 @@ class ResourceTable(val validateResources: Boolean = false, val logger: BlameLog val stringPool = StringPool() /** The list of packages in this table. */ - internal val packages = mutableListOf() + val packages = mutableListOf() /** * Set of dynamic packages that this table may reference. Their package names get encoded into the @@ -638,8 +638,7 @@ class ResourceTablePackage(var name: String = "", var id: Byte? = null) { } fun findOrCreateGroup(type: AaptResourceType, groupId: Byte? = null): ResourceGroup { - val group = findGroup(type, groupId) - return when(group) { + return when(val group = findGroup(type, groupId)) { null -> { val newGroup = ResourceGroup(type) newGroup.id = groupId @@ -705,7 +704,7 @@ class ResourceEntry(val name : String) { var allowNew: AllowNew? = null var overlayable: OverlayableItem? = null - internal val values = mutableListOf() + val values = mutableListOf() fun findValue(config: ConfigDescription, product: String = ""): ResourceConfigValue? { return values.find { it.config == config && it.product == product } diff --git a/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/TableExtractor.kt b/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/TableExtractor.kt index 089938485..427092e3c 100755 --- a/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/TableExtractor.kt +++ b/build-tools/aaptcompiler/src/main/java/com/android/aaptcompiler/TableExtractor.kt @@ -3,7 +3,6 @@ package com.android.aaptcompiler import com.android.aapt.Resources import com.android.aaptcompiler.android.stringToInt import com.itsaky.androidide.layoutlib.resources.ResourceVisibility -import java.io.InputStream import jaxp.xml.XMLConstants import jaxp.xml.namespace.QName import jaxp.xml.stream.XMLEventReader @@ -13,6 +12,7 @@ import jaxp.xml.stream.events.Attribute import jaxp.xml.stream.events.Comment import jaxp.xml.stream.events.StartElement import jaxp.xml.stream.events.XMLEvent +import java.io.InputStream /** * Namespace uri for the xliff:g tag in XML. @@ -25,14 +25,17 @@ private const val XLIFF_NS_URI = "urn:oasis:names:tc:xliff:document:1.2" /** * Resource parsed from the XML, with all relevant metadata. * - * @property config The config description of the resource. This should be the same as the config - * of the source. + * @property config The config description of the resource. This should be the same as the config of + * the source. * @property source The start location in the xml from which this resource was extracted. * @property comment The comment describing the resource that appeared before it in the xml. This - * will be an empty string if no comment was supplied. + * will be an empty string if no comment was supplied. */ private class ParsedResource( - var config: ConfigDescription, val source: Source, val comment: String) { + var config: ConfigDescription, + val source: Source, + val comment: String +) { constructor() : this(ConfigDescription(), Source(""), "") @@ -52,10 +55,10 @@ private class ParsedResource( */ var overlayableItem: OverlayableItem? = null /** - * The value of the resource, this might be null if this is a use of a resource. (i.e. an - * within a + * The value of the resource, this might be null if this is a use of a resource. (i.e. an + * within a */ - var value : Value? = null + var value: Value? = null /** * The child resources of the given resource. These resources will be added to the table when * {@code this} is added. The connection of the resources to this resource should be reflected in @@ -70,16 +73,17 @@ private class ParsedResource( * @property translatable Whether the default setting for this parser is to allow translation. * * @property errorOnPositionalArgs Whether positional arguments in formatted strings are treated as - * errors or warnings. + * errors or warnings. * * @property visibility the default visibility of resources extracted. If non-null, all new - * resources are set with this visibility, and will error if trying to parse the , - * , or tags. + * resources are set with this visibility, and will error if trying to parse the , + * , or tags. */ data class TableExtractorOptions( val translatable: Boolean = true, val errorOnPositionalArgs: Boolean = true, - val visibility: ResourceVisibility? = null) + val visibility: ResourceVisibility? = null +) /** Returns true if the element is or and can be safely ignored */ fun shouldIgnoreElement(elementName: QName): Boolean { @@ -125,9 +129,9 @@ fun parseFormatAttribute(value: String): Int { *

Primarily, as each resource needs to be parsed, the name, package, and type of resource is * extracted. * - *

Then, if an item, a call to [parseItem] is invoked with a type mask of the valid types - * the xml element can be parsed as. This will result in a more specialized call to [parseXml] - * which will proceed to flatten the xml subtree of the item (which may include span tags and + *

Then, if an item, a call to [parseItem] is invoked with a type mask of the valid types the + * xml element can be parsed as. This will result in a more specialized call to [parseXml] which + * will proceed to flatten the xml subtree of the item (which may include span tags and * untranslatable section tags) and then attempt to process the flattened xml string (in accordance * with the valid types specified by the type mask). Finally, the parsed resource value will be * added to [ResourceTable], if successful. @@ -148,10 +152,11 @@ class TableExtractor( val source: Source, val config: ConfigDescription, val options: TableExtractorOptions, - val logger: BlameLogger) { + val logger: BlameLogger +) { fun extract(inputFile: InputStream) { - var eventReader : XMLEventReader? = null + var eventReader: XMLEventReader? = null try { eventReader = xmlInputFactory.createXMLEventReader(inputFile) @@ -162,7 +167,7 @@ class TableExtractor( } var rootStart: XMLEvent? = null - while(eventReader.hasNext()) { + while (eventReader.hasNext()) { rootStart = eventReader.nextEvent() // ignore comments and text before the root tag if (rootStart.isStartElement) { @@ -174,15 +179,13 @@ class TableExtractor( val rootName = rootStart.asStartElement().name if (rootName.namespaceURI != null && rootName.localPart != "resources") { val userReadableSource = logger.getOriginalSource(blameSource(source)).toString().trim() - error( - "Root xml element of resource table not labeled 'resources' ($userReadableSource)." - ) + error("Root xml element of resource table not labeled 'resources' ($userReadableSource).") } extractResourceValues(eventReader) } catch (xmlException: XMLStreamException) { if (xmlException.message?.contains("Premature end of file.", true) != true) { - // Having no root is not an error, but any other xml format exception is. - throw xmlException + // Having no root is not an error, but any other xml format exception is. + throw xmlException } } finally { eventReader?.close() @@ -190,7 +193,7 @@ class TableExtractor( } private fun logError(source: BlameLogger.Source, message: String) { - logger.error(message, source) + logger.error(message, source) } /** @@ -231,7 +234,7 @@ class TableExtractor( if (!event.isStartElement) { errors += - "Unexpected element type: ${event.eventType}, ${blameSource(source, event.location)}." + "Unexpected element type: ${event.eventType}, ${blameSource(source, event.location)}." } val element = event.asStartElement() @@ -267,25 +270,26 @@ class TableExtractor( } } if (errors.any()) { - error(errors.joinToString(separator = ",")) + error(errors.joinToString(separator = ",")) } } /** * Extracts the [Value] of a resource from the given element. This can be either an [Item] or a - * nested value type. + * nested value type. * * @param element The start of the element to be translated as a [Value]. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource The [ParsedResource] to hold the extracted value upon success. * @return Whether or not the parsing was a success. */ private fun extractResource( - element : StartElement, - eventReader : XMLEventReader, - parsedResource : ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { var resourceTypeName = element.name.localPart @@ -307,7 +311,8 @@ class TableExtractor( if (resourceFormat == 0) { logError( blameSource(parsedResource.source), - "Resource has an invalid format of ${formatAttribute.value}.") + "Resource has an invalid format of ${formatAttribute.value}." + ) walkToEndOfElement(element, eventReader) return false } @@ -321,7 +326,6 @@ class TableExtractor( return false } resourceTypeName = typeAttribute.value - } else if (resourceTypeName == "bag") { canBeItem = false @@ -341,7 +345,9 @@ class TableExtractor( if (resourceTypeName == "id") { if (nameAttribute == null) { logError( - blameSource(parsedResource.source), "<${element.name}> is missing the 'name' attribute.") + blameSource(parsedResource.source), + "<${element.name}> is missing the 'name' attribute." + ) walkToEndOfElement(element, eventReader) return false } @@ -365,7 +371,8 @@ class TableExtractor( // if an inner element exists, the inner element must be a reference to another id logError( blameSource(parsedResource.source), - "<${element.name}> inner element must either be a resource reference or empty.") + "<${element.name}> inner element must either be a resource reference or empty." + ) return false } } @@ -373,39 +380,43 @@ class TableExtractor( } if (canBeItem) { - val (type, typeMask) = when (resourceTypeName) { - "bool" -> Pair(AaptResourceType.BOOL, Resources.Attribute.FormatFlags.BOOLEAN_VALUE) - "color" -> Pair(AaptResourceType.COLOR, Resources.Attribute.FormatFlags.COLOR_VALUE) - "configVarying" -> - Pair(AaptResourceType.CONFIG_VARYING, Resources.Attribute.FormatFlags.ANY_VALUE) - "dimen" -> - Pair( - AaptResourceType.DIMEN, - Resources.Attribute.FormatFlags.FLOAT_VALUE or - Resources.Attribute.FormatFlags.FRACTION_VALUE or - Resources.Attribute.FormatFlags.DIMENSION_VALUE) - "drawable" -> Pair(AaptResourceType.DRAWABLE, Resources.Attribute.FormatFlags.COLOR_VALUE) - "fraction" -> - Pair( - AaptResourceType.FRACTION, - Resources.Attribute.FormatFlags.FLOAT_VALUE or - Resources.Attribute.FormatFlags.FRACTION_VALUE or - Resources.Attribute.FormatFlags.DIMENSION_VALUE) - "integer" -> Pair(AaptResourceType.INTEGER, Resources.Attribute.FormatFlags.INTEGER_VALUE) - "string" -> Pair(AaptResourceType.STRING, Resources.Attribute.FormatFlags.STRING_VALUE) - else -> Pair(null, Resources.Attribute.FormatFlags.ANY_VALUE) - } + val (type, typeMask) = + when (resourceTypeName) { + "bool" -> Pair(AaptResourceType.BOOL, Resources.Attribute.FormatFlags.BOOLEAN_VALUE) + "color" -> Pair(AaptResourceType.COLOR, Resources.Attribute.FormatFlags.COLOR_VALUE) + "configVarying" -> + Pair(AaptResourceType.CONFIG_VARYING, Resources.Attribute.FormatFlags.ANY_VALUE) + "dimen" -> + Pair( + AaptResourceType.DIMEN, + Resources.Attribute.FormatFlags.FLOAT_VALUE or + Resources.Attribute.FormatFlags.FRACTION_VALUE or + Resources.Attribute.FormatFlags.DIMENSION_VALUE + ) + "drawable" -> Pair(AaptResourceType.DRAWABLE, Resources.Attribute.FormatFlags.COLOR_VALUE) + "fraction" -> + Pair( + AaptResourceType.FRACTION, + Resources.Attribute.FormatFlags.FLOAT_VALUE or + Resources.Attribute.FormatFlags.FRACTION_VALUE or + Resources.Attribute.FormatFlags.DIMENSION_VALUE + ) + "integer" -> Pair(AaptResourceType.INTEGER, Resources.Attribute.FormatFlags.INTEGER_VALUE) + "string" -> Pair(AaptResourceType.STRING, Resources.Attribute.FormatFlags.STRING_VALUE) + else -> Pair(null, Resources.Attribute.FormatFlags.ANY_VALUE) + } if (type != null) { // this is an item record its type and format and start parsing. if (nameAttribute == null) { logError( blameSource(parsedResource.source), - "<${element.name}> is missing the 'name' attribute.") + "<${element.name}> is missing the 'name' attribute." + ) walkToEndOfElement(element, eventReader) return false } - parsedResource.name = ResourceName( "", type, nameAttribute.value) + parsedResource.name = ResourceName("", type, nameAttribute.value) // Only use the implied format of the type when there is no explicit format. if (resourceFormat == 0) { @@ -416,24 +427,25 @@ class TableExtractor( } if (canBeBag) { - val parseBagMethod = when(resourceTypeName) { - "add-resource" -> ::parseAddResource - "array" -> ::parseArray - "attr" -> ::parseAttr - "configVarying" -> ::parseConfigVarying - "declare-styleable" -> ::parseDeclareStyleable - "integer-array" -> ::parseIntegerArray - "java-symbol" -> ::parseSymbol - "macro" -> ::parseMacro - "overlayable" -> ::parseOverlayable - "plurals" -> ::parsePlural - "public" -> ::parsePublic - "public-group" -> ::parsePublicGroup - "string-array" -> ::parseStringArray - "style" -> ::parseStyle - "symbol" -> ::parseSymbol - else -> null - } + val parseBagMethod = + when (resourceTypeName) { + "add-resource" -> ::parseAddResource + "array" -> ::parseArray + "attr" -> ::parseAttr + "configVarying" -> ::parseConfigVarying + "declare-styleable" -> ::parseDeclareStyleable + "integer-array" -> ::parseIntegerArray + "java-symbol" -> ::parseSymbol + "macro" -> ::parseMacro + "overlayable" -> ::parseOverlayable + "plurals" -> ::parsePlural + "public" -> ::parsePublic + "public-group" -> ::parsePublicGroup + "string-array" -> ::parseStringArray + "style" -> ::parseStyle + "symbol" -> ::parseSymbol + else -> null + } if (parseBagMethod != null) { // ensure we have a name (unless this is a or ). @@ -442,17 +454,17 @@ class TableExtractor( walkToEndOfElement(element, eventReader) logError( blameSource(parsedResource.source), - "<${element.name}> is missing the 'name' attribute.") + "<${element.name}> is missing the 'name' attribute." + ) return false } - parsedResource.name = parsedResource.name.copy(entry=nameAttribute.value) + parsedResource.name = parsedResource.name.copy(entry = nameAttribute.value) } // Call the associated parse method. The type will be filled in by the parse function return parseBagMethod(element, eventReader, parsedResource) } - } if (canBeItem) { @@ -461,7 +473,8 @@ class TableExtractor( if (nameAttribute == null) { logError( blameSource(parsedResource.source), - "<${element.name}> is missing the 'name' attribute.") + "<${element.name}> is missing the 'name' attribute." + ) walkToEndOfElement(element, eventReader) return false } @@ -473,7 +486,8 @@ class TableExtractor( if (parsedResource.value == null) { logError( blameSource(parsedResource.source), - "Invalid value for type '${parsedType.tagName}'. Expected a reference.") + "Invalid value for type '${parsedType.tagName}'. Expected a reference." + ) return false } @@ -490,23 +504,24 @@ class TableExtractor( * Parses the XML subtree and returns an Item. * * @param element The start of the element to be translated as an item type. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param resourceFormat A type mask that specifies which formats are valid for the xml to be - * interpreted as. + * interpreted as. * @param allowRawString If true, a [RawString] representing the xml is returned if it could not - * be parsed as any valid resource [Item]. If false, {@code null} will be returned instead on - * failure. + * be parsed as any valid resource [Item]. If false, {@code null} will be returned instead on + * failure. * * @return The [Item] that represents the xml subtree. This will be {@code null} if the xml failed - * to be interpreted as a valid resource. + * to be interpreted as a valid resource. */ private fun parseXml( element: StartElement, eventReader: XMLEventReader, resourceFormat: Int, - allowRawString : Boolean) : Item? { + allowRawString: Boolean + ): Item? { val flattenedXml = flattenXmlSubTree(element, eventReader) if (!flattenedXml.success) { @@ -518,8 +533,10 @@ class TableExtractor( return StyledString( table.stringPool.makeRef( flattenedXml.styleString, - StringPool.Context(StringPool.Context.Priority.NORMAL.priority, config)), - flattenedXml.untranslatableSections) + StringPool.Context(StringPool.Context.Priority.NORMAL.priority, config) + ), + flattenedXml.untranslatableSections + ) } // Process the raw value @@ -542,9 +559,9 @@ class TableExtractor( if (resourceFormat and Resources.Attribute.FormatFlags.STRING_VALUE != 0) { // use trimmed escaped string. return BasicString( - table.stringPool.makeRef( - flattenedXml.styleString.str, StringPool.Context(config = config)), - flattenedXml.untranslatableSections) + table.stringPool.makeRef(flattenedXml.styleString.str, StringPool.Context(config = config)), + flattenedXml.untranslatableSections + ) } // if the text is empty, and the value is not allowed to be a string, encode it as a @null. @@ -553,20 +570,21 @@ class TableExtractor( } if (allowRawString) { - val raw = flattenedXml.rawString.let { raw -> - // Remove space, newline character wrapping (typically due to IDE formatting) - // and user added quotations for styleable children due to lack of type. - val isNotWrappingChar: (Char) -> Boolean = { it !in setOf(' ', '\n') } - val firstNonWrappingIndex = raw.indexOfFirst(isNotWrappingChar) - val lastNonWrappingIndex = raw.indexOfLast(isNotWrappingChar) - raw.substring( - if (firstNonWrappingIndex == - 1) 0 else firstNonWrappingIndex, - if (lastNonWrappingIndex == - 1) 0 else lastNonWrappingIndex + 1 + val raw = + flattenedXml.rawString.let { raw -> + // Remove space, newline character wrapping (typically due to IDE formatting) + // and user added quotations for styleable children due to lack of type. + val isNotWrappingChar: (Char) -> Boolean = { it !in setOf(' ', '\n') } + val firstNonWrappingIndex = raw.indexOfFirst(isNotWrappingChar) + val lastNonWrappingIndex = raw.indexOfLast(isNotWrappingChar) + raw + .substring( + if (firstNonWrappingIndex == -1) 0 else firstNonWrappingIndex, + if (lastNonWrappingIndex == -1) 0 else lastNonWrappingIndex + 1 ) - .removeSurrounding("\"") + .removeSurrounding("\"") } - return RawString( - table.stringPool.makeRef(raw, StringPool.Context(config=config))) + return RawString(table.stringPool.makeRef(raw, StringPool.Context(config = config))) } return null @@ -576,19 +594,20 @@ class TableExtractor( * Attempts to parse the xml subtree as an item resource. * * @param element The start of the element to be translated as an item type. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource The resource to put the parsed [Item] into, if successful. * @param resourceFormat A type mask that specifies which formats are valid for the xml to be - * interpreted as. + * interpreted as. * @return Whether or not the xml could be parsed. */ private fun parseItem( element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource, - resourceFormat: Int) : Boolean { + resourceFormat: Int + ): Boolean { if (resourceFormat == Resources.Attribute.FormatFlags.STRING_VALUE) { return parseString(element, eventReader, parsedResource) @@ -598,7 +617,8 @@ class TableExtractor( if (parsedResource.value == null) { logError( blameSource(parsedResource.source), - "Invalid <${parsedResource.name.type.tagName}> for given resource value.") + "Invalid <${parsedResource.name.type.tagName}> for given resource value." + ) return false } return true @@ -609,15 +629,18 @@ class TableExtractor( * translatable. * * @param element The start of the element to be translated at a string. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource the resource to put the parsed String into. The [ParsedResource.value] - * will be set to either a [BasicString] or [StyleString] resource, if successful. + * will be set to either a [BasicString] or [StyleString] resource, if successful. * @return Whether or not the element could be parsed as a String resource. */ private fun parseString( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { var formatted = true val formattedAttribute = element.getAttributeByName(QName("formatted")) if (formattedAttribute != null) { @@ -626,7 +649,8 @@ class TableExtractor( logError( blameSource(parsedResource.source), "Invalid value for the 'formatted' attribute. " + - "Was '${formattedAttribute.value}', must be a boolean.") + "Was '${formattedAttribute.value}', must be a boolean." + ) walkToEndOfElement(element, eventReader) return false } @@ -641,17 +665,20 @@ class TableExtractor( logError( blameSource(parsedResource.source), "Invalid value for 'translatable' attribute. " + - "Was '${translatableAttribute.value}', must be a boolean.") + "Was '${translatableAttribute.value}', must be a boolean." + ) walkToEndOfElement(element, eventReader) return false } translatable = maybeTranslatable } - val value = - parseXml(element, eventReader, Resources.Attribute.FormatFlags.STRING_VALUE, false) + val value = parseXml(element, eventReader, Resources.Attribute.FormatFlags.STRING_VALUE, false) if (value == null) { - logError( blameSource(parsedResource.source), "${parsedResource.name} does not contain a valid string resource.") + logError( + blameSource(parsedResource.source), + "${parsedResource.name} does not contain a valid string resource." + ) return false } @@ -660,8 +687,9 @@ class TableExtractor( if (formatted && translatable) { if (!verifyJavaStringFormat(value.toString())) { - val errorMsg = "Multiple substitutions specified in non-positional format of string " + - "resource ${parsedResource.name}. Did you mean to add the formatted=\"false\" attribute?" + val errorMsg = + "Multiple substitutions specified in non-positional format of string " + + "resource ${parsedResource.name}. Did you mean to add the formatted=\"false\" attribute?" if (options.errorOnPositionalArgs) { logError(blameSource(parsedResource.source), errorMsg) return false @@ -680,15 +708,18 @@ class TableExtractor( * Parses the xml element specified by {@code element} as a Enum or Flag value of an Attribute. * * @param element The start element that represents the symbol to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param tag The name of the flag or enum item. * @return The child resource if the parsing was successful, or {@code null} if the parsing - * failed. + * failed. */ private fun parseEnumOrFlagItem( - element: StartElement, eventReader: XMLEventReader, tag: String): AttributeResource.Symbol? { + element: StartElement, + eventReader: XMLEventReader, + tag: String + ): AttributeResource.Symbol? { val elementSource = source.withLine(element.location.lineNumber) walkToEndOfElement(element, eventReader) @@ -708,7 +739,9 @@ class TableExtractor( val resValue = stringToInt(valueAttribute.value) if (resValue == null) { logError( - blameSource(elementSource), "Invalid value '$resValue' for <$tag>. Must be an integer.") + blameSource(elementSource), + "Invalid value '$resValue' for <$tag>. Must be an integer." + ) return null } @@ -721,15 +754,18 @@ class TableExtractor( * Parses the xml element specified by {@code element} as an [Item] under the style. * * @param element The start element that represents the symbol to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param style The parent style of which this resource is a part. * @return The child resource if the parsing was successful, or {@code null} if the parsing - * failed. + * failed. */ private fun parseStyleItem( - element: StartElement, eventReader: XMLEventReader, style: Style): Boolean { + element: StartElement, + eventReader: XMLEventReader, + style: Style + ): Boolean { val itemSource = source.withLine(element.location.lineNumber) val nameAttribute = element.getAttributeByName(QName("name")) @@ -748,7 +784,8 @@ class TableExtractor( if (xmlItem == null) { logError( blameSource(source, element.location), - "Could not parse style item with name '${nameAttribute.value}'.") + "Could not parse style item with name '${nameAttribute.value}'." + ) return false } @@ -761,20 +798,24 @@ class TableExtractor( * formatting). * * @param eventReader the xml to flattened. The reader should have just read the start of the - * element that is needed to be flattened. After this method is invoked, the event reader will - * be after the end of the element that the flattened xml is to represent. - * @return - *

If Parsing fails, the [FlattenedXml.success] fill be set to false and the rest of the - * flattened xml will be left in a unspecified state. - *

Otherwise: - * [FlattenedXml.styleString] contains the escaped and whitespace trimmed text with included - * spans. - * [FlattenedXml.rawString] contains the unescaped text. - * [FlattenedXml.untranslatableSections] contains the sections of the string that should not be + * element that is needed to be flattened. After this method is invoked, the event reader will be + * after the end of the element that the flattened xml is to represent. + * @return

If Parsing fails, the [FlattenedXml.success] fill be set to false and the rest of + * the flattened xml will be left in a unspecified state.

Otherwise: + * [FlattenedXml.styleString] contains the escaped and whitespace trimmed text with included + * ``` + * spans. [FlattenedXml.rawString] + * ``` + * contains the unescaped text. [FlattenedXml.untranslatableSections] contains the sections of the + * string that should not be + * ``` * translated. + * ``` */ private fun flattenXmlSubTree( - startElement: StartElement, eventReader: XMLEventReader) : FlattenedXml { + startElement: StartElement, + eventReader: XMLEventReader + ): FlattenedXml { var depth = 1 @@ -785,7 +826,6 @@ class TableExtractor( when { event.isCharacters -> builder.append(event.asCharacters().data) - event.isStartElement -> { val element = event.asStartElement() @@ -813,9 +853,9 @@ class TableExtractor( // besides XLIFF, any other namespaced tags are unsupported and ignored. logger?.warning( "Ignoring element '$elementName' with unknown namespace '${elementName.namespaceURI}'.", - blameSource(source.withLine(element.location.lineNumber))) + blameSource(source.withLine(element.location.lineNumber)) + ) } - } ++depth } @@ -846,7 +886,8 @@ class TableExtractor( val resourceName = startElement.getAttributeByName(QName("name")).value logError( blameSource(source, startElement.location), - "Failed to flatten XML for resource '$resourceName' with error: ${builder.error}") + "Failed to flatten XML for resource '$resourceName' with error: ${builder.error}" + ) } return flattenedXml } @@ -855,27 +896,32 @@ class TableExtractor( * Parses the xml with a "symbol" tag * * @param element The start element that represents the symbol to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the parsed symbol will be stored, if the parsing was successful. * @return Whether of not the parsing was successful. */ private fun parseSymbol( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { var error = false if (options.visibility != null) { logError( blameSource(source, element.location), - " and tags are not supported with resource visibility.") + " and tags are not supported with resource visibility." + ) error = true } // Symbols should have the default config if (parsedResource.config != ConfigDescription()) { logger?.warning( - "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", - blameSource(source, element.location)) + "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", + blameSource(source, element.location) + ) } if (!parseSymbolImpl(element, eventReader, parsedResource)) { @@ -887,7 +933,10 @@ class TableExtractor( } private fun parseMacro( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { parsedResource.name = parsedResource.name.copy(type = AaptResourceType.MACRO) // Macros can only be defined in the default config @@ -895,17 +944,19 @@ class TableExtractor( if (parsedResource.config != defaultConfig) { logError( blameSource(source, element.location), - " tags cannot be declared in configurations other than the default configuration") + " tags cannot be declared in configurations other than the default configuration" + ) return false } val flattenedXml = flattenXmlSubTree(element, eventReader) if (!flattenedXml.success) { - return false + return false } // TODO(198264572): extract namespaces - parsedResource.value = Macro(flattenedXml.rawString, flattenedXml.styleString, flattenedXml.untranslatableSections) + parsedResource.value = + Macro(flattenedXml.rawString, flattenedXml.styleString, flattenedXml.untranslatableSections) return true } @@ -914,14 +965,17 @@ class TableExtractor( * Parses the xml with an "add-resource" tag. * * @param element The start element that represents the symbol to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the parsed symbol will be stored, if the parsing was successful. * @return Whether of not the parsing was successful. */ private fun parseAddResource( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { if (parseSymbolImpl(element, eventReader, parsedResource)) { parsedResource.visibility = ResourceVisibility.UNDEFINED parsedResource.allowNew = true @@ -931,24 +985,28 @@ class TableExtractor( } /** - * Parses the xml as a Symbol represented by the specified start element. Then, stores the - * value in the parsed resource. + * Parses the xml as a Symbol represented by the specified start element. Then, stores the value + * in the parsed resource. * * @param element The start element that represents the symbol to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the parsed symbol will be stored, if the parsing was successful. * @return Whether of not the parsing was successful. */ private fun parseSymbolImpl( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { val typeAttribute = element.getAttributeByName(QName("type")) if (typeAttribute == null) { walkToEndOfElement(element, eventReader) logError( blameSource(source, element.location), - "<${element.name}> must have a 'type' attribute.") + "<${element.name}> must have a 'type' attribute." + ) return false } @@ -957,7 +1015,8 @@ class TableExtractor( walkToEndOfElement(element, eventReader) logError( blameSource(source, element.location), - "Invalid resource type '${typeAttribute.value}' in <${element.name}> resource.") + "Invalid resource type '${typeAttribute.value}' in <${element.name}> resource." + ) return false } @@ -970,24 +1029,26 @@ class TableExtractor( * Parses the xml represented by the "attr" tag. * * @param element The start element that represents the [AttributeResource] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the [AttributeResource] will be stored, if successful. * @return Whether of not the parsing was successful. */ private fun parseAttr( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean = - parseAttrImpl(element, eventReader, parsedResource, false) + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean = parseAttrImpl(element, eventReader, parsedResource, false) /** * parses the xml as a [AttributeResource] represented by the specified start element. Then stores * the value in the parsed resource. * * @param element The start element that represents the symbol to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the parsed symbol will be stored, if the parsing was successful. * @param isWeak whether or not the resource should be parsed as a weak attr (declaration). * @return Whether of not the parsing was successful. @@ -996,7 +1057,8 @@ class TableExtractor( element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource, - isWeak: Boolean): Boolean { + isWeak: Boolean + ): Boolean { parsedResource.name = parsedResource.name.copy(type = AaptResourceType.ATTR) // Attributes only end up in default configuration @@ -1004,7 +1066,8 @@ class TableExtractor( if (parsedResource.config != defaultConfig) { logger?.warning( "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", - blameSource(source, element.location)) + blameSource(source, element.location) + ) parsedResource.config = defaultConfig } @@ -1016,7 +1079,8 @@ class TableExtractor( if (typeMask == 0) { logError( blameSource(source, element.location), - "Invalid attribute format '${formatAttribute.value}'") + "Invalid attribute format '${formatAttribute.value}'" + ) walkToEndOfElement(element, eventReader) return false } @@ -1040,7 +1104,8 @@ class TableExtractor( if (min == null) { logError( blameSource(source, element.location), - "Invalid 'min' value '$minString'. Integer value required.") + "Invalid 'min' value '$minString'. Integer value required." + ) walkToEndOfElement(element, eventReader) return false } @@ -1058,17 +1123,21 @@ class TableExtractor( if (max == null) { logError( blameSource(source, element.location), - "Invalid 'max' value '$maxString'. Integer value required.") + "Invalid 'max' value '$maxString'. Integer value required." + ) walkToEndOfElement(element, eventReader) return false } } - if ((min != null || max != null) && - (typeMask and Resources.Attribute.FormatFlags.INTEGER_VALUE) == 0) { + if ( + (min != null || max != null) && + (typeMask and Resources.Attribute.FormatFlags.INTEGER_VALUE) == 0 + ) { logError( blameSource(source, element.location), - "'min' and 'max' attributes can only be used with format='integer' on <${element.name}> resource") + "'min' and 'max' attributes can only be used with format='integer' on <${element.name}> resource" + ) walkToEndOfElement(element, eventReader) return false } @@ -1098,15 +1167,18 @@ class TableExtractor( val childSource = source.withLine(event.location.lineNumber) val childName = childElement.name - if (childName.namespaceURI.isEmpty() && - (childName.localPart == "flag" || childName.localPart == "enum")) { + if ( + childName.namespaceURI.isEmpty() && + (childName.localPart == "flag" || childName.localPart == "enum") + ) { var itemError = false when (childName.localPart) { "enum" -> { if ((typeMask and Resources.Attribute.FormatFlags.FLAGS_VALUE) != 0) { logError( blameSource(source, childElement.location), - "Cannot define both and under the same <${element.name}> resource.") + "Cannot define both and under the same <${element.name}> resource." + ) error = true itemError = true } @@ -1116,7 +1188,8 @@ class TableExtractor( if ((typeMask and Resources.Attribute.FormatFlags.ENUM_VALUE) != 0) { logError( blameSource(source, childElement.location), - "Cannot define both and under the same <${element.name}> resource.") + "Cannot define both and under the same <${element.name}> resource." + ) error = true itemError = true } @@ -1149,7 +1222,7 @@ class TableExtractor( ?: blameSource(symbolMap[symbolName]!!.symbol.source) val errorMsg = "Duplicate symbol '$symbolName' defined here: $newSource" + - " and here: $previousSource" + " and here: $previousSource" logError(blameSource(symbol.symbol.source), errorMsg) error = true } @@ -1157,11 +1230,12 @@ class TableExtractor( } else { error = true } - } else{ + } else { if (!shouldIgnoreElement(childName)) { logError( blameSource(childSource), - "Unrecognized tag <$childName> of child element of <${element.name}>.") + "Unrecognized tag <$childName> of child element of <${element.name}>." + ) error = true } walkToEndOfElement(childElement, eventReader) @@ -1173,8 +1247,8 @@ class TableExtractor( return false } - val resource = AttributeResource( - if (typeMask == 0) Resources.Attribute.FormatFlags.ANY_VALUE else typeMask) + val resource = + AttributeResource(if (typeMask == 0) Resources.Attribute.FormatFlags.ANY_VALUE else typeMask) resource.weak = isWeak resource.symbols.addAll(symbolMap.values) resource.minInt = min ?: Int.MIN_VALUE @@ -1188,13 +1262,16 @@ class TableExtractor( * parsed from the format attribute of {@code element} * * @param element The start element of the [ArrayResource] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the read resource will be placed. */ private fun parseArray( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { var resourceFormat = Resources.Attribute.FormatFlags.ANY_VALUE val formatAttribute = element.getAttributeByName(QName("format")) if (formatAttribute != null) { @@ -1202,7 +1279,8 @@ class TableExtractor( if (resourceFormat == 0) { logError( blameSource(source, element.location), - "Invalid format value: '${formatAttribute.value}'.") + "Invalid format value: '${formatAttribute.value}'." + ) walkToEndOfElement(element, eventReader) return false } @@ -1214,47 +1292,62 @@ class TableExtractor( * Parse the xml that is contained by the "integer-array" tag. * * @param element The start element of the [ArrayResource] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the read resource will be placed. */ private fun parseIntegerArray( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource) = + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ) = parseArrayImpl( - element, eventReader, parsedResource, Resources.Attribute.FormatFlags.INTEGER_VALUE) + element, + eventReader, + parsedResource, + Resources.Attribute.FormatFlags.INTEGER_VALUE + ) /** * Parse the xml that is contained by the "string-array" tag. * * @param element The start element of the [ArrayResource] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the read resource will be placed. */ private fun parseStringArray( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource) = + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ) = parseArrayImpl( - element, eventReader, parsedResource, Resources.Attribute.FormatFlags.STRING_VALUE) + element, + eventReader, + parsedResource, + Resources.Attribute.FormatFlags.STRING_VALUE + ) /** * Parse the xml as an [ArrayResource]. * * @param element The start element of the [ArrayResource] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource where the read resource will be placed. * @param resourceFormat A type mask that specifies which formats are valid for the child elements - * of the array to be interpreted as. + * of the array to be interpreted as. * @return Whether or not the parsing was successful. */ private fun parseArrayImpl( element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource, - resourceFormat: Int): Boolean { + resourceFormat: Int + ): Boolean { parsedResource.name = parsedResource.name.copy(type = AaptResourceType.ARRAY) @@ -1267,7 +1360,8 @@ class TableExtractor( if (translatableValue == null) { logError( blameSource(parsedResource.source), - "Invalid value for 'translatable' attribute. Must be a boolean.") + "Invalid value for 'translatable' attribute. Must be a boolean." + ) walkToEndOfElement(element, eventReader) return false } @@ -1303,7 +1397,9 @@ class TableExtractor( } !shouldIgnoreElement(childName) -> { logError( - blameSource(childSource), "Unknown tag <$childName> in <${element.name}> resource.") + blameSource(childSource), + "Unknown tag <$childName> in <${element.name}> resource." + ) error = true walkToEndOfElement(childElement, eventReader) } @@ -1325,47 +1421,52 @@ class TableExtractor( * Parses the xml contained in a "configVarying" tag. * * @param element The start element of the [Style] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @return returns whether or not the parsing was a success. */ private fun parseConfigVarying( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource) = - parseStyleImpl(element, eventReader, parsedResource, AaptResourceType.CONFIG_VARYING) + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ) = parseStyleImpl(element, eventReader, parsedResource, AaptResourceType.CONFIG_VARYING) /** * Parses the xml contained in a "style" tag. * * @param element The start element of the [Style] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @return returns whether or not the parsing was a success. */ private fun parseStyle( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource) = - parseStyleImpl(element, eventReader, parsedResource, AaptResourceType.STYLE) + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ) = parseStyleImpl(element, eventReader, parsedResource, AaptResourceType.STYLE) /** * Parses the xml element as a [Style]. * * @param element The start element of the [Style] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @param type The actual type of the [Style] being parsed, which is reflected in the - * [ResourceName] of the parsed resource. + * [ResourceName] of the parsed resource. * @return returns whether or not the parsing was a success. */ private fun parseStyleImpl( element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource, - type: AaptResourceType): Boolean { + type: AaptResourceType + ): Boolean { parsedResource.name = parsedResource.name.copy(type = type) @@ -1423,7 +1524,8 @@ class TableExtractor( if (!shouldIgnoreElement(childName)) { logError( blameSource(source, childElement.location), - "Unrecognized child element <$childName> of <${element.name}> resource.") + "Unrecognized child element <$childName> of <${element.name}> resource." + ) error = true } walkToEndOfElement(childElement, eventReader) @@ -1442,14 +1544,17 @@ class TableExtractor( * Parses the xml element contained by a "declare-styleable" tag as a [Styleable] resource. * * @param element The start element of the [Styleable] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @return returns whether or not the parsing was a success. */ private fun parseDeclareStyleable( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { parsedResource.name = parsedResource.name.copy(type = AaptResourceType.STYLEABLE) // TODO(b/153454907): add option for preservation of stylable visibility to match aapt2 @@ -1460,7 +1565,8 @@ class TableExtractor( if (parsedResource.config != defaultConfig) { logger?.warning( "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", - blameSource(source, element.location)) + blameSource(source, element.location) + ) parsedResource.config = defaultConfig } @@ -1518,11 +1624,12 @@ class TableExtractor( styleable.entries.add(nameReference) parsedResource.children.add(childResource) - } else { if (!shouldIgnoreElement(childName)) { logError( - blameSource(itemSource), "Unknown tag of <$childName> in <${element.name}> resource.") + blameSource(itemSource), + "Unknown tag of <$childName> in <${element.name}> resource." + ) error = true } walkToEndOfElement(childElement, eventReader) @@ -1543,26 +1650,32 @@ class TableExtractor( * Parses the xml element surrounded by the "overlayable" tag as an [Overlayable] resource. * * @param element The start element of the [Overlayable] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @return returns whether or not the parsing was a success. */ private fun parseOverlayable( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { val defaultConfig = ConfigDescription() if (parsedResource.config != defaultConfig) { logger?.warning( "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", - blameSource(source, element.location)) + blameSource(source, element.location) + ) } val nameAttribute = element.getAttributeByName(QName(null, "name")) if (nameAttribute == null) { logError( - blameSource(source, element.location), " tag must have a 'name' attribute") + blameSource(source, element.location), + " tag must have a 'name' attribute" + ) return false } @@ -1570,8 +1683,9 @@ class TableExtractor( if (actorAttribute != null && !actorAttribute.value.startsWith(Overlayable.ACTOR_SCHEME_URI)) { logError( blameSource(source, element.location), - " tag has a 'actor' attribute: '${actorAttribute.value}'. " + - "Value must use the schema: ${Overlayable.ACTOR_SCHEME_URI}.") + " tag has a 'actor' attribute: '${actorAttribute.value}'. " + + "Value must use the schema: ${Overlayable.ACTOR_SCHEME_URI}." + ) return false } @@ -1618,8 +1732,7 @@ class TableExtractor( parsedResource.children.add(childResource) } } - childName.namespaceURI == XMLConstants.NULL_NS_URI && - childName.localPart == "policy" -> { + childName.namespaceURI == XMLConstants.NULL_NS_URI && childName.localPart == "policy" -> { ++depth val newPolicy = parsePoliciesFromElement(childElement, currentPolicies) @@ -1634,8 +1747,9 @@ class TableExtractor( } !shouldIgnoreElement(childName) -> { logError( - blameSource(source, childElement.location), - "Unrecognized tag '$childName' within an resource.") + blameSource(source, childElement.location), + "Unrecognized tag '$childName' within an resource." + ) error = true } else -> comment = "" @@ -1649,27 +1763,29 @@ class TableExtractor( * Parses the xml element as a [OverlayableItem] within an [Overlayable] resource. * * @param element The start element of the [OverlayableItem] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param policies The policies of the current policy block that this [OverlayableItem] is a part - * of. The value of policies should be non-zero. + * of. The value of policies should be non-zero. * @param overlayable The overlayable which the parsed resource will be a part of. * @param comment The comment that applies to this element. * @return The parsedResource representing the parsed Overlayable Item. If their is an issue - * parsing, then {@code null} is returned. + * parsing, then {@code null} is returned. */ private fun parseOverlayableItem( element: StartElement, eventReader: XMLEventReader, policies: Int, overlayable: Overlayable, - comment: String): ParsedResource? { + comment: String + ): ParsedResource? { if (policies == OverlayableItem.Policy.NONE) { logError( - blameSource(source, element.location), - " within an must be inside a block.") + blameSource(source, element.location), + " within an must be inside a block." + ) walkToEndOfElement(element, eventReader) return null } @@ -1678,8 +1794,9 @@ class TableExtractor( val nameAttribute = element.getAttributeByName(QName(null, "name")) if (nameAttribute == null || nameAttribute.value.isNullOrEmpty()) { logError( - blameSource(source, element.location), - " within an must have a 'name' attribute.") + blameSource(source, element.location), + " within an must have a 'name' attribute." + ) walkToEndOfElement(element, eventReader) return null } @@ -1687,8 +1804,9 @@ class TableExtractor( val typeAttribute = element.getAttributeByName(QName(null, "type")) if (typeAttribute == null || typeAttribute.value.isNullOrEmpty()) { logError( - blameSource(source, element.location), - " within an must have a 'type' attribute.") + blameSource(source, element.location), + " within an must have a 'type' attribute." + ) walkToEndOfElement(element, eventReader) return null } @@ -1696,8 +1814,9 @@ class TableExtractor( val type = resourceTypeFromTag(typeAttribute.value) if (type == null) { logError( - blameSource(source, element.location), - "Invalid resource type '${typeAttribute.value}' in in resource.") + blameSource(source, element.location), + "Invalid resource type '${typeAttribute.value}' in in resource." + ) walkToEndOfElement(element, eventReader) return null } @@ -1714,21 +1833,22 @@ class TableExtractor( } /** - * Parses the "type" attribute of the block for policies. This does not move the - * xml parser, as this does not read + * Parses the "type" attribute of the block for policies. This does not move the xml + * parser, as this does not read * * @param element The start element of the block. * @param oldPolicies The current policies to be overwritten. As nested policy blocks are not - * allowed, the oldPolicies is expected to be [OverlayableItem.Policy.NONE]. + * allowed, the oldPolicies is expected to be [OverlayableItem.Policy.NONE]. * @return The new policy values or null if an error occurred. */ - private fun parsePoliciesFromElement( - element: StartElement, oldPolicies: Int): Int? { + private fun parsePoliciesFromElement(element: StartElement, oldPolicies: Int): Int? { if (oldPolicies != OverlayableItem.Policy.NONE) { // If the policy list is not empty, then we are currently inside a policy element. logError( - blameSource(source, element.location), "Policy blocks should not be nested recursively.") + blameSource(source, element.location), + "Policy blocks should not be nested recursively." + ) return null } @@ -1742,21 +1862,24 @@ class TableExtractor( // Parse the polices separated by vertical bar characters to allow for specifying multiple // policies. Items within the policy tag will have the specified policy. for (string in typeAttribute.value.split('|')) { - newPolicy = newPolicy or when(string.trim()) { - "odm" -> OverlayableItem.Policy.ODM - "oem" -> OverlayableItem.Policy.OEM - "product" -> OverlayableItem.Policy.PRODUCT - "public" -> OverlayableItem.Policy.PUBLIC - "signature" -> OverlayableItem.Policy.SIGNATURE - "system" -> OverlayableItem.Policy.SYSTEM - "vendor" -> OverlayableItem.Policy.VENDOR - else -> { - logError( - blameSource(source, element.location), - " has unsupported type '${string.trim()}'.") - return null - } - } + newPolicy = + newPolicy or + when (string.trim()) { + "odm" -> OverlayableItem.Policy.ODM + "oem" -> OverlayableItem.Policy.OEM + "product" -> OverlayableItem.Policy.PRODUCT + "public" -> OverlayableItem.Policy.PUBLIC + "signature" -> OverlayableItem.Policy.SIGNATURE + "system" -> OverlayableItem.Policy.SYSTEM + "vendor" -> OverlayableItem.Policy.VENDOR + else -> { + logError( + blameSource(source, element.location), + " has unsupported type '${string.trim()}'." + ) + return null + } + } } return newPolicy @@ -1766,15 +1889,18 @@ class TableExtractor( * Parses the {@code element} as a [Plural] resource. * * @param element The start element of the [Plural] to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @return returns whether or not the parsing was a success. */ private fun parsePlural( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { - parsedResource.name = parsedResource.name.copy(type=AaptResourceType.PLURALS) + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { + parsedResource.name = parsedResource.name.copy(type = AaptResourceType.PLURALS) val plural = Plural() @@ -1798,29 +1924,32 @@ class TableExtractor( val quantityAttribute = childElement.getAttributeByName(QName("quantity")) if (quantityAttribute == null) { logError( - blameSource(source, childElement.location), - " in are required to have the 'quantity' attribute.") + blameSource(source, childElement.location), + " in are required to have the 'quantity' attribute." + ) walkToEndOfElement(childElement, eventReader) error = true continue } val trimmedQuantity = quantityAttribute.value.trim() - val pluralType = when (trimmedQuantity) { - "zero" -> Plural.Type.ZERO - "one" -> Plural.Type.ONE - "two" -> Plural.Type.TWO - "few" -> Plural.Type.FEW - "many" -> Plural.Type.MANY - "other" -> Plural.Type.OTHER - else -> null - } + val pluralType = + when (trimmedQuantity) { + "zero" -> Plural.Type.ZERO + "one" -> Plural.Type.ONE + "two" -> Plural.Type.TWO + "few" -> Plural.Type.FEW + "many" -> Plural.Type.MANY + "other" -> Plural.Type.OTHER + else -> null + } if (pluralType == null) { logError( - blameSource(source, childElement.location), - "Unrecognized quantity value '$trimmedQuantity' specified in " + - "in resource.") + blameSource(source, childElement.location), + "Unrecognized quantity value '$trimmedQuantity' specified in " + + "in resource." + ) walkToEndOfElement(childElement, eventReader) error = true continue @@ -1830,8 +1959,9 @@ class TableExtractor( if (plural.values[pluralIndex] != null) { logError( blameSource(source, childElement.location), - " has quantity '$trimmedQuantity' which has already been specified " + - "in resource '${element.name}'") + " has quantity '$trimmedQuantity' which has already been specified " + + "in resource '${element.name}'" + ) error = true walkToEndOfElement(childElement, eventReader) continue @@ -1845,8 +1975,9 @@ class TableExtractor( } else { if (!shouldIgnoreElement(childName)) { logError( - blameSource(source, childElement.location), - "Unrecognized tag '$childName' within an resource.") + blameSource(source, childElement.location), + "Unrecognized tag '$childName' within an resource." + ) error = true } walkToEndOfElement(childElement, eventReader) @@ -1865,19 +1996,23 @@ class TableExtractor( * Parses the {@code element} as a public resource. * * @param element The start element of the resource to be parsed. - * @param eventReader The xml to be read. The event reader should have just pulled the - * {@code StartElement} element. After this method is invoked the eventReader will be placed - * after the corresponding end tag for element. + * @param eventReader The xml to be read. The event reader should have just pulled the {@code + * StartElement} element. After this method is invoked the eventReader will be placed after the + * corresponding end tag for element. * @param parsedResource Where the parsed resource will be placed. * @return returns whether or not the parsing was a success. */ private fun parsePublic( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { - if (options.visibility != null ) { + if (options.visibility != null) { logError( - blameSource(source, element.location), - " tag not allowed with --visibility flag.") + blameSource(source, element.location), + " tag not allowed with --visibility flag." + ) walkToEndOfElement(element, eventReader) return false } @@ -1885,7 +2020,8 @@ class TableExtractor( if (parsedResource.config != ConfigDescription()) { logger?.warning( "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", - blameSource(source, element.location)) + blameSource(source, element.location) + ) } val typeAttribute = element.getAttributeByName(QName("type")) @@ -1898,8 +2034,9 @@ class TableExtractor( val parsedType = resourceTypeFromTag(typeAttribute.value) if (parsedType == null) { logError( - blameSource(source, element.location), - "Invalid resource type '${typeAttribute.value}' in resource.") + blameSource(source, element.location), + "Invalid resource type '${typeAttribute.value}' in resource." + ) walkToEndOfElement(element, eventReader) return false } @@ -1911,8 +2048,9 @@ class TableExtractor( val id = parseResourceId(idAttribute.value) if (id == null) { logError( - blameSource(source, element.location), - "Invalid resource Id '${idAttribute.value}' in resource.") + blameSource(source, element.location), + "Invalid resource Id '${idAttribute.value}' in resource." + ) walkToEndOfElement(element, eventReader) return false } @@ -1934,26 +2072,32 @@ class TableExtractor( * corresponding end of {@code element} */ private fun parsePublicGroup( - element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean { + element: StartElement, + eventReader: XMLEventReader, + parsedResource: ParsedResource + ): Boolean { if (options.visibility != null) { logError( - blameSource(source, element.location), - " tag not allowed with --visibility flag.") + blameSource(source, element.location), + " tag not allowed with --visibility flag." + ) walkToEndOfElement(element, eventReader) return false } if (parsedResource.config != ConfigDescription()) { logger?.warning( - "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", - blameSource(source, element.location)) + "Ignoring configuration '${parsedResource.config}' for <${element.name}> tag.", + blameSource(source, element.location) + ) } val typeAttribute = element.getAttributeByName(QName("type")) if (typeAttribute == null) { logError( - blameSource(source, element.location), - " must have a 'type' attribute.") + blameSource(source, element.location), + " must have a 'type' attribute." + ) walkToEndOfElement(element, eventReader) return false } @@ -1961,8 +2105,9 @@ class TableExtractor( val parsedType = resourceTypeFromTag(typeAttribute.value) if (parsedType == null) { logError( - blameSource(source, element.location), - "Invalid resource type '${typeAttribute.value}' in .") + blameSource(source, element.location), + "Invalid resource type '${typeAttribute.value}' in ." + ) walkToEndOfElement(element, eventReader) return false } @@ -1970,8 +2115,9 @@ class TableExtractor( val idAttribute = element.getAttributeByName(QName("first-id")) if (idAttribute == null) { logError( - blameSource(source, element.location), - " must have a 'first-id' attribute.") + blameSource(source, element.location), + " must have a 'first-id' attribute." + ) walkToEndOfElement(element, eventReader) return false } @@ -1979,8 +2125,9 @@ class TableExtractor( val idVal = parseResourceId(idAttribute.value) if (idVal == null) { logError( - blameSource(source, element.location), - "Invalid resource ID '${idAttribute.value}' in . Integer expected.") + blameSource(source, element.location), + "Invalid resource ID '${idAttribute.value}' in . Integer expected." + ) walkToEndOfElement(element, eventReader) return false } @@ -2012,9 +2159,11 @@ class TableExtractor( val itemSource = source.withLine(childElement.location.lineNumber) if (childName.namespaceURI.isEmpty() && childName.localPart == "public") { val nameAttribute = childElement.getAttributeByName(QName("name")) - if (nameAttribute == null) { + if (nameAttribute == null) { logError( - blameSource(source, childElement.location), " must have a 'name' attribute.") + blameSource(source, childElement.location), + " must have a 'name' attribute." + ) walkToEndOfElement(childElement, eventReader) error = true continue @@ -2023,8 +2172,9 @@ class TableExtractor( val childIdAttribute = childElement.getAttributeByName(QName("id")) if (childIdAttribute != null) { logError( - blameSource(source, childElement.location), - "'id' attribute is not allowed on tags within a .") + blameSource(source, childElement.location), + "'id' attribute is not allowed on tags within a ." + ) walkToEndOfElement(childElement, eventReader) error = true continue @@ -2033,8 +2183,9 @@ class TableExtractor( val childTypeAttribute = childElement.getAttributeByName(QName("type")) if (childTypeAttribute != null) { logError( - blameSource(source, childElement.location), - "'type' attribute is not allowed on tags within a .") + blameSource(source, childElement.location), + "'type' attribute is not allowed on tags within a ." + ) walkToEndOfElement(childElement, eventReader) error = true continue @@ -2051,8 +2202,9 @@ class TableExtractor( } else { if (!shouldIgnoreElement(childName)) { logError( - blameSource(source, childElement.location), - "Unrecognized tag '$childName' within an resource.") + blameSource(source, childElement.location), + "Unrecognized tag '$childName' within an resource." + ) error = true } walkToEndOfElement(childElement, eventReader) @@ -2095,12 +2247,15 @@ class TableExtractor( resource.comment = parsedResource.comment resource.source = parsedResource.source - if (!table.addResourceWithId( + if ( + !table.addResourceWithId( parsedResource.name, parsedResource.resourceId, parsedResource.config, parsedResource.productString, - resource)) { + resource + ) + ) { return false } } diff --git a/build-tools/aaptcompiler/src/main/java/com/itsaky/androidide/aapt/logging/IDELogger.kt b/build-tools/aaptcompiler/src/main/java/com/itsaky/androidide/aapt/logging/IDELogger.kt new file mode 100644 index 000000000..ec6423cb4 --- /dev/null +++ b/build-tools/aaptcompiler/src/main/java/com/itsaky/androidide/aapt/logging/IDELogger.kt @@ -0,0 +1,58 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.aapt.logging + +import com.android.utils.ILogger + +/** + * Implementation of [ILogger] which redirects all logs to AndroidIDE's logger implementation i.e. + * [com.itsaky.androidide.utils.ILogger]. + * + * @author Akash Yadav + */ +object IDELogger : ILogger { + + private val log = com.itsaky.androidide.utils.ILogger.newInstance("AAPTCompilerLogger") + + override fun error(t: Throwable?, msgFormat: String?, vararg args: Any?) { + if (msgFormat != null) { + log.error(String.format(msgFormat, args)) + } + if (t != null) { + log.error(t) + } + } + + override fun warning(msgFormat: String?, vararg args: Any?) { + if (msgFormat != null) { + log.warn(String.format(msgFormat, args)) + } + } + + override fun info(msgFormat: String?, vararg args: Any?) { + if (msgFormat != null) { + log.info(String.format(msgFormat, args)) + } + } + + override fun verbose(msgFormat: String?, vararg args: Any?) { + if (msgFormat != null) { + log.verbose(String.format(msgFormat, args)) + } + } +} diff --git a/build-tools/aaptcompiler/src/test/java/com/itsaky/androidide/aaptcompiler/CompilerTest.kt b/build-tools/aaptcompiler/src/test/java/com/itsaky/androidide/aaptcompiler/CompilerTest.kt index 05c3c979b..1b2cb34e6 100644 --- a/build-tools/aaptcompiler/src/test/java/com/itsaky/androidide/aaptcompiler/CompilerTest.kt +++ b/build-tools/aaptcompiler/src/test/java/com/itsaky/androidide/aaptcompiler/CompilerTest.kt @@ -27,9 +27,10 @@ import kotlin.io.path.absolute import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import org.robolectric.RobolectricTestRunner /** @author Akash Yadav */ -@RunWith(JUnit4::class) +@RunWith(RobolectricTestRunner::class) class CompilerTest { @Test diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DOMMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/JAXPValidationMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/SAXMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XIncludeMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XMLSerializerMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_de.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_de.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_de.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_de.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_es.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_es.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_es.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_es.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_fr.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_fr.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_fr.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_fr.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_it.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_it.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_it.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_it.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ja.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ja.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ja.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ja.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ko.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ko.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ko.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_ko.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_pt_BR.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_pt_BR.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_pt_BR.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_pt_BR.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_sv.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_sv.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_sv.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_sv.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_CN.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_CN.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_CN.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_CN.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_TW.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_TW.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_TW.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xerces/internal/impl/msg/XPointerMessages_zh_TW.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/Encodings.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/Encodings.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/Encodings.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/Encodings.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/HTMLEntities.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/HTMLEntities.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/HTMLEntities.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/HTMLEntities.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/XMLEntities.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/XMLEntities.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/XMLEntities.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/XMLEntities.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_html.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_html.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_html.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_html.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_text.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_text.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_text.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_text.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_unknown.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_unknown.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_unknown.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_unknown.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_xml.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_xml.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/output_xml.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/output_xml.properties diff --git a/build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessagers.properties b/build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/utils/SerializerMessagers.properties similarity index 100% rename from build-tools/jaxp/src/main/resources/org/openjdk/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessagers.properties rename to build-tools/jaxp/src/main/resources/jaxp/sun/org/apache/xml/internal/serializer/utils/SerializerMessagers.properties diff --git a/build-tools/layoutlib-api/build.gradle b/build-tools/layoutlib-api/build.gradle index f446dff3c..99eac5946 100644 --- a/build-tools/layoutlib-api/build.gradle +++ b/build-tools/layoutlib-api/build.gradle @@ -55,9 +55,8 @@ android { dependencies { implementation common.jkotlin - implementation 'com.android.tools:annotations:30.2.2' - implementation 'net.sf.kxml:kxml2:2.3.0' - implementation 'org.jetbrains:annotations:13.0' + implementation aapt.annotations + implementation aapt.jb_annotations implementation google.guava_jre diff --git a/build-tools/xml-utils/.gitignore b/build-tools/xml-utils/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/build-tools/xml-utils/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/build-tools/xml-utils/build.gradle b/build-tools/xml-utils/build.gradle new file mode 100644 index 000000000..5ad5d184c --- /dev/null +++ b/build-tools/xml-utils/build.gradle @@ -0,0 +1,65 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +plugins { + id 'com.android.library' + id 'kotlin-android' +} + +android { + namespace "com.itsaky.androidide.aaptcompiler" + compileSdkVersion rootProject.ext.compileSdk + buildToolsVersion rootProject.ext.buildTools + + defaultConfig { + minSdkVersion rootProject.ext.minSdk + targetSdkVersion rootProject.ext.targetSdk + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility rootProject.ext.javaSourceVersion + targetCompatibility rootProject.ext.javaTargetVersion + } + + kotlinOptions { + jvmTarget = "11" + } + + testOptions { + unitTests { + includeAndroidResources = true + } + } +} + +dependencies { + implementation common.kotlin + implementation project(path: ':logger') + + api project(path: ':build-tools:aaptcompiler') + + testImplementation tests.junit + testImplementation tests.robolectric + testImplementation tests.google_truth +} \ No newline at end of file diff --git a/build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/ResourceTableRegistry.kt b/build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/ResourceTableRegistry.kt new file mode 100644 index 000000000..fe3e83c13 --- /dev/null +++ b/build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/ResourceTableRegistry.kt @@ -0,0 +1,54 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.xml.res + +import com.android.aaptcompiler.ResourceTable +import com.itsaky.androidide.xml.res.internal.DefaultResourceTableRegistry +import java.io.File + +/** + * Handles resource tables for multiple modules/dependencies and the framework resources. + * + * @author Akash Yadav + */ +interface ResourceTableRegistry { + + companion object { + private val instance = DefaultResourceTableRegistry() + + @JvmStatic fun getInstance(): ResourceTableRegistry = instance + } + + /** + * Get the resource table for the given resource directory. Creates a resource table if not + * already created. + * + * @param dir The directory to create resource table for. + */ + fun forResourceDir(dir: File): ResourceTable? + + /** + * Remove the resource table entry for the given resource directory. + * + * @param dir The resource directory to remove the resource table entry for. + */ + fun removeTable(dir: File) + + /** Clears all the registered resource tables. */ + fun clear() +} diff --git a/build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/internal/DefaultResourceTableRegistry.kt b/build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/internal/DefaultResourceTableRegistry.kt new file mode 100644 index 000000000..ac53b90b5 --- /dev/null +++ b/build-tools/xml-utils/src/main/java/com/itsaky/androidide/xml/res/internal/DefaultResourceTableRegistry.kt @@ -0,0 +1,122 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.xml.res.internal + +import com.android.aaptcompiler.BlameLogger +import com.android.aaptcompiler.ResourceTable +import com.android.aaptcompiler.TableExtractor +import com.android.aaptcompiler.TableExtractorOptions +import com.android.aaptcompiler.extractPathData +import com.itsaky.androidide.aapt.logging.IDELogger +import com.itsaky.androidide.layoutlib.resources.ResourceVisibility.PUBLIC +import com.itsaky.androidide.utils.ILogger +import com.itsaky.androidide.xml.res.ResourceTableRegistry +import java.io.File +import java.util.concurrent.ConcurrentHashMap + +/** + * Default implementation of the [ResourceTableRegistry]. + * + * @author Akash Yadav + */ +internal class DefaultResourceTableRegistry : ResourceTableRegistry { + + private val log = ILogger.newInstance(javaClass.simpleName) + + private var tables = ConcurrentHashMap() + + override fun forResourceDir(dir: File): ResourceTable? { + var table = tables[dir.path] + if (table != null) { + return table + } + + table = createTable(dir) ?: return null + tables[dir.path] = table + return table + } + + private fun createTable(resDir: File): ResourceTable? { + val values = File(resDir, "values") + if (!values.exists()) { + return null + } + + val logger = BlameLogger(IDELogger) + val table = ResourceTable() + val options = + TableExtractorOptions(translatable = true, errorOnPositionalArgs = false, visibility = PUBLIC) + values + .listFiles { file -> file.isFile && file.extension == "xml" } + ?.forEach { updateFromFile(it = it, table = table, options = options, logger = logger) } + return table + } + + override fun removeTable(dir: File) { + tables.remove(dir.path) + } + + private fun updateFromDirectory( + directory: File, + table: ResourceTable, + options: TableExtractorOptions, + logger: BlameLogger = BlameLogger(IDELogger) + ) { + directory.listFiles()?.forEach { + if (it.isDirectory || it.extension != "xml") { + return@forEach + } + + updateFromFile(it, table, options, logger) + } + } + + private fun updateFromFile( + it: File, + table: ResourceTable, + options: TableExtractorOptions, + logger: BlameLogger + ) { + val pathData = extractPathData(it) + if (pathData.extension != "xml") { + // Cannot parse any other file types + return + } + + val extractor = + TableExtractor( + table = table, + source = pathData.source, + config = pathData.config, + options = options, + logger = logger + ) + + pathData.file.inputStream().use { stream -> + try { + extractor.extract(stream) + } catch (err: Exception) { + log.warn("Failed to compile ${pathData.file}", err.message) + } + } + } + + override fun clear() { + tables.clear() + } +} diff --git a/build-tools/xml-utils/src/test/java/com/itsaky/androidide/xml/res/ResourceTableRegistryTest.kt b/build-tools/xml-utils/src/test/java/com/itsaky/androidide/xml/res/ResourceTableRegistryTest.kt new file mode 100644 index 000000000..7e6206fd3 --- /dev/null +++ b/build-tools/xml-utils/src/test/java/com/itsaky/androidide/xml/res/ResourceTableRegistryTest.kt @@ -0,0 +1,143 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.xml.res + +import android.graphics.Color +import com.android.aaptcompiler.AaptResourceType.COLOR +import com.android.aaptcompiler.AaptResourceType.STRING +import com.android.aaptcompiler.BasicString +import com.android.aaptcompiler.BinaryPrimitive +import com.android.aaptcompiler.ResourceName +import com.android.aaptcompiler.android.ResValue.DataType +import com.google.common.truth.Truth.assertThat +import com.itsaky.androidide.xml.res.internal.DefaultResourceTableRegistry +import java.io.File +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +/** @author Akash Yadav */ +@RunWith(RobolectricTestRunner::class) +class ResourceTableRegistryTest { + + @Test + fun `test instance of registry`() { + val instance = ResourceTableRegistry.getInstance() + assertThat(instance).isInstanceOf(DefaultResourceTableRegistry::class.java) + } + + @Test + fun `test with simple framework resource parsing`() { + val androidJar = findAndroidJar() + val registry = ResourceTableRegistry.getInstance() + val resourceTable = registry.forResourceDir(File(androidJar.parentFile, "data/res")) + + assertThat(resourceTable).isNotNull() + + resourceTable.apply { + assertThat(this!!.packages).hasSize(1) + this.packages.first().apply { + assertThat(this.name).isEqualTo("") + } + } + + resourceTable!!.findResource(ResourceName(pck = "", type = STRING, entry = "ok")).apply { + assertThat(this).isNotNull() + assertThat(this!!.entry).isNotNull() + assertThat(this.entry.values).isNotEmpty() + this.entry.values.firstOrNull().apply { + assertThat(this).isNotNull() + assertThat(this!!.value).isNotNull() + this.value.apply { + assertThat(this).isInstanceOf(BasicString::class.java) + assertThat(this.toString()).isEqualTo("OK") + } + } + } + + resourceTable.findResource(ResourceName(pck = "", type = STRING, entry = "cancel")).apply { + assertThat(this).isNotNull() + assertThat(this!!.entry).isNotNull() + assertThat(this.entry.values).isNotEmpty() + this.entry.values.firstOrNull().apply { + assertThat(this).isNotNull() + assertThat(this!!.value).isNotNull() + this.value.apply { + assertThat(this).isInstanceOf(BasicString::class.java) + assertThat(this.toString()).isEqualTo("Cancel") + } + } + } + + resourceTable + .findResource(ResourceName(pck = "", type = COLOR, entry = "holo_red_dark")) + .apply { + assertThat(this).isNotNull() + assertThat(this!!.entry).isNotNull() + assertThat(this.entry.values).isNotEmpty() + this.entry.values.firstOrNull().apply { + assertThat(this).isNotNull() + assertThat(this!!.value).isNotNull() + this.value.apply { + assertThat(this).isNotNull() + assertThat(this!!).isInstanceOf(BinaryPrimitive::class.java) + (this as BinaryPrimitive).resValue.apply { + assertThat(this).isNotNull() + assertThat(this.dataType).isEqualTo(DataType.INT_COLOR_ARGB8) + assertThat(this.data) + .isEqualTo(Color.parseColor(/*from colors_holo.xml*/ "#ffcc0000")) + } + } + } + } + } + + private fun findAndroidJar(): File { + val androidHome = findAndroidHome() + return run { + for (platform in intArrayOf(33, 32, 31)) { + val f = File(androidHome, "platforms/android-$platform/android.jar") + if (f.exists() && !f.isDirectory) { + return@run f + } + } + + throw RuntimeException("Cannot find android.jar") + } + } + + private fun findAndroidHome(): String { + var androidHome = System.getenv("ANDROID_HOME") + if (androidHome != null && androidHome.isNotBlank()) { + return androidHome + } + + androidHome = System.getenv("ANDROID_SDK_ROOT") + if (androidHome != null && androidHome.isNotBlank()) { + return androidHome + } + + val os = System.getProperty("os.name") + val home = System.getProperty("user.home") + return if (os.contains("Linux")) { + "$home/Android/Sdk" + } else { + "$home\\AppData\\Local\\Android\\Sdk" + } + } +} diff --git a/dependencies.gradle b/dependencies.gradle index 96e828cfd..3036f63e0 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -58,7 +58,15 @@ ext { guava_jre : 'com.google.guava:guava:31.1-jre', auto_val_annotations: 'com.google.auto.value:auto-value-annotations:1.9', auto_val_ap : 'com.google.auto.value:auto-value:1.9', - oss_licenses : 'com.google.android.gms:play-services-oss-licenses:17.0.0' + oss_licenses : 'com.google.android.gms:play-services-oss-licenses:17.0.0', + protobuf: 'com.google.protobuf:protobuf-java:3.10.0' + ] + + aapt = [ + common: 'com.android.tools:common:30.2.2', + annotations: 'com.android.tools:annotations:30.2.2', + jb_annotations: 'org.jetbrains:annotations:13.0', + proto: 'com.android.tools.build:aapt2-proto:7.2.2-7984345' ] xml = [ diff --git a/settings.gradle b/settings.gradle index 610df0d0e..910322c2f 100755 --- a/settings.gradle +++ b/settings.gradle @@ -40,3 +40,4 @@ include ':lookup' include ':build-tools:aaptcompiler' include ':build-tools:layoutlib-api' include ':build-tools:jaxp' +include ':build-tools:xml-utils' diff --git a/tests/test-home/.androidide/init/model.jar b/tests/test-home/.androidide/init/model.jar index bb8a095ddadb3d8c934aa9cbfa9e7ef3c139841e..8dc8ec55c34583fd5fb74d1e6e671be9e54de23f 100644 GIT binary patch delta 31 ncmZoU#@up@nJ2)TnT3mifrEqL?81#aZ?7_)UAX!8RZd<2oq-Ek delta 31 ncmZoU#@up@nJ2)TnT3mifrEn~zhfiM+pA3Z9h-k&<>Unblkf^_