maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Gold <r...@gold-family.us>
Subject Re: Maven bug in conjunction with annotation processing ?
Date Fri, 19 Jul 2013 16:33:00 GMT
Hi Tommy,

I am not seeing this problem, myself.

When you get the duplicate class problem, do you find multiple copies of the generated source
in your target directory? Multiple copies of the same class files? AFAIK that is the only
way you should ever see a duplicate class exception

- Regards,
Russ

On Jul 19, 2013, at 11:40 AM, Tommy Svensson <tommy@natusoft.se> wrote:

> Hello Russ,
> 
> No, that is not exactly my case. I just tried to build from the IDE  to confirm my suspicion
that the problem only occurred in maven. I'm using Intellij Idea 12 and it is nice enough
to recognize that my project is a maven project. When I tell it to "make" or "rebuild" it
does build itself not using maven, but it uses the same target paths as maven would. It tries
to avoid the problem you describe. 
> 
> My problem is that as long as I build with maven I have to do a "mvm clean install" every
time since an "mvn install" … "mvn install" will fail on the second install with a duplicate
class exception for the generated code. As I said, I suspect that maven have already built
the previously generated classes before annotation procession is run by maven and when the
annotation processor produces new versions of the same classes they are compiled again and
produces exactly the same class file targets as already produced before during the build.
This causes the duplicate class exception. That is at least my theory. 
> 
> /Tommy
> 
> 
> 19 jul 2013 kl. 17:28 skrev Russell Gold <russ@gold-family.us>:
> 
>> Hi Tommy,
>> 
>> I've run into some problems along these lines, but in my case, it only happens when
I build first using Maven and then try to recompile in the IDE. The problem appears to be
that the two disagree on where the generated classes go (there was a change in one of the
JDK releases, I believe).
>> 
>> I work around that by doing a clean compile in maven before starting IDE work.
>> 
>> Is that your problem? Or are you only seeing this by only doing repeated Maven builds?
I don't have that problem.
>> 
>> - Russ
>> 
>> On Jul 19, 2013, at 11:22 AM, Tommy Svensson <tommy@natusoft.se> wrote:
>> 
>>> Hello,
>>> 
>>> I have found a problem when using auto triggered annotation processors (META-INF/services/javax.annotation.Processor)
with maven builds! The problem occurs when the code have been built once and the annotation
processors have been triggered and generated code.  If I then build again without doing a
clean in between then I get a duplicate class exception for each generated class. I suspect
this is because maven have already build the previous versions before annotation processing
is triggered and when the newly updated/generated sources  are compiled it conflicts the the
previous built classes. 
>>> 
>>> This problem does not occur when I build in the IDE not using maven. Then the
annotation processing behaves as expected. I suspect that if the processor weren't specified
in META-INF/services/javax.annotation.Processor, and was run manually with apt-maven-plugin
it would work better, but that is not an option. I wan't my processor to be able to be used
the standard Java way, and with maven, without having 2 versions of it. I have found a way
to identify in the processor when there already are old sources available and don't regenerate
then, which will make it run in maven, but will then not update the generated sources without
first doing a clean when annotations are updated. This is of course not a good solution. 
>>> 
>>> Is there any other known way to solve this problem with maven ? I'm using version
3.1 of the maven-compiler-plugin.
>>> 
>>> Any help is appreciated.
>>> 
>>> Best Regards,
>>> Tommy Svensson
>>> 
>>> 
>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>> 
>> 
>> -----------------
>> Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
>> and listen to the Misfile radio play <http://www.gold-family.us/audio/misfile.html>!
>> 
>> 
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

-----------------
Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.gold-family.us/audio/misfile.html>!





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message