Last active
November 3, 2020 14:16
-
-
Save enriched/b0a685e124a2abff3ac92bf3a5e63630 to your computer and use it in GitHub Desktop.
Generate Eclipse project for Bazel workspace (works with vscode-java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
cd $(bazel info workspace) | |
WORKSPACE_NAME=$(basename $PWD) | |
cat << EOF > ./.project | |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<projectDescription> | |
<name>${WORKSPACE_NAME}</name> | |
<comment/> | |
<projects> | |
</projects> | |
<buildSpec> | |
<buildCommand> | |
<name>org.eclipse.jdt.core.javabuilder</name> | |
<arguments> | |
</arguments> | |
</buildCommand> | |
</buildSpec> | |
<natures> | |
<nature>org.eclipse.jdt.core.javanature</nature> | |
</natures> | |
</projectDescription> | |
EOF | |
JARS=$(find ./bazel-${WORKSPACE_NAME}/external/maven/v1 -iname '*.jar') | |
SRC_PATHS=$(find . -type d -path '*/src/main/java' -o -path '*/src/test/java') | |
cat << EOF > ./.classpath | |
<?xml version="1.0" encoding="UTF-8"?> | |
<classpath> | |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | |
$( for PATH in $SRC_PATHS; do echo " <classpathentry kind=\"src\" path=\"${PATH:2}\" />"; done; ) | |
<classpathentry kind="output" path="java-bin"/> | |
$( for JAR in $JARS; do echo " <classpathentry kind=\"lib\" path=\"${JAR:2}\" />"; done; ) | |
</classpath> | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made some changes here: https://gist.github.com/walles/581c50278fdf9d50a482104366aaa82e
Changes include:
.classpath
.classpath
After my changes I was able to successfully open https://github.com/bazelbuild/bazel-buildfarm in vscode.
If this was a project I'd make a PR, not sure how to work with Gists.
And really nice work Rich! Looks like you found the MIT advice :).