You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Behrooz Nobakht <no...@gmail.com> on 2015/06/08 18:05:12 UTC

Mojo API to add target/generated-sources/DIR to eclipse's source folder

Hi,

I am trying to follow what `maven-plugin-plugin` Mojo does when generating
HelpMojo.java.
It also updates eclipse's .classpath some way (?) that I can see the
`target/generated-sources/plugin`
as a source folder in my IDE.

Similarly, this is also what maven-jaxb2-plugin does when generating
sources files from a schema.

I'm a bit clueless at this moment how to achieve the same for a custom
plugin I'm developing.
Any specific documentation, hints, or example sources I can look into for
this?

Thanks in advance,
Behrooz

Re: Mojo API to add target/generated-sources/DIR to eclipse's source folder

Posted by Behrooz Nobakht <no...@gmail.com>.
Thank you, Vincent for the link. It completely describes the way to
create default execution without the need to configure it when using the
plugin.
I learnt a lot!


On Mon, Jun 8, 2015 at 7:53 PM, Vincent Latombe <vi...@gmail.com>
wrote:

> This annotation just allows you to skip the <phase> declaration when you
> add the execution to your pom.
>
> If you want to skip the <execution> block, you'll need to create a custom
> packaging [1]. Then you'd specify <packaging>my-packaging</packaging> in
> your pom, instead of <packaging>jar</packaging> (or any other value you
> currently use)
>
> Cheers,
>
> Vincent
>
> [1]
>
> http://blog.sonatype.com/2009/08/create-a-customized-build-process-in-maven/#.VXXWhUZ5zaU
>
> Vincent
>
> 2015-06-08 19:21 GMT+02:00 Behrooz Nobakht <no...@gmail.com>:
>
> > Let me continue with another question. Currently, my Mojo implementation
> > has
> >
> > @Mojo(name = "my-goal-name", defaultPhase =
> > LifecyclePhase.GENERATE_SOURCES)
> >
> > However, I still need to add `<execution>` when I'm using the plugin;
> > otherwise it's just ignored.
> > I was expecting that the Mojo annotation would remove this requirement.
> > What am I missing?
> >
> > Thanks,
> > Behrooz
> >
> >
> > On Mon, Jun 8, 2015 at 6:36 PM, Behrooz Nobakht <no...@gmail.com>
> wrote:
> >
> > > Hi Andreas,
> > >
> > > Thank you for the pointer. It helped and it worked.
> > > I was using an improper life cycle phase as the default.
> > >
> > > Cheers,
> > > Behrooz
> > >
> > >
> > >
> > > On Mon, Jun 8, 2015 at 6:13 PM, Andreas Gudian <
> andreas.gudian@gmail.com
> > >
> > > wrote:
> > >
> > >> Hi,
> > >>
> > >> You can check the build-helper-maven-plugin, which has a tiny goal to
> > add
> > >> a
> > >> source directory to the project:
> > >>
> > >>
> >
> https://github.com/mojohaus/build-helper-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/buildhelper/AddSourceMojo.java
> > >>
> > >> The maven-eclipse-plugin picks up all source directories listed in the
> > >> model of the build.
> > >>
> > >> Hope that helps,
> > >> Andreas
> > >>
> > >> Am Montag, 8. Juni 2015 schrieb Behrooz Nobakht :
> > >>
> > >> > Hi,
> > >> >
> > >> > I am trying to follow what `maven-plugin-plugin` Mojo does when
> > >> generating
> > >> > HelpMojo.java.
> > >> > It also updates eclipse's .classpath some way (?) that I can see the
> > >> > `target/generated-sources/plugin`
> > >> > as a source folder in my IDE.
> > >> >
> > >> > Similarly, this is also what maven-jaxb2-plugin does when generating
> > >> > sources files from a schema.
> > >> >
> > >> > I'm a bit clueless at this moment how to achieve the same for a
> custom
> > >> > plugin I'm developing.
> > >> > Any specific documentation, hints, or example sources I can look
> into
> > >> for
> > >> > this?
> > >> >
> > >> > Thanks in advance,
> > >> > Behrooz
> > >> >
> > >>
> > >
> > >
> > >
> > > --
> > > -- Behrooz Nobakht
> > >
> >
> >
> >
> > --
> > -- Behrooz Nobakht
> >
>



