Why maven-compiler-plugin seems to not take advantage of already compiled .class files?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Why maven-compiler-plugin seems to not take advantage of already compiled .class files?

Francesco Caliumi - Diennea
Hi everyone,
I'm wondering why, modifying just a single file, a "without clean" build takes a time very close to a "clean" build.

Some numbers about my build times:
1) mvn clean install: 01:13 min
2) mvn install (without file changes): 10.541 s
3) mvn install (with a single source file changed, among 2680 others left unchanged): 01:06 min

In case 3 I'm expecting a time closer to case 2, not to case 1. Both case 1 and 3 reports "Compiling 2680 source files".

Are there some options to make maven-compiler-plugin skip compiling sources where the xxx.class file has a more recent update time than the relative xxx.java file?

Many thanks in advance,
Francesco


--

Francesco Caliumi
Developer @ Diennea - MagNews
Tel.: (+39) 0546 066100 - Int. 266
Viale G.Marconi 30/14 - 48018 Faenza (RA)

[Magnews.it]<http://www.magnews.it/it>

[Linkedin]<http://www.linkedin.com/company/diennea---magnews>     [Twitter] <http://twitter.com/DienneaMagNews>      [Facebook] <http://www.facebook.com/pages/MagNews/197617841797>      [Newsletter] <http://www.magnews.it/it/iscriviti-alla-newsletter>

________________________________

CONFIDENTIALITY & PRIVACY NOTICE
This e-mail (including any attachments) is strictly confidential and may also contain privileged information. If you are not the intended recipient you are not authorised to read, print, save, process or disclose this message. If you have received this message by mistake, please inform the sender immediately and destroy this e-mail, its attachments and any copies. Any use, distribution, reproduction or disclosure by any person other than the intended recipient is strictly prohibited and the person responsible may incur in penalties.
The use of this e-mail is only for professional purposes; there is no guarantee that the correspondence towards this e-mail will be read only by the recipient, because, under certain circumstances, there may be a need to access this email by third subjects belonging to the Company.
Reply | Threaded
Open this post in threaded view
|

Re: Why maven-compiler-plugin seems to not take advantage of already compiled .class files?

rfscholte
Hi,

that's indeed quite a huge difference, but does this mean that the 55  
seconds is only for compilation?
The background about incremental builds is described/discussed in  
MCOMPILER-205[1] and Stack Overflow[2].

TLDR; If you change a method signature, you must also compile all classes  
that call this method (and throw a compilation error if you forgot to  
change this class).
Basically there are 2 options: analyze every class and decide if it must  
be recompiled OR simply recompile everything. The maven-compiler-plugin  
does the latter by default because the java compiler should be quite  
efficient.
Hence I'm kind of surprised by your numbers.

We're always interested in improvements, of course.

thanks,
Robert

[1] https://issues.apache.org/jira/projects/MCOMPILER/issues/MCOMPILER-205
[2]  
https://stackoverflow.com/questions/16963012/maven-compiler-recompile-all-files-instead-modified/49700942#49700942

On Fri, 30 Nov 2018 16:34:24 +0100, Francesco Caliumi - Diennea  
<[hidden email]> wrote:

> Hi everyone,
> I'm wondering why, modifying just a single file, a "without clean" build  
> takes a time very close to a "clean" build.
>
> Some numbers about my build times:
> 1) mvn clean install: 01:13 min
> 2) mvn install (without file changes): 10.541 s
> 3) mvn install (with a single source file changed, among 2680 others  
> left unchanged): 01:06 min
>
> In case 3 I'm expecting a time closer to case 2, not to case 1. Both  
> case 1 and 3 reports "Compiling 2680 source files".
>
> Are there some options to make maven-compiler-plugin skip compiling  
> sources where the xxx.class file has a more recent update time than the  
> relative xxx.java file?
>
> Many thanks in advance,
> Francesco
>
>
> --
>
> Francesco Caliumi
> Developer @ Diennea - MagNews
> Tel.: (+39) 0546 066100 - Int. 266
> Viale G.Marconi 30/14 - 48018 Faenza (RA)
>
> [Magnews.it]<http://www.magnews.it/it>
>
> [Linkedin]<http://www.linkedin.com/company/diennea---magnews>      
> [Twitter] <http://twitter.com/DienneaMagNews>      [Facebook]  
> <http://www.facebook.com/pages/MagNews/197617841797>      [Newsletter]  
> <http://www.magnews.it/it/iscriviti-alla-newsletter>
>
> ________________________________
>
> CONFIDENTIALITY & PRIVACY NOTICE
> This e-mail (including any attachments) is strictly confidential and may  
> also contain privileged information. If you are not the intended  
> recipient you are not authorised to read, print, save, process or  
> disclose this message. If you have received this message by mistake,  
> please inform the sender immediately and destroy this e-mail, its  
> attachments and any copies. Any use, distribution, reproduction or  
> disclosure by any person other than the intended recipient is strictly  
> prohibited and the person responsible may incur in penalties.
> The use of this e-mail is only for professional purposes; there is no  
> guarantee that the correspondence towards this e-mail will be read only  
> by the recipient, because, under certain circumstances, there may be a  
> need to access this email by third subjects belonging to the Company.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Why maven-compiler-plugin seems to not take advantage of already compiled .class files?

Martin Desruisseaux
In reply to this post by Francesco Caliumi - Diennea
Hello Francesco

Have you tried following configuration? It seems counter-intuitive, but
last time I tried it made compilation much faster (i.e. it seems to have
the opposite effect of what we would expect):

    <build>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <useIncrementalCompilation>false</useIncrementalCompilation> <!-- https://jira.codehaus.org/browse/MCOMPILER-209 -->
          </configuration>
        </plugin>
      </plugins>
    </build>

Martin


Reply | Threaded
Open this post in threaded view
|

Re: Why maven-compiler-plugin seems to not take advantage of already compiled .class files?

rfscholte
This is a dangerous advice.
Yes, it'll only compile the touched files, but not the source files using  
it.
For example method signature changes are not detected and you will hit  
that issue at runtime with a NoSuchMethodException, which is too late (and  
then Maven is of course the one to blame...)

thanks,
Robert

On Sat, 01 Dec 2018 19:48:21 +0100, Martin Desruisseaux  
<[hidden email]> wrote:

> Hello Francesco
>
> Have you tried following configuration? It seems counter-intuitive, but
> last time I tried it made compilation much faster (i.e. it seems to have
> the opposite effect of what we would expect):
>
>     <build>
>       <plugins>
>         <plugin>
>           <artifactId>maven-compiler-plugin</artifactId>
>           <configuration>
>             <useIncrementalCompilation>false</useIncrementalCompilation>  
> <!-- https://jira.codehaus.org/browse/MCOMPILER-209 -->
>           </configuration>
>         </plugin>
>       </plugins>
>     </build>
>
> Martin
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Why maven-compiler-plugin seems to not take advantage of already compiled .class files?

Martin Desruisseaux
Le 01/12/2018 à 21:17, Robert Scholte a écrit :

> This is a dangerous advice.
>
> Yes, it'll only compile the touched files, but not the source files
> using it. For example method signature changes are not detected and
> you will hit that issue at runtime with a NoSuchMethodException, which
> is too late
>
Yes I know. But running "mvn clean install" when we know that we have
changed the API, or when we get a NoSuchMethodException, is a small
price to pay for the gain in build speed.

    Martin



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]