Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] issue when working with output class files?



On 12-02-22 9:10 PM, Andrei Pozolotin wrote:
    *Igor*, hi;

    I have an issue when working with output class files:

    in my MojoExecutionBuildParticipant I am interested in resulting
    class files,
    not java source files; and when my configurator is invoked by m2e
    for incremental build,
    the following problem occur:

    1) the source file compiles fine, and class file becomes available,
    but there is some kind of timing issue; namely,
    form time to time the build() invocation happens
    apparently BEFORE the class file is ready form JDT
    in the output folder; in other words, MojoExecutionBuildParticipant
    can see modified java file but NOT the corresponding class file;

    what is the way to insure build() is called only when class file is
    ready?


This is odd. Normally, m2e project have Java Builder before Maven
Builder in project configuration, so Maven builder is expected to see
both changed .java and corresponding generated .class files. If Maven
Builder is configured to run before Java Builder for whatever reason,
Maven builder is expected to be invoked twice, before Java Builder and
after.

Also, keep in mind that you don't have to use Maven Builder. You can
implement your own project builder or you can use JDT API to participate
in Java compilation directly.

    2) and when the file does not compile due to a compilation error,
    how can I know inside MojoExecutionBuildParticipant
    if there will be no class file available at all, despite java source
    change?



There is JDT API that allows you to participate in Java Builder
execution. It may allow you get information about java classes that
failed to compile or were compiled with errors.

--
Regards,
Igor


Back to the top