You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tomas Carlsson <to...@gmail.com> on 2006/11/13 14:16:58 UTC

Best practice for source-generating multiple archetype plugin

Hi,

We have a tool that given one input file generates code for different
purposes (currently j2me, j2se, ansi-c). I'm planning to write an m2 plugin
for this tool but I'm not really sure how to do it.

What I'm trying to achieve is to only have one copy of the original input
file and whenever it is changed there should be a simple build/release step
generating the result deliverables where the different types of deliverables
preferably has the same version number (ie. "generated-j2me-1.0.jar", "
generated-j2se-1.0.jar", "generated-ansi-c-1.0.zip")

My initial thought is to create a plugin that first generates sources for
the different purposes, then compiles them and lastly packages one archive
for each type.

I.e:
  1 input file => 3 generated source trees => 3 compiled "classes" tress =>
3 packed archetypes

I'm seeing some trouble with this though:

 1. It violates the maven philosophy of only having one archetype
 2. The plugin seems to get quite complicated which I think should be
possible to avoid


Anyone having experience with this kind of setup? Any best practices out
there?


best regards
Tomas

Re: Best practice for source-generating multiple archetype plugin

Posted by Arnaud Bailly <ab...@oqube.com>.
"Tomas Carlsson" <to...@gmail.com> writes:

> Hi,
>
> My initial thought is to create a plugin that first generates sources for
> the different purposes, then compiles them and lastly packages one archive
> for each type.
>
> I.e:
>  1 input file => 3 generated source trees => 3 compiled "classes" tress =>
> 3 packed archetypes
>
> I'm seeing some trouble with this though:
>
> 1. It violates the maven philosophy of only having one archetype
> 2. The plugin seems to get quite complicated which I think should be
> possible to avoid
>

Hello Tomas, 

I wrote a code generation plugin that does different things, ie. have
different mojos. I do not think this is complicated as this seems to
be the norm. 

As for Q.1, I do not have any definitive answer but what I did in my
case was creating one subproject for each different generation process
with dependency on the model project. Then you can configure your
plugin to do one thing in each project before compile or anything
else, then generate one artifact per project which is compliant with
standard maven usage. 

HTH,
-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Best practice for source-generating multiple archetype plugin

Posted by franz see <fr...@gmail.com>.
Good day,

I agree with this one. This should solve your trouble#2.

And as for your trouble #1, I haven't heard of that philosophy before.
Kindly expound further....but as for multiple archetypes, that is allowed
(hence the existence of the allowPartial tag in the archetype descriptor).

Cheers,
Franz


pjungwir wrote:
> 
> Why not limit your plugin to generating the sources, and use the existing
> plugins for compiling and packaging? This is likely to be more flexible,
> plus it's a lot less work.
> 
> If you want different artifactIds for each bundle, you should use a
> separate module for each. But you could also put them all into one module
> if you wanted to use classifiers. Then you'd get names like this:
> 
> - generated-1.0-j2me.jar
> - generated-1.0-j2se.jar
> - generated-1.0-ansi-c.zip
> 
> Paul
> 
> 
> Tomas Carlsson wrote:
>> 
>> Hi,
>> 
>> We have a tool that given one input file generates code for different
>> purposes (currently j2me, j2se, ansi-c). I'm planning to write an m2
>> plugin
>> for this tool but I'm not really sure how to do it.
>> 
>> What I'm trying to achieve is to only have one copy of the original input
>> file and whenever it is changed there should be a simple build/release
>> step
>> generating the result deliverables where the different types of
>> deliverables
>> preferably has the same version number (ie. "generated-j2me-1.0.jar", "
>> generated-j2se-1.0.jar", "generated-ansi-c-1.0.zip")
>> 
>> My initial thought is to create a plugin that first generates sources for
>> the different purposes, then compiles them and lastly packages one
>> archive
>> for each type.
>> 
>> I.e:
>>   1 input file => 3 generated source trees => 3 compiled "classes" tress
>> =>
>> 3 packed archetypes
>> 
>> I'm seeing some trouble with this though:
>> 
>>  1. It violates the maven philosophy of only having one archetype
>>  2. The plugin seems to get quite complicated which I think should be
>> possible to avoid
>> 
>> 
>> Anyone having experience with this kind of setup? Any best practices out
>> there?
>> 
>> 
>> best regards
>> Tomas
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Best-practice-for-source-generating-multiple-archetype-plugin-tf2622203s177.html#a7394789
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Best practice for source-generating multiple archetype plugin

Posted by pjungwir <ma...@9stmaryrd.com>.
Why not limit your plugin to generating the sources, and use the existing
plugins for compiling and packaging? This is likely to be more flexible,
plus it's a lot less work.

If you want different artifactIds for each bundle, you should use a separate
module for each. But you could also put them all into one module if you
wanted to use classifiers. Then you'd get names like this:

- generated-1.0-j2me.jar
- generated-1.0-j2se.jar
- generated-1.0-ansi-c.zip

Paul


Tomas Carlsson wrote:
> 
> Hi,
> 
> We have a tool that given one input file generates code for different
> purposes (currently j2me, j2se, ansi-c). I'm planning to write an m2
> plugin
> for this tool but I'm not really sure how to do it.
> 
> What I'm trying to achieve is to only have one copy of the original input
> file and whenever it is changed there should be a simple build/release
> step
> generating the result deliverables where the different types of
> deliverables
> preferably has the same version number (ie. "generated-j2me-1.0.jar", "
> generated-j2se-1.0.jar", "generated-ansi-c-1.0.zip")
> 
> My initial thought is to create a plugin that first generates sources for
> the different purposes, then compiles them and lastly packages one archive
> for each type.
> 
> I.e:
>   1 input file => 3 generated source trees => 3 compiled "classes" tress
> =>
> 3 packed archetypes
> 
> I'm seeing some trouble with this though:
> 
>  1. It violates the maven philosophy of only having one archetype
>  2. The plugin seems to get quite complicated which I think should be
> possible to avoid
> 
> 
> Anyone having experience with this kind of setup? Any best practices out
> there?
> 
> 
> best regards
> Tomas
> 
> 

-- 
View this message in context: http://www.nabble.com/Best-practice-for-source-generating-multiple-archetype-plugin-tf2622203s177.html#a7361402
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org