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.build; 17 18 import com.android.tradefed.config.Option; 19 20 /** 21 * Utility meant to capture the usual build information arguments from a command line and create a 22 * {@link IBuildInfo} from them. We use this to create a placeholder build info in case of download 23 * issue while reporting the appropriate build number. 24 */ 25 public class CommandLineBuildInfoBuilder { 26 27 @Option(name = "build-id", description = "build id to supply.") 28 private String mBuildId = BuildInfo.UNKNOWN_BUILD_ID; 29 30 @Option(name = "branch", description = "build branch name to supply.") 31 private String mBranch = null; 32 33 @Option(name = "build-flavor", description = "build flavor name to supply.") 34 private String mBuildFlavor = null; 35 36 @Option(name = "build-os", description = "build os name to supply.") 37 private String mBuildOs = "linux"; 38 createBuild()39 public IBuildInfo createBuild() { 40 IBuildInfo build = 41 new BuildInfo(mBuildId, String.format("%s-%s-%s", mBranch, mBuildOs, mBuildFlavor)); 42 build.setBuildBranch(mBranch); 43 build.setBuildFlavor(mBuildFlavor); 44 return build; 45 } 46 } 47