-- 
-- Behrooz Nobakht

Re: Mojo API to add target/generated-sources/DIR to eclipse's source folder

Posted by Vincent Latombe <vi...@gmail.com>.
This annotation just allows you to skip the <phase> declaration when you
add the execution to your pom.

If you want to skip the <execution> block, you'll need to create a custom
packaging [1]. Then you'd specify <packaging>my-packaging</packaging> in
your pom, instead of <packaging>jar</packaging> (or any other value you
currently use)

Cheers,

Vincent

[1]
http://blog.sonatype.com/2009/08/create-a-customized-build-process-in-maven/#.VXXWhUZ5zaU

Vincent

2015-06-08 19:21 GMT+02:00 Behrooz Nobakht <no...@gmail.com>:

> Let me continue with another question. Currently, my Mojo implementation
> has
>
> @Mojo(name = "my-goal-name", defaultPhase =
> LifecyclePhase.GENERATE_SOURCES)
>
> However, I still need to add `<execution>` when I'm using the plugin;
> otherwise it's just ignored.
> I was expecting that the Mojo annotation would remove this requirement.
> What am I missing?
>
> Thanks,
> Behrooz
>
>
> On Mon, Jun 8, 2015 at 6:36 PM, Behrooz Nobakht <no...@gmail.com> wrote:
>
> > Hi Andreas,
> >
> > Thank you for the pointer. It helped and it worked.
> > I was using an improper life cycle phase as the default.
> >
> > Cheers,
> > Behrooz
> >
> >
> >
> > On Mon, Jun 8, 2015 at 6:13 PM, Andreas Gudian <andreas.gudian@gmail.com
> >
> > wrote:
> >
> >> Hi,
> >>
> >> You can check the build-helper-maven-plugin, which has a tiny goal to
> add
> >> a
> >> source directory to the project:
> >>
> >>
> https://github.com/mojohaus/build-helper-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/buildhelper/AddSourceMojo.java
> >>
> >> The maven-eclipse-plugin picks up all source directories listed in the
> >> model of the build.
> >>
> >> Hope that helps,
> >> Andreas
> >>
> >> Am Montag, 8. Juni 2015 schrieb Behrooz Nobakht :
> >>
> >> > Hi,
> >> >
> >> > I am trying to follow what `maven-plugin-plugin` Mojo does when
> >> generating
> >> > HelpMojo.java.
> >> > It also updates eclipse's .classpath some way (?) that I can see the
> >> > `target/generated-sources/plugin`
> >> > as a source folder in my IDE.
> >> >
> >> > Similarly, this is also what maven-jaxb2-plugin does when generating
> >> > sources files from a schema.
> >> >
> >> > I'm a bit clueless at this moment how to achieve the same for a custom
> >> > plugin I'm developing.
> >> > Any specific documentation, hints, or example sources I can look into
> >> for
> >> > this?
> >> >
> >> > Thanks in advance,
> >> > Behrooz
> >> >
> >>
> >
> >
> >
> > --
> > -- Behrooz Nobakht
> >
>
>
>
> --
> -- Behrooz Nobakht
>

Re: Mojo API to add target/generated-sources/DIR to eclipse's source folder

Posted by Behrooz Nobakht <no...@gmail.com>.
Let me continue with another question. Currently, my Mojo implementation has

@Mojo(name = "my-goal-name", defaultPhase = LifecyclePhase.GENERATE_SOURCES)

However, I still need to add `<execution>` when I'm using the plugin;
otherwise it's just ignored.
I was expecting that the Mojo annotation would remove this requirement.
What am I missing?

Thanks,
Behrooz


On Mon, Jun 8, 2015 at 6:36 PM, Behrooz Nobakht <no...@gmail.com> wrote:

