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

Incremental builds #345

Closed
michalszynkiewicz opened this issue Jan 28, 2021 · 12 comments
Closed

Incremental builds #345

michalszynkiewicz opened this issue Jan 28, 2021 · 12 comments
Labels
wontfix This will not be worked on

Comments

@michalszynkiewicz
Copy link

It would be great if mvnd had an option to rebuild only the modules that have been modified since they were last built successfully.

@gnodet, @ppalaga mentioned that you may be already looking into it.

If not, I might be interested in implementing it (if I have time ;) )

@gnodet
Copy link
Contributor

gnodet commented Feb 3, 2021

Without having the knowledge of the actual inputs for each plugin, I don' think there's any safe way to say that a plugin (or even module) can be safely skipped. When optimizing the camel build time, I made sure that each plugin we were using could do a quick check and bypass the execution if the input had not changed.

I'm working on a Test Impact Analysis tool for maven so that the build could skip the tests that aren't affected by changes. It's still a prototype currently: https://github.com/mvndaemon/mvntia

@michalszynkiewicz
Copy link
Author

I was thinking of simply adding some timestamp of the last build to the target directory and then skipping a rebuild of an entire module if nothing has changed in places other than target (maybe also IDE settings?)

@gnodet
Copy link
Contributor

gnodet commented Feb 3, 2021

@michalszynkiewicz I'm not sure storing the timestamp in each build is a good idea
Also, I think what we're looking for has been implemented as part of https://issues.apache.org/jira/browse/MNG-5760 which is targeted at maven 4.0.
I'd rather try to port the related commits somehow to support parallel builds rather than trying to implement something completely different.

@michalszynkiewicz
Copy link
Author

While working with Quarkus, I often modify multiple modules. It's a big project and I want a fast feedback loop so I usually handwrite a command like mvn clean install -pl <a long list of modules>.

I started thinking of writing a small tool/shell that would figure out the list of modules for me automatically.
I thought that maybe instead of doing a separate thing, it could be added to mvnd.
Do I understand correctly that you think it's not a good fit for mvnd?

@gnodet
Copy link
Contributor

gnodet commented Feb 3, 2021

@michalszynkiewicz No, I definitely agree something has to be done. Until maven supports it, I agree it could be done in mvnd, but I'd rather do it the same way than maven: analyse the output, store the list of failed/skipped projects into a target/mvnd-resume.properties and use it if -r/--resume is added on the command line.

@jjlharrison
Copy link

@gnodet : Isn't there a difference between an incremental build and resuming a build? For me, when I say "incremental" I normally mean only building modules that have been changed, not just resuming from a failure.

@gnodet
Copy link
Contributor

gnodet commented Feb 3, 2021

@jjlharrison yes, there's a difference, but I think the workflow described by @michalszynkiewicz is more a resume than incremental
For incremental, I have much more reservations at this point as a single timestamp would certainly not be sufficient. Let's say you change the parent pom, you have to rebuild, even if no direct input has changed. And there are much worse scenarii. Incremental build needs each plugin to actually list all its input / output so that the system can determine if there is a change.

@michalszynkiewicz
Copy link
Author

-rf does a good job for resuming for me.
What I'm after is rebuilding modules that have changed files, not continuing from last failure.

Modifying a parent pom is indeed an example of a non-trivial change that should cause a rebuild.
Another one could be a changed BOM file that is imported by a module.
Do you see any more examples like that?

In my experience BOM or parent pom changes are much less frequent than code changes that I'd like to test, so ignoring them for now (so that one has to do a full rebuild in this case) would be an acceptable start.
And, at least these two cases, doesn't seem very complicated to handle. Maybe if a chain of parent poms/bom imports would go out of the project and back that could be not easy but I think giving up in such a case is okay.

@jjlharrison
Copy link

@gnodet: Yes, I understand that it is very complex and there can even be external dependencies that might change to affect things.

If there were a true incremental option, it would need some major caveats and the user would need to be responsible for knowing when they can use that option. I imagine it would be a lot of work to support as well.

@gnodet
Copy link
Contributor

gnodet commented Feb 3, 2021

To be clear, I did experiment a bit with the takari lifecycle https://github.com/takari/takari-lifecycle which provides a real incremental replacement of the core maven. However, my experiments were not really conclusive, especially if you have an existing build which is quite complex with non basic plugins.

At the end, I optimised all the plugins that were used so that they can be really fast if nothing has changed (basically, doing incremental build at the plugin level). This is much easier than implementing a truly increment build for maven.

mvnd helps in this regard if you use the -Dbuildtime.output.log=true which provides great insight into which plugins execute slowly.

@famod
Copy link
Contributor

famod commented Feb 7, 2021

Don't want to lure anyone away from mvnd (which is great), but for git-based incremental builds I'd like to suggest checking out https://github.com/vackosar/gitflow-incremental-builder (disclaimer: I'm maintaining that extension)

(In fact, there is some WIP to integrate it into the Quarkus build setup: quarkusio/quarkus#13243)

@gnodet
Copy link
Contributor

gnodet commented Feb 12, 2021

I'm going to close this issue. I'm not opposed to an incremental build, but it should be evaluated in the light of https://github.com/takari/takari-lifecycle, the https://github.com/vackosar/gitflow-incremental-builder. Also, it would be better as a separate maven extension, which could be hosted in this organisation if the existing ones are not satisfying (provided they can't be easily enhanced).

@gnodet gnodet closed this as completed Feb 12, 2021
@ppalaga ppalaga added this to the No fix/wont't fix milestone Mar 9, 2021
@gnodet gnodet added the wontfix This will not be worked on label Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants