Skip to content

Commit

Permalink
Fix for release bug (#23)
Browse files Browse the repository at this point in the history
* Update DownloadMojo to pull protoc binary from maven central

* Code clean up

* Fix for maven release and also added support for gradle to use the plugin

* Update to use lastIndexOf to find protoc binary
  • Loading branch information
JckHoe authored Oct 12, 2023
1 parent 654b311 commit 801ca02
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.PrintWriter;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;

public class ProtoGenImpl implements ProtoGen {
private final CommandLineUtils.StringStreamConsumer error = new CommandLineUtils.StringStreamConsumer();
Expand Down Expand Up @@ -50,7 +51,17 @@ public void protocGenerate(Filer filer, List<ProtoFile> protoFiles) {
String outputDirectory = Paths.get(resource.toUri()).toFile().getParent();

// Retrieve the protoc executable
String protocExecutable = outputDirectory.substring(0, outputDirectory.indexOf("target")) + "target/protoc/bin/" + "protoc.exe";
// Index of build output (Maven & Gradle)
// For Maven
int index = outputDirectory.lastIndexOf("target");
String protocExecutable;
// If Index == -1 try for Gradle;
if (index < 0) {
index = outputDirectory.lastIndexOf("build");
protocExecutable = outputDirectory.substring(0, index) + "build/protoc/bin/" + "protoc.exe";
}else {
protocExecutable = outputDirectory.substring(0, index) + "target/protoc/bin/" + "protoc.exe";
}
File protocExeFile = new File(protocExecutable);
String executable = protocExeFile.exists() ? protocExecutable : "protoc";

Expand Down

0 comments on commit 801ca02

Please sign in to comment.