Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression for Maven 3.8.2 in v2.9.0 #508

Merged
merged 3 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions protobuf-maven-plugin/src/it/protoc-descriptor-file/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<relativePath>../setup/pom.xml</relativePath>
</parent>

<groupId>path-protoc</groupId>
<artifactId>path-protoc</artifactId>
<groupId>protoc-descriptor-file</groupId>
<artifactId>protoc-descriptor-file</artifactId>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ public AbstractGenerateMojo() {
* defined in descriptor.proto) containing all the input files in
* {@code outputDescriptorFile}.</p>
*
* @since 2.8.1
* @since 2.9.0
*/
@Parameter
Path outputDescriptorFile;
@Nullable File outputDescriptorFile;

/**
* Override the directory to output generated code to.
Expand Down Expand Up @@ -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 {
Expand All @@ -841,6 +841,12 @@ private Set<String> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
}

Expand Down
Loading