Maven plugin for source generating

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Maven plugin for source generating

Rimvydas Vaidelis
Hello,

I would like to write a maven plugin that transforms a java source code
(adds specified annotations to methods). Lets say the source code contains
java files A.java, B.java and C.java. Lets say only B.java must be
transformed (transformer decides which java file should be transformed). I
do not want to modify original sources so I will write the transformed
class to a separate folder (target/myfolder).
Compiling should compile A.java and C.java from src/main/java and B.java
from target/myfolder. I can include the new source root in the plugin but
the compiler plugin will find 2 classes with the same name and will fire an
error.
Is there a way to configure which source files should be excluded from the
compilation? If so then maybe you can give some example of how to do that?
Or maybe this path is too complicated?

Thanks in advance for any help.
--
Rimvydas
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin for source generating

Mantas Gridinas
Sounds like you want annotation processing
https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html

On Tue, Mar 9, 2021 at 4:12 PM Rimvydas Vaidelis
<[hidden email]> wrote:

>
> Hello,
>
> I would like to write a maven plugin that transforms a java source code
> (adds specified annotations to methods). Lets say the source code contains
> java files A.java, B.java and C.java. Lets say only B.java must be
> transformed (transformer decides which java file should be transformed). I
> do not want to modify original sources so I will write the transformed
> class to a separate folder (target/myfolder).
> Compiling should compile A.java and C.java from src/main/java and B.java
> from target/myfolder. I can include the new source root in the plugin but
> the compiler plugin will find 2 classes with the same name and will fire an
> error.
> Is there a way to configure which source files should be excluded from the
> compilation? If so then maybe you can give some example of how to do that?
> Or maybe this path is too complicated?
>
> Thanks in advance for any help.
> --
> Rimvydas

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