Skip to content

Commit

Permalink
remove maven support on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilou242 committed Jul 8, 2023
1 parent 02a019c commit 29e1f3a
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
*/
package tech.catheu.jnotebook.jshell;

import tech.catheu.jnotebook.Main;
import org.apache.commons.lang3.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tech.catheu.jnotebook.Main;
import tech.catheu.jnotebook.localstorage.LocalStorage;

import java.io.BufferedReader;
Expand All @@ -27,14 +26,15 @@
import java.util.Deque;
import java.util.List;

import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
import static tech.catheu.jnotebook.Main.SharedConfiguration.AUTO_CLASSPATH;

public class ShellProvider {

private static final Logger LOG = LoggerFactory.getLogger(ShellProvider.class);
private static final String MAVEN_PROJECT_FILE = "pom.xml";
private static final String MAVEN_WRAPPER_FILE =
SystemUtils.IS_OS_WINDOWS ? "mvnw.cmd" : "mvnw";
IS_OS_WINDOWS ? "mvnw.cmd" : "mvnw";
private static final String GRADLE_PROJECT_FILE = "build.gradle";
public static final String MAVEN_DEPENDENCY_COMMAND =
" -q exec:exec -Dexec.executable=echo -Dexec.args=\"%classpath\"";
Expand Down Expand Up @@ -79,19 +79,23 @@ private String getClassPath() {
if (!AUTO_CLASSPATH.equals(configuration.classPath)) {
resolvedClasspath = configuration.classPath;
} else if (new File(MAVEN_PROJECT_FILE).exists()) {
try {
LOG.info(
"Found a pom.xml file. Trying to add maven dependencies to the classpath...");
resolvedClasspath = computeMavenClasspath();
LOG.info("Maven dependencies added to the classpath successfully");
} catch (IOException | InterruptedException e) {
LOG.error("Failed resolving maven dependencies in pom.xml.", e);
resolvedClasspath = configuration.classPath;
if (IS_OS_WINDOWS) {
LOG.error(
"Found a pom.xml file. Cannot add maven dependencies automatically because this is not implemented on Windows. If you have a windows machine please contribute, it should be easy.");
} else {
try {
LOG.info(
"Found a pom.xml file. Trying to add maven dependencies to the classpath...");
resolvedClasspath = computeMavenClasspath();
LOG.info("Maven dependencies added to the classpath successfully");
} catch (IOException | InterruptedException e) {
LOG.error("Failed resolving maven dependencies in pom.xml.", e);
resolvedClasspath = configuration.classPath;
}
}
} else if (new File(GRADLE_PROJECT_FILE).exists()) {
LOG.warn(
"Automatic inclusion of classpath with gradle is not implemented. Use --class-path argument to pass manually.");
resolvedClasspath = configuration.classPath;
}

if (configuration.noUtils) {
Expand Down

0 comments on commit 29e1f3a

Please sign in to comment.