自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
贡献非核心代码
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为了使向 tradefederation 项目贡献非核心 src 的团队能够完全掌控审核流程,我们创建了以下项目,这些项目向所有团队开放了两项以上的权限。这样会减轻核心 tradefederation 团队的负担,让他们免去与核心框架无关的所有代码审核工作,同时也让其他团队能够在审核周期内更快地迭代。
非核心 src 是指不是 tradefederation 框架正常运行所必需的代码(例如,自定义测试、配置和特定测试实用程序)。
重要提示:非核心 src 不得扩展核心 tradefederation 类。这样做会影响未来的重构/清理。如果您不确定您的代码是属于核心代码还是 contrib 代码,请与 android-tradefed@ 联系,让他们为您解释清楚。核心 tradefederation 团队很乐意为您提供建议和接收功能请求。
例如,com.google.android.tradefed.build
软件包中的任何类都是核心 tradefederation 类,如:com.google.android.tradefed.build.LaunchControlProvider
同样,如果您不清楚哪些类将被视为核心类,请与 android-tradefed@ 联系。
[TOC]
contrib 项目的路径
这些 contrib 项目的使用对象是谁?
如果您目前是编写测试/测试实用程序/配置的 tradefederation 项目组人员,那么这些 contrib 项目就是为您创建的。
contrib 项目中的代码审核
contrib 项目的目标是允许您在 Tradefed 中进行开发,而无需经过核心团队 (android-tradefed@) 的审核。因此,我们希望您的团队或任何熟悉您所处环境的人对您的 CL 执行代码审核。
如果您遇到难题或在特殊情况下需要指导,请随时与 android-tradefed@ 联系,而不要在默认情况下依赖它来执行 contrib 中的代码审核。对于 contrib 中的代码审核,Tradefed 团队未设定相应的 SLO。
我在哪里可以开始处理这些项目?
这些项目已添加到以下分支清单,并且已经是主平台签出的一部分,因此如果您没有在自己的环境中看到这些项目,那么说明您的代码库与贡献代码未同步。
- main
- tradefed
- oc-dev
- oc-dev-plus-aosp
- nyc-mr2-dev-plus-aosp
- main-daydream-dev
- main-without-vendor
- wear-main
开发和测试
在 contrib 中进行开发时,应与 Android 代码库中的其他任何位置达到相同的质量标准:
- 遵循 Android 格式设置准则
- 代码经过测试并与测试一起提交
- 设计经过深思熟虑且有意义
如何在 contrib 中进行本地测试?
AOSP
在 aosp 中,contrib 的单元测试位于 platform/tools/tradefederation/contrib/tests/src/,并且应将单元测试添加到 com.android.tradefed.prodtests.UnitTests,才会在提交前测试和本地测试脚本中提取它们。
运行 lunch 命令后的 aosp 本地脚本:
tools/tradefederation/core/tests/run_tradefed_aosp_presubmit.sh
contrib 项目的构建规则更新
build 规则 (makefile) 在它们自己的 build/
文件夹下,并且由 OWNERS
文件锁定,该文件将阻止您在未经核心团队额外审核的情况下修改这些规则。这是对 contrib 项目的唯一限制。
我们需要这一审核环节来确保在核心团队不知情或不同意的情况下,不会向整体 Tradefed 项目添加意外的依赖项。如果您确实需要添加一些新的依赖项,请与 android-tradefed@
联系,让他们调查您的用例并给出建议。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Contribute non-core code\n\nTo enable teams that contribute non-core src to the tradefederation projects\nfull ownership of the review process, the following projects have been created\nwith open +2 rights for all teams. This relieves the core tradefederation team\nfrom the burden of all code reviews un-related to the core framework while also\nallowing the other teams to iterate faster in their review cycle.\n\n**Non-core src** is defined as code that is not required by the tradefederation\nframework to be functional (e.g. custom tests, configs, specific test\nutilities).\n\u003e ***IMPORTANT*** Non-core src should not extend core tradefederation classes.\n\u003e Doing so impacts future refactoring/clean up. If you are unsure if your code\n\u003e belongs in core or contrib, reach out to android-tradefed@ for clarification.\n\u003e The core tradefederation team is happy to advise and receive feature requests.\n\u003e\n\u003e An example core tradefederation class would be any class in the\n\u003e `com.google.android.tradefed.build` package like:\n\u003e `com.google.android.tradefed.build.LaunchControlProvider`\n\u003e\n\u003e Again, please reach out if you are unclear what would be considered a core\n\u003e class to android-tradefed@.\n\n\\[TOC\\]\n\nContrib projects' paths\n-----------------------\n\n- [platform/tools/tradefederation/contrib](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/main)\n\nWho are these contrib projects for?\n-----------------------------------\n\nIf you currently work in the tradefederation projects writing tests/test\nutilities/configs, these projects were created for you.\n\nCode reviews in contrib projects\n--------------------------------\n\nThe goal of the contrib projects is to allow you to do development in Tradefed\nwithout needing the review of the core team (android-tradefed@). So we expect\nyour team or anybody familiar with your context to perform the code reviews on\nyour CLs.\n\nAlways feel free to reach out to android-tradefed@ if stuck or need guidance on\na particular case, but do not rely on it by default to do your code review in\ncontrib. **Tradefed team has no SLO when it comes to code reviews in contrib.**\n\nWhere can I start working on these projects?\n--------------------------------------------\n\nThey have been added to the following branch manifests and are already part of\nmain platform checkout so if you don't see the projects in your environment,\nyou're a repo sync away from contributing.\n\n- main\n- tradefed\n- oc-dev\n- oc-dev-plus-aosp\n- nyc-mr2-dev-plus-aosp\n- main-daydream-dev\n- main-without-vendor\n- wear-main\n\nDevelopment and testing\n-----------------------\n\nDevelopment in contrib is expected to have the same quality bar as anywhere else\nin the Android repositories:\n\n- Respect the Android formatting guidelines\n- Code is tested and submitted with tests\n- Design is thoughtful and makes sense\n\n### How do I test locally in contrib?\n\n#### AOSP\n\nIn aosp, unit tests of contrib are located in\n[platform/tools/tradefederation/contrib/tests/src/](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/android16-release/tests/src/com/android)\nand unit tests should be added to\n[com.android.tradefed.prodtests.UnitTests](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/android16-release/tests/src/com/android/tradefed/prodtests/UnitTests.java)\nto be picked up in presubmit and local testing scripts.\n\nAosp local scripts after running lunch: \n\n tools/tradefederation/core/tests/run_tradefed_aosp_presubmit.sh\n\nBuild rules update to contrib projects\n--------------------------------------\n\nThe build rules (makefiles) are under their own `build/` folder and locked by an\n`OWNERS` file that will prevent your from modifying them without an extra review\nfrom the core team. This is the only limitation to the contrib project.\n\nWe need this review to ensure no unexpected dependencies are added to the\noverall Tradefed projects without the knowledge or agreement from the core team.\nIf you really need some new dependencies to be added, please contact\n`android-tradefed@` to look into your use cases and advise you."]]