Skip to content

Commit

Permalink
fix: protoc plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ngyewch committed Oct 2, 2024
1 parent 2fb772a commit 1b3da91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions java/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ plugins {
`java-gradle-plugin`
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.apache.commons:commons-lang3:3.17.0")
}

gradlePlugin {
plugins {
create("protocPlugin") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.File;
import javax.inject.Inject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
Expand Down Expand Up @@ -82,12 +84,16 @@ public void apply(Project project) {
taskName,
Exec.class,
task -> {
task.doFirst(
t -> {
outputExeFile.getParentFile().mkdirs();
});
task.doFirst(t -> outputExeFile.getParentFile().mkdirs());
task.getOutputs().file(outputExeFile);
task.commandLine("go", "build", "-o", outputExeFile, "../..");
final Object[] commandArgs =
new Object[] {"go", "build", "-o", outputExeFile, "../.."};
// task.commandLine(commandArgs);
if (SystemUtils.IS_OS_WINDOWS) {
task.commandLine("cmd", "/c", StringUtils.join(commandArgs, " "));
} else {
task.commandLine("/bin/sh", "-c", StringUtils.join(commandArgs, " "));
}
task.environment("GOOS", buildParameters.getGoos());
task.environment("GOARCH", buildParameters.getGoarch());
});
Expand Down

0 comments on commit 1b3da91

Please sign in to comment.