blob: 0b790f5e4c683466a0eeed2d60f8a073334edb64 [file] [log] [blame] [view]
AndroidX Core Team2e416b22020-12-03 22:58:07 +00001## AndroidX policies and processes
2
3This document is intended to describe release policies that affect the workflow
4of an engineer developing within the AndroidX libraries. It also describes the
5process followed by a release engineer or TPM to take a development branch and
6publish it as a release on Google Maven.
7
8Policies and processes automated via tooling are noted in
9<span style="color:#bf9000;">yellow</span>.
10
11[TOC]
12
13## Project directory structure {#directory-structure}
14
15Libraries developed in AndroidX follow a consistent project naming and directory
16structure.
17
18Library groups should organize their modules into directories and module names
19(in brackets) as:
20
21```
22<feature-name>/
23 <feature-name>-<sub-feature>/ [<feature-name>:<feature-name>-<sub-feature>]
AndroidX Core Team43201242021-01-26 21:38:01 +000024 samples/ [<feature-name>:<feature-name>-<sub-feature>:samples]
AndroidX Core Team2e416b22020-12-03 22:58:07 +000025 integration-tests/
26 testapp/ [<feature-name>:testapp]
27 testlib/ [<feature-name>:testlib]
AndroidX Core Team2e416b22020-12-03 22:58:07 +000028```
29
AndroidX Core Team95cd3da2021-01-14 11:47:43 -050030For example, the `navigation` library group's directory structure is:
AndroidX Core Team2e416b22020-12-03 22:58:07 +000031
32```
AndroidX Core Team95cd3da2021-01-14 11:47:43 -050033navigation/
34 navigation-benchmark/ [navigation:navigation-benchmark]
AndroidX Core Team2e416b22020-12-03 22:58:07 +000035 ...
AndroidX Core Team95cd3da2021-01-14 11:47:43 -050036 navigation-ui/ [navigation:navigation-ui]
37 navigation-ui-ktx/ [navigation:navigation-ui-ktx]
AndroidX Core Team2e416b22020-12-03 22:58:07 +000038 integration-tests/
AndroidX Core Team95cd3da2021-01-14 11:47:43 -050039 testapp/ [navigation:integration-tests:testapp]
AndroidX Core Team2e416b22020-12-03 22:58:07 +000040```
41
42## Terminology {#terminology}
43
44**Artifact**
45: Previously referred to as "a Support Library library." A library --
46 typically Java or Android -- that maps to a single Maven artifact, ex.
47 `androidx.recyclerview:recyclerview`. An artifact is associated with a
48 single Android Studio module and a directory containing a `build.gradle`
49 configuration, resources, and source code.
50
51**API Council**
52: A committee that reviews Android APIs, both platform and library, to ensure
53 they are consistent and follow the best-practices defined in our API
54 guidelines.
55
56**Semantic Versioning (SemVer)**
57: A versioning standard developed by one of the co-founders of GitHub that is
58 understood by common dependency management systems, including Maven. In this
59 document, we are referring specifically to
60 [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
61
62## Managing versions {#managing-versions}
63
64This section outlines the steps for a variety of common versioning-related
65tasks. Artifact versions should **only** be modified by their owners as
66specified in the artifact directory's `OWNERS` file.
67
68Artifact versions are specified in
AndroidX Core Team408c27b2020-12-15 15:57:00 +000069[`LibraryVersions.kt`](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt).
AndroidX Core Team2e416b22020-12-03 22:58:07 +000070Versions are bound to your artifact in the `supportLibrary` block in your
71artifact's `build.gradle` file. The `Version` class validates the version string
72at build time.
73
74In the
AndroidX Core Team408c27b2020-12-15 15:57:00 +000075[`LibraryVersions.kt`](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt)
AndroidX Core Team2e416b22020-12-03 22:58:07 +000076file:
77
78```
79object LibraryVersions {
80 val SNAZZY_ARTIFACT = Version("1.1.0-alpha03")
81}
82```
83
84In your artifact's `build.gradle` file:
85
86```
87import androidx.build.LibraryVersions
88
89supportLibrary {
90 mavenVersion = LibraryVersions.SNAZZY_ARTIFACT
91}
92```
93
94#### Finalizing for release {#finalizing-for-release}
95
96When the artifact is ready for release, its versioned API file should be
97finalized to ensure that the subsequent versioned release conforms to the
98versioning policies.
99
100```
101./gradlew <module>:finalizeApi
102```
103
104This will prevent any subsequent changes to the API surface until the artifact
105version is updated. To update the artifact version and allow changes within the
106semantic versioning contract, simply update the version string in the artifact's
107`build.gradle` (see [Workflow](#workflow) introduction).
108
109To avoid breaking the development workflow, we recommend that API finalization
110and version string updates be submitted as a single CL.
111
112## Dependencies {#dependencies}
113
114Artifacts may depend on other artifacts within AndroidX as well as sanctioned
115third-party libraries.
116
117### Versioned artifacts {#versioned-artifacts}
118
119One of the most difficult aspects of independently-versioned releases is
120maintaining compatibility with public artifacts. In a mono repo such as Google's
121repository or Android Git at master revision, it's easy for an artifact to
122accidentally gain a dependency on a feature that may not be released on the same
123schedule.
124
125#### Pre-release dependencies {#pre-release-dependencies}
126
127Pre-release suffixes **must** propagate up the dependency tree. For example, if
128your artifact has API-type dependencies on pre-release artifacts, ex.
129`1.1.0-alpha01`, then your artifact must also carry the `alpha` suffix. If you
130only have implementation-type dependencies, your artifact may carry either the
131`alpha` or `beta` suffix.
132
133#### Pinned versions {#pinned-versions}
134
135To avoid issues with dependency versioning, consider pinning your artifact's
136dependencies to the oldest version (available via local `maven_repo` or Google
137Maven) that satisfies the artifact's API requirements. This will ensure that the
138artifact's release schedule is not accidentally tied to that of another artifact
139and will allow developers to use older libraries if desired.
140
141```
142dependencies {
143 api("androidx.collection:collection:1.0.0")
144 ...
145}
146```
147
148Artifacts should be built and tested against both pinned and tip-of-tree
149versions of their dependencies to ensure behavioral compatibility.
150
151#### Non-Pinned versions {#nonpinned-versions}
152
153Below is an example of a non-pinned dependency. It ties the artifact's release
154schedule to that of the dependency artifact, because the dependency will need to
155be released at the same time.
156
157```
158dependencies {
159 api(project(":collection"))
160 ...
161}
162```
163
164### Non-public APIs {#non-public-apis}
165
166Artifacts may depend on non-public (e.g. `@hide`) APIs exposed within their own
167artifact or another artifact in the same `groupId`; however, cross-artifact
168usages are subject to binary compatibility guarantees and
169`@RestrictTo(Scope.LIBRARY_GROUP)` APIs must be tracked like public APIs.
170
171```
172Dependency versioning policies are enforced at build time in the createArchive task. This task will ensure that pre-release version suffixes are propagated appropriately.
173
174Cross-artifact API usage policies are enforced by the checkApi and checkApiRelease tasks (see Life of a release).
175```
176
177### Third-party libraries {#third-party-libraries}
178
179Artifacts may depend on libraries developed outside of AndroidX; however, they
180must conform to the following guidelines:
181
182* Prebuilt **must** be checked into Android Git with both Maven and Make
183 artifacts
184 * `prebuilts/maven_repo` is recommended if this dependency is only
185 intended for use with AndroidX artifacts, otherwise please use
186 `external`
187* Prebuilt directory **must** contains an OWNERS file identifying one or more
188 individual owners (e.g. NOT a group alias)
189* Library **must** be approved by legal