|
21 | 21 | import com.google.gson.reflect.TypeToken;
|
22 | 22 | import com.samsungsds.analyst.code.main.CacheUtils;
|
23 | 23 | import com.samsungsds.analyst.code.main.MeasuredResult;
|
| 24 | +import com.samsungsds.analyst.code.main.Version; |
24 | 25 | import com.samsungsds.analyst.code.pmd.ComplexityAnalysis;
|
25 | 26 | import com.samsungsds.analyst.code.pmd.ComplexityResult;
|
26 | 27 | import com.samsungsds.analyst.code.python.PythonRuntime;
|
@@ -65,18 +66,46 @@ public void addOption(String option, String value) {
|
65 | 66 | public void run(String instanceKey) {
|
66 | 67 | String python = checkPythonVersionAndGetPath();
|
67 | 68 |
|
68 |
| - File tmpDir = saveRadonPackageWheels(instanceKey); |
| 69 | + if (haveCachedRadon()) { |
| 70 | + File virtualEnvDir = new File(IOAndFileUtils.mkdirCacheDir(), "radon-" + Version.CODE_ANALYST + File.separator + "radon"); |
| 71 | + LOGGER.info("Cached Radon Virtual Env. used : {}", virtualEnvDir.toString()); |
| 72 | + String resultJsonPath = runRadon(virtualEnvDir.getAbsolutePath()); |
69 | 73 |
|
70 |
| - String virtualEnvDir = makeVirtualEnv(python, tmpDir); |
| 74 | + LOGGER.debug("radon result : {}", resultJsonPath); |
| 75 | + processResult(resultJsonPath, instanceKey); |
| 76 | + } else { |
| 77 | + File tmpDir = saveRadonPackageWheels(instanceKey); |
| 78 | + |
| 79 | + String virtualEnvDir = makeVirtualEnv(python, tmpDir); |
| 80 | + |
| 81 | + installWheelPackages(tmpDir.getPath(), instanceKey); |
| 82 | + |
| 83 | + installRadonPackages(tmpDir.getPath()); |
| 84 | + |
| 85 | + String resultJsonPath = runRadon(virtualEnvDir); |
| 86 | + |
| 87 | + LOGGER.debug("radon result : {}", resultJsonPath); |
| 88 | + processResult(resultJsonPath, instanceKey); |
| 89 | + } |
| 90 | + } |
71 | 91 |
|
72 |
| - installWheelPackages(tmpDir.getPath(), instanceKey); |
| 92 | + private boolean haveCachedRadon() { |
| 93 | + if (System.getProperty("noCache", "false").equalsIgnoreCase("true")) { |
| 94 | + return false; |
| 95 | + } |
73 | 96 |
|
74 |
| - installRadonPackages(tmpDir.getPath()); |
| 97 | + File cacheDir = IOAndFileUtils.mkdirCacheDir(); |
75 | 98 |
|
76 |
| - String resultJsonPath = runRadon(virtualEnvDir); |
| 99 | + File radonExecuteFile; |
| 100 | + if (PythonRuntime.IS_MACOS || PythonRuntime.IS_LINUX) { |
| 101 | + radonExecuteFile = new File(cacheDir, |
| 102 | + "radon-" + Version.CODE_ANALYST + File.separator + "radon" + File.separator + "bin" + File.separator + "radon"); |
| 103 | + } else { |
| 104 | + radonExecuteFile = new File(cacheDir, |
| 105 | + "radon-" + Version.CODE_ANALYST + File.separator + "radon" + File.separator + "Scripts" + File.separator + "radon.exe"); |
| 106 | + } |
77 | 107 |
|
78 |
| - LOGGER.debug("radon result : {}", resultJsonPath); |
79 |
| - processResult(resultJsonPath, instanceKey); |
| 108 | + return radonExecuteFile.exists(); |
80 | 109 | }
|
81 | 110 |
|
82 | 111 | private String checkPythonVersionAndGetPath() {
|
|
0 commit comments