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