Skip to content

Commit

Permalink
Merge pull request #71 from IBM/1.0.4
Browse files Browse the repository at this point in the history
mvnw now looks for absolute path
  • Loading branch information
rahlk authored Nov 11, 2024
2 parents 7d740b9 + 0925555 commit bb3b2b6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.3
version=1.0.4
6 changes: 2 additions & 4 deletions src/main/java/com/ibm/cldk/CodeAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class CodeAnalyzer implements Runnable {
private static boolean noBuild = false;

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

@Option(names = {"-a", "--analysis-level"}, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
private static int analysisLevel = 1;
Expand Down Expand Up @@ -116,9 +116,7 @@ private static void analyze() throws Exception {
Log.debug("Single file analysis.");
Pair<Map<String, JavaCompilationUnit>, Map<String, List<Problem>>> symbolTableExtractionResult = SymbolTable.extractSingle(sourceAnalysis);
symbolTable = symbolTableExtractionResult.getLeft();
}

else {
} else {
// download library dependencies of project for type resolution
String dependencies = null;
if (BuildProject.downloadLibraryDependencies(input, projectRootPom)) {
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/com/ibm/cldk/utils/BuildProject.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ibm.cldk.utils;

import com.ibm.cldk.CodeAnalyzer;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
Expand All @@ -10,15 +12,25 @@
import java.util.Arrays;
import java.util.List;

import static com.ibm.cldk.utils.ProjectDirectoryScanner.classFilesStream;

import static com.ibm.cldk.utils.ProjectDirectoryScanner.classFilesStream;
import static com.ibm.cldk.CodeAnalyzer.projectRootPom;
public class BuildProject {

public static Path libDownloadPath;
private static final String LIB_DEPS_DOWNLOAD_DIR = "_library_dependencies";
private static final String MAVEN_CMD = System.getProperty("os.name").toLowerCase().contains("windows")
? (new File("mvnw.cmd").exists() ? "mvnw.cmd" : "mvn.cmd")
: (new File("mvnw").exists() ? "mvnw" : "mvn");
private static final String MAVEN_CMD = BuildProject.getMavenCommand();
private static String getMavenCommand() {
Boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
String mvnCommand;
if (isWindows) {
mvnCommand = new File(projectRootPom, "mvnw.bat").exists() ? String.valueOf(new File(projectRootPom, "mvnw.bat")) : "mvn.bat";
} else {
mvnCommand = new File(projectRootPom, "mvnw").exists() ? String.valueOf(new File(projectRootPom, "mvnw")) : "mvn";
}
return mvnCommand;
}

private static final String GRADLE_CMD = System.getProperty("os.name").toLowerCase().contains("windows") ? "gradlew.bat" : "gradlew";
public static Path tempInitScript;
static {
Expand All @@ -28,6 +40,7 @@ public class BuildProject {
throw new RuntimeException(e);
}
}

private static final String GRADLE_DEPENDENCIES_TASK = "allprojects { afterEvaluate { project -> task downloadDependencies(type: Copy) {\n" +
" def configs = project.configurations.findAll { it.canBeResolved }\n\n" +
" dependsOn configs\n" +
Expand Down

0 comments on commit bb3b2b6

Please sign in to comment.