2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
Tradefed XML 構成のテンプレートとインクルード
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
1 つのモノリシック XML 構成を作成してテストを定義することは、必ずしも現実的ではありません。セットアップの一部を再利用して同様のテストを実行する場合は、2 つの大きな XML ファイルをコピーして維持しなければなりません。
ここで Tradefed XML 構成定義の template
タグと include
タグが役立ちます。ある XML 構成でプレースホルダを設定して、別の XML 構成の一部を追加できます。
テンプレートの定義の例
<configuration description="Common base configuration for local runs with minimum overhead">
<build_provider class="com.android.tradefed.build.BootstrapBuildProvider" />
<template-include name="preparers" default="empty" />
<template-include name="test" default="empty" />
<template-include name="reporters" default="empty" />
</configuration>
テンプレートは、参照する name
とオプションの default
フィールドを持つプレースホルダです。default フィールドは、使用するデフォルトの置換 XML を定義します。
特定の構成のテンプレートを置き換えるには、次のコマンド パラメータをコマンドラインに追加する必要があります。
--template:map <name of template>=<replacement XML config path>
--template:map preparers=empty
例:
<template-include name="preparers" default="empty" />
この場合の empty
参照は、何も含まない empty.xml
構成を参照します。つまり、何も置き換えない場合の参照です。
XML 構成のパスは、Tradefed の JAR リソース内にある res/config
フォルダに対する相対パスまたは絶対パスを指定できます。それらの場所をいくつか示します。
- tools/tradefederation/core/res/config
- tools/tradefederation/core/tests/res/config
- tools/tradedeferation/contrib/res/config
インクルードの定義の例
<configuration description="Common base configuration for local runs with minimum overhead">
<build_provider class="com.android.tradefed.build.BootstrapBuildProvider" />
<include name="empty"/>
</configuration>
インクルードは、コマンドライン引数を必要としないためテンプレートよりもシンプルであり、name
タグで参照される XML を直接展開します。テンプレートと同様に、構成へのパスは絶対パスまたは相対パスを指定できます。それでも、移植性が高いため、includes
では相対パスのみを使用することをおすすめします。Tradefed を別のマシンに移動すると、絶対パスは無効になります。
構成ミス
置換する XML が見つからない場合など、構成が誤っている場合は、考えられる欠落または構成の誤りに関する説明とともに ConfigurationException
がスローされます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-28 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-28 UTC。"],[],[],null,["Creating one monolithic XML configuration to define a test is not always\npractical. If you want to re-use part of the setup to run similar tests, you\nwould be forced to copy and maintain two giant XML files.\n\nThis is where `template` and `include` tags in Tradefed XML Configuration\ndefinition come in handy. They allow you to set placeholders in some XML\nconfiguration to add part of another XML configuration.\n\nExample definition for templates \n\n \u003cconfiguration description=\"Common base configuration for local runs with minimum overhead\"\u003e\n \u003cbuild_provider class=\"com.android.tradefed.build.BootstrapBuildProvider\" /\u003e\n\n \u003ctemplate-include name=\"preparers\" default=\"empty\" /\u003e\n\n \u003ctemplate-include name=\"test\" default=\"empty\" /\u003e\n\n \u003ctemplate-include name=\"reporters\" default=\"empty\" /\u003e\n \u003c/configuration\u003e\n\nTemplates are placeholders with a `name` to reference them, and an optional\n`default` field. The default field defines the default replacement XML that\nshould be used.\n\nIn order to replace a template for a given configuration, the following command\nparameter needs to be added to the command line: \n\n --template:map \u003cname of template\u003e=\u003creplacement XML config path\u003e\n\n --template:map preparers=empty\n\nFor example: \n\n \u003ctemplate-include name=\"preparers\" default\u003e=\"empty\" /\n\nThe `empty` reference in this case refers to the `empty.xml` configuration that\ncontains nothing; we use it as our reference to *replace with nothing*.\n\nThe path of XML configs can be absolute or relative to the `res/config` folder\ninside Tradefed's JAR resources. Here are a few of their locations:\n\n- tools/tradefederation/core/res/config\n- tools/tradefederation/core/tests/res/config\n- tools/tradedeferation/contrib/res/config\n\nExample definition of includes \n\n \u003cconfiguration description=\"Common base configuration for local runs with minimum over\u003ehead&\u003cquot;\n build_provider class=\"com.android.tradefed.build.BootstrapB\u003euildPr\u003covider\" /\n\n i\u003en\u003cclude name=&qu\u003eot;empty\"/\n /configuration\n\nIncludes are simpler than Templates as they require no command line arguments;\nthey directly expand the referenced XML in the `name` tag. Similar to templates,\nthe path to the config can be absolute or relative. Still, for `includes` we\nrecommend using only relative paths as they are more portable in Tradefed.\nAbsolute paths would not be valid if Tradefed is moved to another machine.\n\nMisconfiguration\n\nIn case of misconfiguration, such as when the replacement XML cannot be found,\nTradefed will throw a `ConfigurationException` with description of what seems to\nbe missing or misconfigured."]]