Skip to content

Commit bb3b2b6

Browse files
authored
Merge pull request #71 from IBM/1.0.4
mvnw now looks for absolute path
2 parents 7d740b9 + 0925555 commit bb3b2b6

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.0.3
1+
version=1.0.4

src/main/java/com/ibm/cldk/CodeAnalyzer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class CodeAnalyzer implements Runnable {
7070
private static boolean noBuild = false;
7171

7272
@Option(names = {"-f", "--project-root-path"}, description = "Path to the root pom.xml file of the project.")
73-
private static String projectRootPom;
73+
public static String projectRootPom;
7474

7575
@Option(names = {"-a", "--analysis-level"}, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
7676
private static int analysisLevel = 1;
@@ -116,9 +116,7 @@ private static void analyze() throws Exception {
116116
Log.debug("Single file analysis.");
117117
Pair<Map<String, JavaCompilationUnit>, Map<String, List<Problem>>> symbolTableExtractionResult = SymbolTable.extractSingle(sourceAnalysis);
118118
symbolTable = symbolTableExtractionResult.getLeft();
119-
}
120-
121-
else {
119+
} else {
122120
// download library dependencies of project for type resolution
123121
String dependencies = null;
124122
if (BuildProject.downloadLibraryDependencies(input, projectRootPom)) {

src/main/java/com/ibm/cldk/utils/BuildProject.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.ibm.cldk.utils;
22

3+
import com.ibm.cldk.CodeAnalyzer;
4+
35
import java.io.BufferedReader;
46
import java.io.File;
57
import java.io.IOException;
@@ -10,15 +12,25 @@
1012
import java.util.Arrays;
1113
import java.util.List;
1214

13-
import static com.ibm.cldk.utils.ProjectDirectoryScanner.classFilesStream;
1415

16+
import static com.ibm.cldk.utils.ProjectDirectoryScanner.classFilesStream;
17+
import static com.ibm.cldk.CodeAnalyzer.projectRootPom;
1518
public class BuildProject {
1619

1720
public static Path libDownloadPath;
1821
private static final String LIB_DEPS_DOWNLOAD_DIR = "_library_dependencies";
19-
private static final String MAVEN_CMD = System.getProperty("os.name").toLowerCase().contains("windows")
20-
? (new File("mvnw.cmd").exists() ? "mvnw.cmd" : "mvn.cmd")
21-
: (new File("mvnw").exists() ? "mvnw" : "mvn");
22+
private static final String MAVEN_CMD = BuildProject.getMavenCommand();
23+
private static String getMavenCommand() {
24+
Boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
25+
String mvnCommand;
26+
if (isWindows) {
27+
mvnCommand = new File(projectRootPom, "mvnw.bat").exists() ? String.valueOf(new File(projectRootPom, "mvnw.bat")) : "mvn.bat";
28+
} else {
29+
mvnCommand = new File(projectRootPom, "mvnw").exists() ? String.valueOf(new File(projectRootPom, "mvnw")) : "mvn";
30+
}
31+
return mvnCommand;
32+
}
33+
2234
private static final String GRADLE_CMD = System.getProperty("os.name").toLowerCase().contains("windows") ? "gradlew.bat" : "gradlew";
2335
public static Path tempInitScript;
2436
static {
@@ -28,6 +40,7 @@ public class BuildProject {
2840
throw new RuntimeException(e);
2941
}
3042
}
43+
3144
private static final String GRADLE_DEPENDENCIES_TASK = "allprojects { afterEvaluate { project -> task downloadDependencies(type: Copy) {\n" +
3245
" def configs = project.configurations.findAll { it.canBeResolved }\n\n" +
3346
" dependsOn configs\n" +

0 commit comments

Comments
 (0)