You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "mensinda (via GitHub)" <gi...@apache.org> on 2025/03/11 10:15:09 UTC
[PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
mensinda opened a new pull request, #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312
This is a followup for for #191 to add the generatedSourcesPath back to the maven project paths as the final step of the mojo.
This is an *alternative* implementation to #311.
---
Following this checklist to help us incorporate your
contribution quickly and easily:
- [x] Your pull request should address just one issue, without pulling in other changes.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Each commit in the pull request should have a meaningful subject line and body.
Note that commits might be squashed by a maintainer on merge.
- [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
This may not always be possible but is a best-practice.
- [x] Run `mvn verify` to make sure basic checks pass.
A more thorough check will be performed on your pull request automatically.
- [x] You have run the integration tests successfully (`mvn -Prun-its verify`).
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312#discussion_r1993183887
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -703,8 +703,39 @@ protected final Optional<Path> getModuleDeclaration(final Set<File> sourceFiles)
private boolean targetOrReleaseSet;
@Override
- @SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, CompilationFailureException {
+ try {
+ executeReal();
+ } finally {
+ addGeneratedSourcesToProject();
+ }
Review Comment:
ok, can stays
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312#discussion_r1993035074
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -703,8 +703,39 @@ protected final Optional<Path> getModuleDeclaration(final Set<File> sourceFiles)
private boolean targetOrReleaseSet;
@Override
- @SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, CompilationFailureException {
+ try {
+ executeReal();
+ } finally {
+ addGeneratedSourcesToProject();
+ }
Review Comment:
I'm not sure if finally is needed ... if something wrong in first method whole Maven build will be broken anymore
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "mensinda (via GitHub)" <gi...@apache.org>.
mensinda commented on code in PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312#discussion_r1993141044
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -703,8 +703,39 @@ protected final Optional<Path> getModuleDeclaration(final Set<File> sourceFiles)
private boolean targetOrReleaseSet;
@Override
- @SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, CompilationFailureException {
+ try {
+ executeReal();
+ } finally {
+ addGeneratedSourcesToProject();
+ }
Review Comment:
Yes and no: I agree that the `try / finally` is not required for most circumstances (regular `mvn clean compile`, etc.). However, maven also has the `--fail-at-end` and `--fail-never` flags. In this case, the try finally could make sense.
So, just to be on the safe side to not change the original behavior, I would keep the `try / finally`. However, I am also open to removing it, if you would prefer it that way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "oehme (via GitHub)" <gi...@apache.org>.
oehme commented on code in PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312#discussion_r1993248776
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -703,8 +703,39 @@ protected final Optional<Path> getModuleDeclaration(final Set<File> sourceFiles)
private boolean targetOrReleaseSet;
@Override
- @SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, CompilationFailureException {
+ try {
+ executeReal();
+ } finally {
+ addGeneratedSourcesToProject();
+ }
Review Comment:
Try-finally is necessary, because there are several `return` points in the method and doing a finally block is the easiest way to ensure this work gets done, no matter how these `return`s are shuffled around in the future. It actually has nothing to do with failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski merged PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "oehme (via GitHub)" <gi...@apache.org>.
oehme commented on PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312#issuecomment-2718643641
LGTM
@slawekjaranowski This fixes the problem I mentioned
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add generatedSourcesPath back to the maven project [maven-compiler-plugin]
Posted by "oehme (via GitHub)" <gi...@apache.org>.
oehme commented on code in PR #312:
URL: https://github.com/apache/maven-compiler-plugin/pull/312#discussion_r1993248776
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -703,8 +703,39 @@ protected final Optional<Path> getModuleDeclaration(final Set<File> sourceFiles)
private boolean targetOrReleaseSet;
@Override
- @SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, CompilationFailureException {
+ try {
+ executeReal();
+ } finally {
+ addGeneratedSourcesToProject();
+ }
Review Comment:
Try-finally is necessary, because there are several `return` points in the method and doing a finally block is the easiest way to ensure this work gets done, no matter how these `return`s are shuffled around in the future. It actually has nothing to do with failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org