[
https://issues.apache.org/jira/browse/MCOMPILER-271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15786054#comment-15786054
]
Andreas Gudian commented on MCOMPILER-271:
------------------------------------------
I just played around a bit. and changing the build-section of the pom in the
example to this helps (removing the apt-maven-plugin):
{code:xml}
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
<annotationProcessorPaths>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
</annotationProcessorPaths>
<annotationProcessors>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</annotationProcessors>
</configuration>
</plugin>
</plugins>
</build>
{code}
I'm pretty sure this has nothing to do with the incremental compilation stuff.
It is defintely a side-effect of the changes I made for MCOMPILER-240. What
happens is that if the path configured with {{generatedSourcesDirectory}} (
(which defaults to {{target/generated-sources/annotations}}) or the equivalent
for {{test-compile}} is part of the project's compile-source-roots, then that
directory will be ignored for compilation, as the annotation processing done by
the compilation step itself already takes care of compiling the sources it
generates (regardless of whether {{annotationProcessorPaths}} is used or not).
So the assumption is that the path configured with
{{generatedSourcesDirectory}} would only contain sources that are already
compiled.
So it doesn't seem like something we can nicely fix in the compiler-plugin. I
don't think we should try to determine if any files within the
generated-sources directory were generated by the compiler-plugins compilation
call and thus are already compiled, or if they have been placed at that
location by another plugin execution.
And as pointed out, the other alternative to use only the compiler-plugin or to
change the output path for the apt-plugin to a directory that doesn't overlap
with the (configured or defaulted) {{generatedSourcesDirectory}} of the
compiler-plugin. I always do that with the compiler-plugin only, as there's
usually no need to split APT source generation from compilation.
I suggest closing this as Wont-Fix, with the explanation above. Is that okay
with you, [~oliver.gierke]?
> APT generated classes not visible during test compilation
> ---------------------------------------------------------
>
> Key: MCOMPILER-271
> URL: https://issues.apache.org/jira/browse/MCOMPILER-271
> Project: Maven Compiler Plugin
> Issue Type: Bug
> Affects Versions: 3.5.1
> Reporter: Oliver Gierke
> Assignee: Andreas Gudian
> Attachments: compiler-plugin-bug.zip
>
>
> After upgrading the Maven Compiler Plugin to 3.5.1, I see compilation errors
> with builds that work on 3.5. The symptom is that classes generated by an APT
> plugin are not visible on the test class path when
> {{target/generated-sources/annotations}} is used as output folder.
> I'll attach a sample project that shows the failure if you run {{mvn clean
> test-compile}}.
> Two things make the project work:
> 1. Downgrade to 3.5 (which makes me think any of the fixes made for
> MCOMPILER-240 has to do with this).
> 2. Change {{annotations}} segment of the output path to something other than
> {{annotations}}.
> Especially the latter puzzles me as it seems like this path is explicitly not
> added to the test compile classpath.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)