ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
เทมเพลตและรวมอยู่ในการกำหนดค่า XML ของ Tradefed
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การสร้างการกําหนดค่า XML แบบโมโนลิธิกรายการเดียวเพื่อกําหนดการทดสอบนั้นไม่เหมาะสําหรับการใช้งานจริงเสมอไป หากต้องการใช้การตั้งค่าบางส่วนซ้ำเพื่อทำการทดสอบที่คล้ายกัน คุณจะต้องคัดลอกและดูแลรักษาไฟล์ XML ขนาดใหญ่ 2 ไฟล์
แท็ก template
และ include
ในคำจำกัดความการกําหนดค่า XML ของ Tradefed จะมีประโยชน์ในกรณีนี้ ซึ่งช่วยให้คุณตั้งตัวยึดตําแหน่งในการกำหนดค่า 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
ที่ไม่บังคับ ช่องเริ่มต้นจะกำหนด XML การเปลี่ยนทดแทนเริ่มต้นที่ควรใช้
หากต้องการแทนที่เทมเพลตสําหรับการกําหนดค่าหนึ่งๆ คุณต้องเพิ่มพารามิเตอร์คําสั่งต่อไปนี้ลงในบรรทัดคําสั่ง
--template:map <name of template>=<replacement XML config path>
--template:map preparers=empty
เช่น
<template-include name="preparers" default="empty" />
ในกรณีนี้ การอ้างอิง empty
หมายถึงการกําหนดค่า empty.xml
ที่ไม่มีข้อมูลใดๆ เราใช้การอ้างอิงนี้เพื่อแทนที่ด้วย "ไม่มี"
เส้นทางของการกำหนดค่า XML อาจเป็นเส้นทางแบบสัมบูรณ์หรือแบบสัมพัทธ์กับโฟลเดอร์ res/config
ภายในทรัพยากร JAR ของ Tradefed ตัวอย่างสถานที่ตั้งมีดังนี้
- 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>
ไฟล์รวมจะใช้งานได้ง่ายกว่าเทมเพลตเนื่องจากไม่ต้องใช้อาร์กิวเมนต์บรรทัดคำสั่ง แต่จะขยาย XML ที่อ้างอิงในแท็ก name
โดยตรง เส้นทางไปยังการกําหนดค่าอาจเป็นแบบสัมบูรณ์หรือสัมพัทธ์ได้ เช่นเดียวกับเทมเพลต อย่างไรก็ตาม สำหรับ includes
เราขอแนะนำให้ใช้เฉพาะเส้นทางสัมพัทธ์เนื่องจากนำไปใช้ใน Tradefed ได้สะดวกกว่า
Absolute Path จะใช้ไม่ได้หากย้าย Tradefed ไปยังเครื่องอื่น
การกําหนดค่าที่ไม่ถูกต้อง
ในกรณีที่มีการกําหนดค่าไม่ถูกต้อง เช่น เมื่อไม่พบ XML เปลี่ยนทดแทน Tradefed จะแสดง ConfigurationException
พร้อมคําอธิบายสิ่งที่ดูเหมือนจะขาดหายไปหรือกําหนดค่าไม่ถูกต้อง
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-09-09 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-09-09 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."]]