1 /* 2 * Copyright (C) 2020 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 package com.android.tradefed.config.yaml; 17 18 import com.android.tradefed.build.DependenciesResolver; 19 import com.android.tradefed.config.Configuration; 20 import com.android.tradefed.config.OptionSetter; 21 import com.android.tradefed.log.FileLogger; 22 import com.android.tradefed.result.suite.SuiteResultReporter; 23 24 /** Loader for the default objects available in AOSP. */ 25 public class OpenObjectLoader implements IDefaultObjectLoader { 26 27 @Override addDefaultObjects(LoaderConfiguration loadConfiguration)28 public void addDefaultObjects(LoaderConfiguration loadConfiguration) { 29 // Only add the objects below if it's created as a stand alone configuration, in suite as 30 // a module, it will be resolving object from the top level suite. 31 if (loadConfiguration.createdAsModule()) { 32 return; 33 } 34 // Logger 35 loadConfiguration 36 .getConfigDef() 37 .addConfigObjectDef(Configuration.LOGGER_TYPE_NAME, FileLogger.class.getName()); 38 // Result Reporters 39 loadConfiguration 40 .getConfigDef() 41 .addConfigObjectDef( 42 Configuration.RESULT_REPORTER_TYPE_NAME, 43 SuiteResultReporter.class.getName()); 44 // Build 45 int classCount = 46 loadConfiguration 47 .getConfigDef() 48 .addConfigObjectDef( 49 Configuration.BUILD_PROVIDER_TYPE_NAME, 50 DependenciesResolver.class.getName()); 51 // Set all the dependencies on the provider 52 for (String depencency : loadConfiguration.getDependencies()) { 53 String optionName = 54 String.format( 55 "%s%c%d%c%s", 56 DependenciesResolver.class.getName(), 57 OptionSetter.NAMESPACE_SEPARATOR, 58 classCount, 59 OptionSetter.NAMESPACE_SEPARATOR, 60 "dependency"); 61 loadConfiguration 62 .getConfigDef() 63 .addOptionDef( 64 optionName, 65 null, 66 depencency, 67 loadConfiguration.getConfigDef().getName(), 68 Configuration.BUILD_PROVIDER_TYPE_NAME); 69 } 70 } 71 } 72