diff --git a/src/main/resources/javac-interceptor.sh b/src/main/resources/javac-interceptor.sh new file mode 100755 index 00000000..0e5bf0f0 --- /dev/null +++ b/src/main/resources/javac-interceptor.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +if [ -z "$JAVAC_PATH" ]; then + if [ -z "$JAVA_HOME" ]; then + readonly JAVAC_PATH="$(command -v javac)" + else + readonly JAVAC_PATH="$JAVA_HOME/bin/javac" + fi +fi + +FILENAME=$@ + +CONTENTS=$(cat "${FILENAME#?}") + +BOOTCLASSPATH=$(echo "$CONTENTS" | grep -A 1 "\-bootclasspath") +echo "lsifjava $BOOTCLASSPATH" + +CLASSPATH=$(echo "$CONTENTS" | grep -A 1 "\-classpath") +echo "lsifjava $CLASSPATH" + +$JAVAC_PATH "$FILENAME" \ No newline at end of file diff --git a/src/main/resources/projectClasspathFinder.gradle b/src/main/resources/projectClasspathFinder.gradle index 4dbe1584..36e8d134 100644 --- a/src/main/resources/projectClasspathFinder.gradle +++ b/src/main/resources/projectClasspathFinder.gradle @@ -41,4 +41,11 @@ allprojects { project -> } } } + + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.fork = true + options.forkOptions.executable = '/home/noah/Sourcegraph/lsif-java/src/main/resources/javac-interceptor.sh' + } + } } \ No newline at end of file