• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package com.update.check.utils;
17 
18 import java.io.File;
19 
20 /**
21  * MyProjectHelper
22  *
23  * @since 23-04-07
24  */
25 public class MyProjectHelper {
26     /**
27      * isOpenHarmonyProject
28      *
29      * @param projectPath projectPath
30      * @return {@code true} if this project is OpenHarmony project, {@code false} otherwise
31      */
isOpenHarmonyProject(String projectPath)32     public static boolean isOpenHarmonyProject(String projectPath) {
33         if (projectPath == null) {
34             return false;
35         }
36         return isOpenHarmonyProject(new File(projectPath));
37     }
38 
39     /**
40      * isOpenHarmonyProject
41      *
42      * @param projectPath projectPath
43      * @return {@code true} if this project is OpenHarmony project, {@code false} otherwise
44      */
isOpenHarmonyProject(File projectPath)45     public static boolean isOpenHarmonyProject(File projectPath) {
46         if (projectPath == null) {
47             return false;
48         }
49 
50         if (!projectPath.exists()) {
51             return false;
52         }
53 
54         if (!projectPath.isDirectory()) {
55             return false;
56         }
57 
58         String sdkPath = FileUtils.getNodePath(projectPath.getPath(), "local.properties", "sdk.dir");
59         return sdkPath != null;
60     }
61 
62 }
63