Skip to content

Commit

Permalink
Only call rlocation once (bazel-contrib#267)
Browse files Browse the repository at this point in the history
This leads to slightly faster runtime, and slightly less confusing error
messages if the file can't be found.
  • Loading branch information
illicitonion authored May 3, 2024
1 parent 2e6e068 commit 09685c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions java/gazelle/private/servermanager/servermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -93,11 +94,10 @@ func locateJavaparser() (string, error) {

// We want //java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators:Main
javaparserPath := "contrib_rules_jvm/java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators/Main"
loc, err := rf.Rlocation(javaparserPath)
if err != nil {
loc, err = rf.Rlocation(javaparserPath + ".exe")
if runtime.GOOS == "windows" {
javaparserPath += ".exe"
}

loc, err := rf.Rlocation(javaparserPath)
if err != nil {
return "", fmt.Errorf("failed to call RLocation: %w", err)
}
Expand Down

0 comments on commit 09685c3

Please sign in to comment.