Skip to content

Commit 1ad2b92

Browse files
committed
Fix issue #83
Signed-off-by: Rahul Krishna <[email protected]>
1 parent cb285fa commit 1ad2b92

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

gradle.properties

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

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import static com.ibm.cldk.utils.ProjectDirectoryScanner.classFilesStream;
1818
import static com.ibm.cldk.CodeAnalyzer.projectRootPom;
19-
public class BuildProject {
2019

20+
public class BuildProject {
2121
public static Path libDownloadPath;
2222
private static final String LIB_DEPS_DOWNLOAD_DIR = "_library_dependencies";
2323
private static final String MAVEN_CMD = BuildProject.getMavenCommand();
@@ -55,10 +55,8 @@ private static String getGradleCmd() {
5555

5656
if (new File(projectRootPom, gradleWrapper).exists()) {
5757
GRADLE_CMD = gradleWrapper;
58-
} else if (commandExists(gradle)) {
59-
GRADLE_CMD = gradle;
6058
} else {
61-
throw new IllegalStateException("Could not file a valid gradle command. I did not find " + gradleWrapper + " or " + gradle + " in the project directory or in the system PATH.");
59+
GRADLE_CMD = gradle;
6260
}
6361
return GRADLE_CMD;
6462
}
@@ -229,6 +227,9 @@ public static boolean downloadLibraryDependencies(String projectPath, String pro
229227
File pomFile = new File(projectRoot, "pom.xml");
230228
if (pomFile.exists()) {
231229
Log.info("Found pom.xml in the project directory. Using Maven to download dependencies.");
230+
if (!commandExists(MAVEN_CMD))
231+
throw new IllegalStateException("Could not find a valid maven command. I did not find " + MAVEN_CMD + " in the project directory or in the system PATH.");
232+
232233
String[] mavenCommand = {
233234
MAVEN_CMD, "--no-transfer-progress", "-f",
234235
Paths.get(projectRoot, "pom.xml").toString(),
@@ -237,6 +238,10 @@ public static boolean downloadLibraryDependencies(String projectPath, String pro
237238
};
238239
return buildWithTool(mavenCommand);
239240
} else if (new File(projectRoot, "build.gradle").exists() || new File(projectRoot, "build.gradle.kts").exists()) {
241+
Log.info("Found build.gradle or build.gradle.kts in the project directory. Using gradle to download dependencies.");
242+
if (!commandExists(GRADLE_CMD))
243+
throw new IllegalStateException("Could not find a valid Gradle command. I did not find " + GRADLE_CMD + " in the project directory or in the system PATH.");
244+
240245
Log.info("Found build.gradle[.kts] in the project directory. Using Gradle to download dependencies.");
241246
tempInitScript = Files.writeString(tempInitScript, GRADLE_DEPENDENCIES_TASK);
242247
String[] gradleCommand;
@@ -246,8 +251,6 @@ public static boolean downloadLibraryDependencies(String projectPath, String pro
246251
else {
247252
gradleCommand = new String[]{GRADLE_CMD, "--init-script", tempInitScript.toFile().getAbsolutePath(), "downloadDependencies", "-PoutputDir=" + libDownloadPath.toString()};
248253
}
249-
250-
System.out.println(Arrays.toString(gradleCommand));
251254
return buildWithTool(gradleCommand);
252255
}
253256
return false;

0 commit comments

Comments
 (0)