Feature/add flag to ignore existing generated sources#1031
Feature/add flag to ignore existing generated sources#1031nkengasongatem wants to merge 4 commits intoaxonivy:release/12.0from
Conversation
…-flag-to-ignore-existing-generated-sources # Conflicts: # src/test/java/ch/ivyteam/ivy/maven/compile/TestCompileProjectMojo.java
|
Hi @ivy-lgi could you have a look at this when you have time? thank you. |
|
Thanks for proposing this enhancement @nkengasongatem I think we need to make sure, that no existing configuration option is there to prevent the error. Have you already explored, with:
you can print the options: output: If you share a minimal project where this error occurs, we can assist you in pin pointing whether an existing configuration can handle the problem. |
|
Thanks for the review and the pointer about v14.0 @ivy-rew , I was not aware of this so from my point of view it is okay that this proposal is only an intermediate solution for LTS12. Regarding the current issue: in the reproducer (see link below) it is a compiler error, not a warning. The output is:
Because of that, disabling warnings do not help. Here is a minimal reproducer: https://github.com/nkengasongatem/db-test The error can be reproduced with: I tried cleaning the src_generated at the "initialize" phase, but then I could no longer use the pro designer because any significant change during development would clean the sources and my project would break. For my pipeline, I currently just delete the sources in the test stage (that were created during the build stage) but the main pain point is during local development. Here I tend to run tests (and run other maven commands) quite often, and having to clean each time is not very convenient. |
|
Ok thanks for sharing the comprehensive miniaml example. I've shortly verified your setup.
Workaround:
<profiles>
<profile>
<id>modelgen</id>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.6.15.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>Full example (your db.test/pom.xml with a profile): Does that help you? |
|
Thanks for the detailed feedback and the profile suggestion @ivy-rew. I agree the profile approach is valid, but I am not sure it is the most practical solution: The issue isn't limited to In contrast, Ideally this would be handled at the engine level via the options map (the option The profile approach does work, but as outlined above it comes with a cognitive overhead. Either way, thank you for taking the time to review and for the detailed feedback, I really appreciate — feel free to close this PR if you don't see it fitting for LTS12 :) |

Summary
Adds a new
compileProjectflag to prevent Java compiler Filer errors caused by already existing generated sources.New property:
ivy.compiler.failOnExistingGeneratedSources(default:true)When set to
false,compileProjectprevents (for now, ignores) the specificInvocationTargetExceptioncase whose cause contains:Problem with Filer: Source file already existsWhy
This supports annotation-processing setups where generated sources may already exist before
compileProjectruns, for example Hibernate JPA static metamodel generation.Notes
ivy.compiler.failOnExistingGeneratedSources.CompileProjectMojo.Tests
Updated
TestCompileProjectMojoto cover:falsetrueExample