Skip to content

Commit

Permalink
Skip execution if no sources are discovered
Browse files Browse the repository at this point in the history
Skip any execution if no sources are discovered, rather than erroring when
protoc is called.
  • Loading branch information
ascopes authored Jan 12, 2024
1 parent 6aa7034 commit 117cd17
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ public boolean generate(GenerationRequest request) throws ResolutionException, I
var plugins = discoverPlugins(request);
var importPaths = discoverImportPaths(request);
var sources = discoverCompilableSources(request);

if (sources.isEmpty()) {
// We might want to add the ability to throw an error here in the future.
// For now, let's just avoid doing additional work. This also prevents protobuf
// failing because we provided no sources to it.
log.info("No protobuf sources found; nothing to do!");
return true;

Check warning on line 81 in src/main/java/io/github/ascopes/protobufmavenplugin/generate/SourceCodeGenerator.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/io/github/ascopes/protobufmavenplugin/generate/SourceCodeGenerator.java#L80-L81

Added lines #L80 - L81 were not covered by tests
}

createOutputDirectories(request);

var argLineBuilder = new ArgLineBuilder(protocPath)
Expand Down

0 comments on commit 117cd17

Please sign in to comment.