-
Notifications
You must be signed in to change notification settings - Fork 27
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
Only create assertion class when it does not exist or when the associated class has changed #48
Comments
That would be a nice improvement. |
The I think the class could be used in this plugin as well. From the sources, I guess the following steps are required:
|
I had a closer look at the issue. It is much more complicated than I initially thought. It is easy to determine the Java file to which a generated assertion will be written and, therefore, it is also easy to identify the time it was last modified. However, the Java classes for which the assertions are generated are loaded via the class loader (which I did not know previously). It is possible to get the root directory (e.g. For classes contained in JAR files, the story is different. They should represent dependencies, but I have no idea how to determine if the dependencies was added / changed after the last build. My current idea would be to check
The part regarding the assertions created for source files from the current project could be much easier, if the evaluation for the classed to include would be done based on the maven project and not on the class path. This would require a major refactoring but could also be used as basis for #53. In such a scenario, we could do the following: -is the generation of assertions is restricted to source directories only?
I am note sure how many projects actually generate assertions from dependencies, but it guess the majority doesn't. Thus, this approach would improve the generation for the majority of the users. And for the other a work-around to use a separate maven project which only generates the assertions from the dependencies would be possible and also improve the situation. If you want to support #53 I could try to propose a combined PR with this issue in a way that the current behaviour remains standard (i.e. no breaking change for anyone who updates). |
Currently, the generator plugin always generates the assertion class which requires the
test-compile
step of Maven to compile the classes in every run - even if no source code has changed. The assertion classes should only be generated:Example:
I want to create assertions for class
A
:A
do not exist -> generate assertion classA
exists and classA
was not changed since the generation -> do not generate assertion classA
exists and classA
was changed since the generation -> generate a new version of the assertion classThe text was updated successfully, but these errors were encountered: