1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16def standaloneProject = project(":jetifier-standalone")
17def jetifierBin = file("${standaloneProject.buildDir}/install/jetifier-standalone/bin/jetifier-standalone")
18
19task stripArchive(type: Zip) {
20    dependsOn tasks['createArchive']
21    from zipTree(project.tasks['createArchive'].archivePath)
22    destinationDir rootProject.buildDir
23    archiveName "stripped_archive.zip"
24    include "m2repository/androidx/annotation/**",
25            "m2repository/androidx/appcompat/**",
26            "m2repository/androidx/asynclayoutinflater/**",
27            "m2repository/androidx/browser/**",
28            "m2repository/androidx/car/**",
29            "m2repository/androidx/cardview/**",
30            "m2repository/androidx/collection/collection/**",
31            "m2repository/androidx/coordinatorlayout/**",
32            "m2repository/androidx/core/core/**",
33            "m2repository/androidx/cursoradapter/**",
34            "m2repository/androidx/customview/**",
35            "m2repository/androidx/documentfile/**",
36            "m2repository/androidx/drawerlayout/**",
37            "m2repository/androidx/dynamicanimation/**",
38            "m2repository/androidx/emoji/**",
39            "m2repository/androidx/exifinterface/**",
40            "m2repository/androidx/fragment/fragment/**",
41            "m2repository/androidx/gridlayout/**",
42            "m2repository/androidx/heifwriter/**",
43            "m2repository/androidx/interpolator/**",
44            "m2repository/androidx/leanback/**",
45            "m2repository/androidx/legacy/**",
46            "m2repository/androidx/loader/**",
47            "m2repository/androidx/localbroadcastmanager/**",
48            "m2repository/androidx/media/media/**",
49            "m2repository/androidx/mediarouter/**",
50            "m2repository/androidx/palette/palette/**",
51            "m2repository/androidx/percentlayout/**",
52            "m2repository/androidx/preference/**",
53            "m2repository/androidx/print/**",
54            "m2repository/androidx/recommendation/**",
55            "m2repository/androidx/recyclerview/**",
56            "m2repository/androidx/slice/**",
57            "m2repository/androidx/slidingpanelayout/**",
58            "m2repository/androidx/swiperefreshlayout/**",
59            "m2repository/androidx/transition/**",
60            "m2repository/androidx/tvprovider/**",
61            "m2repository/androidx/vectordrawable/**",
62            "m2repository/androidx/viewpager/**",
63            "m2repository/androidx/wear/**",
64            "m2repository/androidx/webkit/**"
65}
66
67task dejetifyArchive(type: Exec) {
68    description "Produces a zip of dejetified artifacts by running Dejetifier against refactored" +
69            " artifacts, for temporary usage by external clients that haven't upgraded to Jetpack" +
70            " yet."
71
72    dependsOn ':jetifier-standalone:installDist'
73    dependsOn project.tasks['stripArchive']
74    inputs.file project.tasks['stripArchive'].archivePath
75
76    outputs.file "${rootProject.ext.distDir}/top-of-tree-m2repository-dejetified-${project.ext.buildNumber}.zip"
77
78    commandLine (
79        "${jetifierBin}",
80        "-i", "${inputs.files.singleFile}",
81        "-o", "${outputs.files.singleFile}",
82        "--versions", "inDev",
83        "--log", "warning",
84        "--reversed",
85        "--rebuildTopOfTree"
86    )
87}
88