1 /* 2 * Copyright 2022 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 */ 16 17 package androidx.build.importMaven 18 19 import okio.Path 20 import okio.Path.Companion.toOkioPath 21 import java.io.File 22 import java.util.Properties 23 24 /** 25 * Helper class to laod some environment related configuration. 26 */ 27 object EnvironmentConfig { <lambda>null28 private val config: Properties by lazy { 29 val config = Properties() 30 val resourceName = "/importMavenConfig.properties" 31 EnvironmentConfig::class.java.getResource(resourceName).let { 32 checkNotNull(it) { 33 "Cannot find properties file: $resourceName" 34 } 35 }.openStream() 36 .use { 37 config.load(it) 38 } 39 config 40 } 41 42 /** 43 * The path for the support root folder (frameworks/support) 44 */ <lambda>null45 val supportRoot: Path by lazy { 46 checkNotNull(config["supportRoot"]) { 47 "missing supportRoot property" 48 }.let { 49 File(it.toString()).toOkioPath() 50 } 51 } 52 }