[ 
https://issues.apache.org/jira/browse/MCOMPILER-312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16398242#comment-16398242
 ] 

Børge N commented on MCOMPILER-312:
-----------------------------------

We are also having issues with dagger and incremental compiles. (Possibly 
related to MCOMPILER-300.)

>From what I can see, the problem is that the incremental build does not take 
>generated sources into account at all, and there are two issues
 # When computing sources, generated sources are correctly excluded (see 
[change|[http://svn.apache.org/viewvc/maven/plugins/tags/maven-compiler-plugin-3.7.0/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java?r1=1726073&r2=1726074],]
 but when stale sources are computed, the generated sources are *not* excluded, 
so builds are triggered more often than necessary. This fix for this is 
straightforward.
 # When computing the list of changed files, there is an incremental build 
helper to track the files in the output directory. These files are deleted 
before an incremental compile. Note that this *also* includes classes from 
generated sources.
However, there are no incremental build helper for the generated sources, so 
the generated sources are *not* deleted. During compilation, javac sees that 
these files are already present, and therefore do not care to generated them 
again, and do not copy their respective class files to the output directory. 
After an incremental compilation, the output directory therefore do *not* 
include class files for generated sources, and further testing and/or 
compilation will break.

Attached is a crude patch for these two problems. The fix for the second item 
is rather ugly, because IncrementalBuildHelper only supports once directory, 
and the file lists (for the output directory and generated sources) need to be 
separated. But perhaps someone else can improve on this.

 

[^incremental_generate.patch]

> Maven annotation processor compiler error after changing the code
> -----------------------------------------------------------------
>
>                 Key: MCOMPILER-312
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-312
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.7.0
>         Environment: ./mvnw --version
> Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 
> 2017-04-03T20:39:06+01:00)
> Maven home: 
> /Users/fsousa/.m2/wrapper/dists/apache-maven-3.5.0-bin/6ps54u5pnnbbpr6ds9rppcc7iv/apache-maven-3.5.0
> Java version: 1.8.0_144, vendor: Oracle Corporation
> Java home: 
> /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "mac os x", version: "10.13.1", arch: "x86_64", family: "mac"
>            Reporter: Filipe Sousa
>            Priority: Major
>         Attachments: incremental_generate.patch
>
>
> Hi,
> I've been using google dagger annotation processor with maven. Is this 
> project ([https://github.com/natros/dagger2-mcp-test]) when I make a change I 
> have to clean install otherwise I'm getting compiler errors.
> Steps to reproduce:
> first time compile, compiles ok
> {noformat}
> ./mvnw clean compile
> {noformat}
> changing the code
> {noformat}
> sed -i -e 's@AuthService@//AuthService@' 
> src/main/java/com/github/natros/mcp/Main.java
> {noformat}
> compile without clean and fail
> {noformat}
> ./mvnw compile
> {noformat}
> clean compile and no errors
> {noformat}
> ./mvnw clean compile
> {noformat}
> On a large project it does not makes sense to clean before compiling.
> This is the error I'm getting:
> {noformat}
> [INFO] -------------------------------------------------------------
> [ERROR] COMPILATION ERROR : 
> [INFO] -------------------------------------------------------------
> [ERROR] 
> /Users/fsousa/Projects/tmp/dagger2-mcp-test/target/generated-sources/annotations/com/github/natros/mcp/DaggerMyComponent.java:[30,37]
>  method create in class com.github.natros.mcp.Main_Factory cannot be applied 
> to given types;
>   required: 
> javax.inject.Provider<com.github.natros.mcp.AuthService>,javax.inject.Provider<com.github.natros.mcp.UserService>
>   found: dagger.internal.Factory<com.github.natros.mcp.UserService>
>   reason: actual and formal argument lists differ in length
> [ERROR] 
> /Users/fsousa/Projects/tmp/dagger2-mcp-test/target/generated-sources/annotations/com/github/natros/mcp/Main_Factory.java:[26,12]
>  constructor Main in class com.github.natros.mcp.Main cannot be applied to 
> given types;
>   required: com.github.natros.mcp.UserService
>   found: com.github.natros.mcp.AuthService,com.github.natros.mcp.UserService
>   reason: actual and formal argument lists differ in length
> [INFO] 2 errors 
> {noformat}
> I asked this question to dagger creators who told me that this is a maven bug 
> not a dagger one.
> [https://github.com/google/dagger/issues/881#issuecomment-335854660]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to