Skip to content

Commit 1acec4a

Browse files
committed
Add root pom path to the CLI
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
2 parents 934a54f + bb56aca commit 1acec4a

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Codeanalyzer CI
33
on:
44
push:
55
branches:
6-
- GA
6+
- 1.X.X
77

88
permissions:
99
contents: write

gradle.properties

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ public class CodeAnalyzer implements Runnable {
7171

7272
@Option(names = {"-f", "--project-root-path"}, description = "Path to the root pom.xml file of the project.")
7373
private static String projectRootPom;
74-
75-
74+
7675
@Option(names = {"-a", "--analysis-level"}, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
7776
private static int analysisLevel = 1;
7877

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ public static List<Path> buildProjectAndStreamClassFiles(String projectPath, Str
155155
* @param projectPath Path to the project under analysis
156156
* @return true if dependency download succeeds; false otherwise
157157
*/
158-
public static boolean downloadLibraryDependencies(String projectPath) throws IOException {
158+
public static boolean downloadLibraryDependencies(String projectPath, String projectRootPom) throws IOException {
159159
// created download dir if it does not exist
160+
String projectRoot = projectRootPom != null ? projectRootPom : projectPath;
160161
libDownloadPath = Paths.get(projectPath, LIB_DEPS_DOWNLOAD_DIR).toAbsolutePath();
161162
if (!Files.exists(libDownloadPath)) {
162163
try {
@@ -166,20 +167,20 @@ public static boolean downloadLibraryDependencies(String projectPath) throws IOE
166167
return false;
167168
}
168169
}
169-
File pomFile = new File(projectPath, "pom.xml");
170+
File pomFile = new File(projectRoot, "pom.xml");
170171
if (pomFile.exists()) {
171172
Log.info("Found pom.xml in the project directory. Using Maven to download dependencies.");
172173
String[] mavenCommand = {
173174
MAVEN_CMD, "--no-transfer-progress", "-f",
174-
Paths.get(projectPath, "pom.xml").toString(),
175+
Paths.get(projectRoot, "pom.xml").toString(),
175176
"dependency:copy-dependencies",
176177
"-DoutputDirectory=" + libDownloadPath.toString()
177178
};
178179
return buildWithTool(mavenCommand);
179-
} else if (new File(projectPath, "build.gradle").exists() || new File(projectPath, "build.gradle.kts").exists()) {
180+
} else if (new File(projectRoot, "build.gradle").exists() || new File(projectRoot, "build.gradle.kts").exists()) {
180181
Log.info("Found build.gradle[.kts] in the project directory. Using Gradle to download dependencies.");
181182
tempInitScript = Files.writeString(tempInitScript, GRADLE_DEPENDENCIES_TASK);
182-
String[] gradleCommand = {projectPath + File.separator + GRADLE_CMD, "--init-script", tempInitScript.toFile().getAbsolutePath(), "downloadDependencies", "-PoutputDir="+libDownloadPath.toString()};
183+
String[] gradleCommand = {projectRoot + File.separator + GRADLE_CMD, "--init-script", tempInitScript.toFile().getAbsolutePath(), "downloadDependencies", "-PoutputDir="+libDownloadPath.toString()};
183184
System.out.println(Arrays.toString(gradleCommand));
184185
return buildWithTool(gradleCommand);
185186
}

0 commit comments

Comments
 (0)