> Hi Andreas,
>
> Thank you for the pointer. It helped and it worked.
> I was using an improper life cycle phase as the default.
>
> Cheers,
> Behrooz
>
>
>
> On Mon, Jun 8, 2015 at 6:13 PM, Andreas Gudian <an...@gmail.com>
> wrote:
>
>> Hi,
>>
>> You can check the build-helper-maven-plugin, which has a tiny goal to add
>> a
>> source directory to the project:
>>
>> https://github.com/mojohaus/build-helper-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/buildhelper/AddSourceMojo.java
>>
>> The maven-eclipse-plugin picks up all source directories listed in the
>> model of the build.
>>
>> Hope that helps,
>> Andreas
>>
>> Am Montag, 8. Juni 2015 schrieb Behrooz Nobakht :
>>
>> > Hi,
>> >
>> > I am trying to follow what `maven-plugin-plugin` Mojo does when
>> generating
>> > HelpMojo.java.
>> > It also updates eclipse's .classpath some way (?) that I can see the
>> > `target/generated-sources/plugin`
>> > as a source folder in my IDE.
>> >
>> > Similarly, this is also what maven-jaxb2-plugin does when generating
>> > sources files from a schema.
>> >
>> > I'm a bit clueless at this moment how to achieve the same for a custom
>> > plugin I'm developing.
>> > Any specific documentation, hints, or example sources I can look into
>> for
>> > this?
>> >
>> > Thanks in advance,
>> > Behrooz
>> >
>>
>
>
>
> --
> -- Behrooz Nobakht
>



-- 
-- Behrooz Nobakht

Re: Mojo API to add target/generated-sources/DIR to eclipse's source folder

Posted by Behrooz Nobakht <no...@gmail.com>.
Hi Andreas,

Thank you for the pointer. It helped and it worked.
I was using an improper life cycle phase as the default.

Cheers,
Behrooz



On Mon, Jun 8, 2015 at 6:13 PM, Andreas Gudian <an...@gmail.com>
wrote:

> Hi,
>
> You can check the build-helper-maven-plugin, which has a tiny goal to add a
> source directory to the project:
>
> https://github.com/mojohaus/build-helper-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/buildhelper/AddSourceMojo.java
>
> The maven-eclipse-plugin picks up all source directories listed in the
> model of the build.
>
> Hope that helps,
> Andreas
>
> Am Montag, 8. Juni 2015 schrieb Behrooz Nobakht :
>
> > Hi,
> >
> > I am trying to follow what `maven-plugin-plugin` Mojo does when
> generating
> > HelpMojo.java.
> > It also updates eclipse's .classpath some way (?) that I can see the
> > `target/generated-sources/plugin`
> > as a source folder in my IDE.
> >
> > Similarly, this is also what maven-jaxb2-plugin does when generating
> > sources files from a schema.
> >
> > I'm a bit clueless at this moment how to achieve the same for a custom
> > plugin I'm developing.
> > Any specific documentation, hints, or example sources I can look into for
> > this?
> >
> > Thanks in advance,
> > Behrooz
> >
>



-- 
-- Behrooz Nobakht

Re: Mojo API to add target/generated-sources/DIR to eclipse's source folder

Posted by Andreas Gudian <an...@gmail.com>.
Hi,

You can check the build-helper-maven-plugin, which has a tiny goal to add a
source directory to the project:
https://github.com/mojohaus/build-helper-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/buildhelper/AddSourceMojo.java

The maven-eclipse-plugin picks up all source directories listed in the
model of the build.

Hope that helps,
Andreas

Am Montag, 8. Juni 2015 schrieb Behrooz Nobakht :

> Hi,
>
> I am trying to follow what `maven-plugin-plugin` Mojo does when generating
> HelpMojo.java.
> It also updates eclipse's .classpath some way (?) that I can see the
> `target/generated-sources/plugin`
> as a source folder in my IDE.
>
> Similarly, this is also what maven-jaxb2-plugin does when generating
> sources files from a schema.
>
> I'm a bit clueless at this moment how to achieve the same for a custom
> plugin I'm developing.
> Any specific documentation, hints, or example sources I can look into for
> this?
>
> Thanks in advance,
> Behrooz
>