diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ced07e0..e8cf2aec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,7 +106,7 @@ jobs: - name: Build and test shell: bash - run: ./mvnw -B -Dcheckstyle.skip -Dlicense.skip verify + run: ./mvnw -B -Dcheckstyle.skip -Dlicense.skip clean verify - name: Publish code coverage uses: codecov/codecov-action@v4 diff --git a/protobuf-maven-plugin/src/it/protoc-descriptor-file/pom.xml b/protobuf-maven-plugin/src/it/protoc-descriptor-file/pom.xml index 71286ab4..2791ff2b 100644 --- a/protobuf-maven-plugin/src/it/protoc-descriptor-file/pom.xml +++ b/protobuf-maven-plugin/src/it/protoc-descriptor-file/pom.xml @@ -28,8 +28,8 @@ ../setup/pom.xml - path-protoc - path-protoc + protoc-descriptor-file + protoc-descriptor-file diff --git a/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojo.java b/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojo.java index 7126f182..741067fa 100644 --- a/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojo.java +++ b/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojo.java @@ -517,10 +517,10 @@ public AbstractGenerateMojo() { * defined in descriptor.proto) containing all the input files in * {@code outputDescriptorFile}.

* - * @since 2.8.1 + * @since 2.9.0 */ @Parameter - Path outputDescriptorFile; + @Nullable File outputDescriptorFile; /** * Override the directory to output generated code to. @@ -816,12 +816,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { .isIgnoreProjectDependencies(ignoreProjectDependencies) .isLiteEnabled(liteOnly) .isRegisterAsCompilationRoot(registerAsCompilationRoot) + .outputDescriptorFile(outputDescriptorFile()) .outputDirectory(outputDirectory()) .protocVersion(protocVersion()) .sourceDependencies(nonNullList(sourceDependencies)) .sourceRootRegistrar(sourceRootRegistrar()) .sourceRoots(sourceDirectories()) - .outputDescriptorFile(outputDescriptorFile) .build(); try { @@ -841,6 +841,12 @@ private Set dependencyScopes() { .orElseGet(this::defaultDependencyScopes); } + private @Nullable Path outputDescriptorFile() { + return Optional.ofNullable(outputDescriptorFile) + .map(File::toPath) + .orElse(null); + } + private Path outputDirectory() { return Optional.ofNullable(outputDirectory) .map(File::toPath) diff --git a/protobuf-maven-plugin/src/test/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojoTestTemplate.java b/protobuf-maven-plugin/src/test/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojoTestTemplate.java index 9c43e57e..a3fb9ed3 100644 --- a/protobuf-maven-plugin/src/test/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojoTestTemplate.java +++ b/protobuf-maven-plugin/src/test/java/io/github/ascopes/protobufmavenplugin/mojo/AbstractGenerateMojoTestTemplate.java @@ -891,9 +891,9 @@ class DescriptorFileTest { void whenDescriptorFileProvidedExpectProvidedDirectoryToBeUsed( @TempDir Path tempDir ) throws Throwable { - Path expectedDescriptorFile = Files.createFile(tempDir.resolve("protobin.desc")); + var expectedDescriptorFile = Files.createFile(tempDir.resolve("protobin.desc")); // Given - mojo.outputDescriptorFile = expectedDescriptorFile; + mojo.outputDescriptorFile = expectedDescriptorFile.toFile(); // When mojo.execute(); @@ -902,7 +902,8 @@ void whenDescriptorFileProvidedExpectProvidedDirectoryToBeUsed( var captor = ArgumentCaptor.forClass(GenerationRequest.class); verify(mojo.sourceCodeGenerator).generate(captor.capture()); var actualRequest = captor.getValue(); - assertThat(actualRequest.getOutputDescriptorFile()).isEqualTo(expectedDescriptorFile); + assertThat(actualRequest.getOutputDescriptorFile()) + .isEqualTo(expectedDescriptorFile); } }