1*f585d8a3SJacky Wang# Copyright (C) 2020 The Dagger Authors. 2*f585d8a3SJacky Wang# 3*f585d8a3SJacky Wang# Licensed under the Apache License, Version 2.0 (the "License"); 4*f585d8a3SJacky Wang# you may not use this file except in compliance with the License. 5*f585d8a3SJacky Wang# You may obtain a copy of the License at 6*f585d8a3SJacky Wang# 7*f585d8a3SJacky Wang# http://www.apache.org/licenses/LICENSE-2.0 8*f585d8a3SJacky Wang# 9*f585d8a3SJacky Wang# Unless required by applicable law or agreed to in writing, software 10*f585d8a3SJacky Wang# distributed under the License is distributed on an "AS IS" BASIS, 11*f585d8a3SJacky Wang# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*f585d8a3SJacky Wang# See the License for the specific language governing permissions and 13*f585d8a3SJacky Wang# limitations under the License. 14*f585d8a3SJacky Wang 15*f585d8a3SJacky Wang"""Macro for producing dejetified artifacts. 16*f585d8a3SJacky Wang""" 17*f585d8a3SJacky Wang 18*f585d8a3SJacky Wang# See: https://developer.android.com/studio/command-line/jetifier 19*f585d8a3SJacky WangJETIFIER_STANDALONE = "https://dl.google.com/dl/android/studio/jetifier-zips/1.0.0-beta08/jetifier-standalone.zip" 20*f585d8a3SJacky Wang 21*f585d8a3SJacky Wangdef dejetified_library(name, input, output): 22*f585d8a3SJacky Wang _dejetify_library(name, input, output) 23*f585d8a3SJacky Wang 24*f585d8a3SJacky Wangdef _dejetify_library(name, input, output): 25*f585d8a3SJacky Wang """Generates a dejetified library artifact. 26*f585d8a3SJacky Wang 27*f585d8a3SJacky Wang A dejetified artifact is one that has been transformed to migrate its 28*f585d8a3SJacky Wang AndroidX APIs to the support equivalents. 29*f585d8a3SJacky Wang 30*f585d8a3SJacky Wang Args: 31*f585d8a3SJacky Wang name: The name of the target. 32*f585d8a3SJacky Wang input: The android_library input, e.g. ":myLibrary.aar". 33*f585d8a3SJacky Wang output: The name of the output artifact, e.g. "dejetified-myLibrary.aar". 34*f585d8a3SJacky Wang """ 35*f585d8a3SJacky Wang native.genrule( 36*f585d8a3SJacky Wang name = name, 37*f585d8a3SJacky Wang srcs = [input], 38*f585d8a3SJacky Wang outs = [output], 39*f585d8a3SJacky Wang cmd = """ 40*f585d8a3SJacky Wang TEMP="$$(mktemp -d)" 41*f585d8a3SJacky Wang curl {tool_link} --output $$TEMP/jetifier-standalone.zip 42*f585d8a3SJacky Wang unzip $$TEMP/jetifier-standalone.zip -d $$TEMP/ 43*f585d8a3SJacky Wang $$TEMP/jetifier-standalone/bin/jetifier-standalone -r \ 44*f585d8a3SJacky Wang -l info -i $< -o $@ 45*f585d8a3SJacky Wang """.format(tool_link = JETIFIER_STANDALONE), 46*f585d8a3SJacky Wang local = 1, 47*f585d8a3SJacky Wang ) 48