Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] <runOnConfiguration> and copying resources

On Fri, Oct 19, 2012 at 12:54 PM, Steven Bethard
<steven.bethard@xxxxxxxxxxxx> wrote:
> Yep, sounds like a very similar problem.
>
> So here's what I'm thinking now:
>
> (1) During the search for files with hasDelta=true, I should ignore any errors that come up in the search, and interpret those errors as hasDelta=false. That way, on an import/configuration build, I always only come up with hasDelta=false.
>
> (2) In the case that I do find a hasDelta=true file, then I can restart the search for input files, and if any errors happen now, they're real errors that should be reported, not ignored. Assuming no errors occur, I can then run the code generation as usual.

I think I just found a much cleaner way to detect the configuration
build. This looks like a good pattern to follow:

// add generated source and/or resource directories to the project

// generated source directories will be added as optional classpath
entries, so they don't need to be created
// generated resources directories must exist, so create them here

// if this is an m2e configuration build then return immediately
without doing any work
if (buildContext.isIncremental() &&
!buildContext.hasDelta(project.getBasedir())) {
    return;
}

// perform code and/or resource generation

The code shown above should work because m2e will only execute an
m2e-compatible Maven plugin during an incremental build if there is a
delta inside the project. If there are no deltas in the project then
it must be a configuration build.

In the future it would be nice if there was a way for an
m2e-compatible Maven plugin to watch other projects in the workspace
so that it could be called whenever there is a delta in any of the
watched projects. I think this is already possible for m2e connectors.

Josh


Back to the top