You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Petar Tahchiev <pa...@gmail.com> on 2015/12/17 22:40:28 UTC
ARCHETYPE-494
Hello all,
I've been having this idea to modify the resulting project after generating
from a given archetype. In my particular case I'd like to be able to delete
certain files, modify the pom.xml to add/remove dependencies, etc. After
speaking with Herve Boutemy he suggested it would be a nice addition to the
maven archetype plugin to be able to run a script after the project is
generated from an archetype. I filed the enhancement here:
https://issues.apache.org/jira/browse/ARCHETYPE-494
I've also implemented it in a separate branch here:
https://git1-us-west.apache.org/repos/asf?p=maven-archetype.git;a=commit;h=d60b876506e9b60ffa115c63425f837793fcaacf
The idea is very basic - if the archetype plugin finds a file called
"post_create.groovy" in META-INF folder it will try to execute it, passing
all the environment variables to it. I've also added a sample test-case.
I'd really like if someone takes a look on it before I merge it. Please
share your comments here.
Thanks.
--
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
Re: ARCHETYPE-494
Posted by Petar Tahchiev <pa...@gmail.com>.
Hi Herve,
I pushed the changes in the branch. It should be fine now.
Thanks again for the feedback.
2015-12-18 23:59 GMT+02:00 Hervé BOUTEMY <he...@free.fr>:
> yes, this sounds reasonable :)
>
> Regards,
>
> Hervé
>
> Le vendredi 18 décembre 2015 21:27:48 Petar Tahchiev a écrit :
> > Hello Herve,
> >
> > thanks for the feedback. Indeed, looking at your email I realize the file
> > naming is not the best. To answer your question - it is both post-create
> > and post-generate. I'm developing a project which later on I make into an
> > archetype using mvn archetype:create-from-project. This script lies in
> the
> > src/main/resources/META-INF/post_create.groovy and after archetype
> creation
> > it ends up in the jar's META-INF/post_create.groovy.
> >
> > I guess the best would be to rename the file to
> > archetype-post-generate.groovy and not use any properties - just detect
> if
> > a file is present
> > then put it in the META-INF during archetype:create-from-project and
> > respectfully if a file called archetype-post-generate.groovy is in the
> > META-INF
> > folder then try to execute it. How does this sound?
> >
> > 2015-12-18 13:48 GMT+02:00 Hervé BOUTEMY <he...@free.fr>:
> > > Hi Petar,
> > >
> > > Nice work!
> > >
> > > I had a look, and I am a bit confused: is it about post-*generate*, ie
> > > after a
> > > project is generated from an archetype, or about post-*create*, ie
> after
> > > an
> > > archetype project is built from a sample project? See the workflow
> drawing
> > > I
> > > did to try to make that clear [1]
> > >
> > > Because the Jira issue tells that it's about post-generate, but the
> script
> > > constant is ARCHETYPE_POST_GENERATION_SCRIPT =
> > > "META-INF/post_create.groovy"
> > > and a lot of generated classes are about create
> (ArchetypeCreationRequest,
> > > CreateArchetypeFromProjectMojo, FilesetArchetypeCreator).
> > >
> > > I see that Groovy script execution is in
> DefaultFilesetArchetypeGenerator,
> > > then it's really in archetype:generate, but then I don't understand
> what's
> > > the
> > > purpose of the code in archetype:create-from-project. And the
> > > "archetype.postScript" property name doesn't seem a good choice, since
> > > IMHO
> > > causes confusion with "archetype.postPhase":
> > > "archetype.postGenerateScript"
> > > would be better. But even the existence of this property seems
> > > questionable:
> > > can't it just be in a particular location in sample project, so it gets
> > > copied
> > > into META-INF/archetype-post-generate.groovy (whatever the
> > > ARCHETYPE_POST_GENERATION_SCRIPT constant will point to)?
> > >
> > >
> > > I suppose some additional example in plugin's documentation, would make
> > > the
> > > feature easier to understand from an end-user point of view.
> > >
> > >
> > > It's a good idea: let's continue!
> > >
> > > Regards,
> > >
> > > Hervé
> > >
> > >
> > > [1] http://maven.apache.org/archetype/maven-archetype-plugin/
> > >
> > > Le jeudi 17 décembre 2015 23:40:28 Petar Tahchiev a écrit :
> > > > Hello all,
> > > >
> > > > I've been having this idea to modify the resulting project after
> > >
> > > generating
> > >
> > > > from a given archetype. In my particular case I'd like to be able to
> > >
> > > delete
> > >
> > > > certain files, modify the pom.xml to add/remove dependencies, etc.
> After
> > > > speaking with Herve Boutemy he suggested it would be a nice addition
> to
> > >
> > > the
> > >
> > > > maven archetype plugin to be able to run a script after the project
> is
> > > > generated from an archetype. I filed the enhancement here:
> > > >
> > > > https://issues.apache.org/jira/browse/ARCHETYPE-494
> > >
> > > > I've also implemented it in a separate branch here:
> > >
> https://git1-us-west.apache.org/repos/asf?p=maven-archetype.git;a=commit;h
> > > =d>
> > > > 60b876506e9b60ffa115c63425f837793fcaacf
> > > >
> > > > The idea is very basic - if the archetype plugin finds a file called
> > > > "post_create.groovy" in META-INF folder it will try to execute it,
> > >
> > > passing
> > >
> > > > all the environment variables to it. I've also added a sample
> test-case.
> > > >
> > > > I'd really like if someone takes a look on it before I merge it.
> Please
> > > > share your comments here.
> > > >
> > > > Thanks.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
--
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
Re: ARCHETYPE-494
Posted by Hervé BOUTEMY <he...@free.fr>.
yes, this sounds reasonable :)
Regards,
Hervé
Le vendredi 18 décembre 2015 21:27:48 Petar Tahchiev a écrit :
> Hello Herve,
>
> thanks for the feedback. Indeed, looking at your email I realize the file
> naming is not the best. To answer your question - it is both post-create
> and post-generate. I'm developing a project which later on I make into an
> archetype using mvn archetype:create-from-project. This script lies in the
> src/main/resources/META-INF/post_create.groovy and after archetype creation
> it ends up in the jar's META-INF/post_create.groovy.
>
> I guess the best would be to rename the file to
> archetype-post-generate.groovy and not use any properties - just detect if
> a file is present
> then put it in the META-INF during archetype:create-from-project and
> respectfully if a file called archetype-post-generate.groovy is in the
> META-INF
> folder then try to execute it. How does this sound?
>
> 2015-12-18 13:48 GMT+02:00 Hervé BOUTEMY <he...@free.fr>:
> > Hi Petar,
> >
> > Nice work!
> >
> > I had a look, and I am a bit confused: is it about post-*generate*, ie
> > after a
> > project is generated from an archetype, or about post-*create*, ie after
> > an
> > archetype project is built from a sample project? See the workflow drawing
> > I
> > did to try to make that clear [1]
> >
> > Because the Jira issue tells that it's about post-generate, but the script
> > constant is ARCHETYPE_POST_GENERATION_SCRIPT =
> > "META-INF/post_create.groovy"
> > and a lot of generated classes are about create (ArchetypeCreationRequest,
> > CreateArchetypeFromProjectMojo, FilesetArchetypeCreator).
> >
> > I see that Groovy script execution is in DefaultFilesetArchetypeGenerator,
> > then it's really in archetype:generate, but then I don't understand what's
> > the
> > purpose of the code in archetype:create-from-project. And the
> > "archetype.postScript" property name doesn't seem a good choice, since
> > IMHO
> > causes confusion with "archetype.postPhase":
> > "archetype.postGenerateScript"
> > would be better. But even the existence of this property seems
> > questionable:
> > can't it just be in a particular location in sample project, so it gets
> > copied
> > into META-INF/archetype-post-generate.groovy (whatever the
> > ARCHETYPE_POST_GENERATION_SCRIPT constant will point to)?
> >
> >
> > I suppose some additional example in plugin's documentation, would make
> > the
> > feature easier to understand from an end-user point of view.
> >
> >
> > It's a good idea: let's continue!
> >
> > Regards,
> >
> > Hervé
> >
> >
> > [1] http://maven.apache.org/archetype/maven-archetype-plugin/
> >
> > Le jeudi 17 décembre 2015 23:40:28 Petar Tahchiev a écrit :
> > > Hello all,
> > >
> > > I've been having this idea to modify the resulting project after
> >
> > generating
> >
> > > from a given archetype. In my particular case I'd like to be able to
> >
> > delete
> >
> > > certain files, modify the pom.xml to add/remove dependencies, etc. After
> > > speaking with Herve Boutemy he suggested it would be a nice addition to
> >
> > the
> >
> > > maven archetype plugin to be able to run a script after the project is
> > > generated from an archetype. I filed the enhancement here:
> > >
> > > https://issues.apache.org/jira/browse/ARCHETYPE-494
> >
> > > I've also implemented it in a separate branch here:
> > https://git1-us-west.apache.org/repos/asf?p=maven-archetype.git;a=commit;h
> > =d>
> > > 60b876506e9b60ffa115c63425f837793fcaacf
> > >
> > > The idea is very basic - if the archetype plugin finds a file called
> > > "post_create.groovy" in META-INF folder it will try to execute it,
> >
> > passing
> >
> > > all the environment variables to it. I've also added a sample test-case.
> > >
> > > I'd really like if someone takes a look on it before I merge it. Please
> > > share your comments here.
> > >
> > > Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: ARCHETYPE-494
Posted by Petar Tahchiev <pa...@gmail.com>.
Hello Herve,
thanks for the feedback. Indeed, looking at your email I realize the file
naming is not the best. To answer your question - it is both post-create
and post-generate. I'm developing a project which later on I make into an
archetype using mvn archetype:create-from-project. This script lies in the
src/main/resources/META-INF/post_create.groovy and after archetype creation
it ends up in the jar's META-INF/post_create.groovy.
I guess the best would be to rename the file to
archetype-post-generate.groovy and not use any properties - just detect if
a file is present
then put it in the META-INF during archetype:create-from-project and
respectfully if a file called archetype-post-generate.groovy is in the
META-INF
folder then try to execute it. How does this sound?
2015-12-18 13:48 GMT+02:00 Hervé BOUTEMY <he...@free.fr>:
> Hi Petar,
>
> Nice work!
>
> I had a look, and I am a bit confused: is it about post-*generate*, ie
> after a
> project is generated from an archetype, or about post-*create*, ie after an
> archetype project is built from a sample project? See the workflow drawing
> I
> did to try to make that clear [1]
>
> Because the Jira issue tells that it's about post-generate, but the script
> constant is ARCHETYPE_POST_GENERATION_SCRIPT =
> "META-INF/post_create.groovy"
> and a lot of generated classes are about create (ArchetypeCreationRequest,
> CreateArchetypeFromProjectMojo, FilesetArchetypeCreator).
>
> I see that Groovy script execution is in DefaultFilesetArchetypeGenerator,
> then it's really in archetype:generate, but then I don't understand what's
> the
> purpose of the code in archetype:create-from-project. And the
> "archetype.postScript" property name doesn't seem a good choice, since IMHO
> causes confusion with "archetype.postPhase": "archetype.postGenerateScript"
> would be better. But even the existence of this property seems
> questionable:
> can't it just be in a particular location in sample project, so it gets
> copied
> into META-INF/archetype-post-generate.groovy (whatever the
> ARCHETYPE_POST_GENERATION_SCRIPT constant will point to)?
>
>
> I suppose some additional example in plugin's documentation, would make the
> feature easier to understand from an end-user point of view.
>
>
> It's a good idea: let's continue!
>
> Regards,
>
> Hervé
>
>
> [1] http://maven.apache.org/archetype/maven-archetype-plugin/
>
> Le jeudi 17 décembre 2015 23:40:28 Petar Tahchiev a écrit :
> > Hello all,
> >
> > I've been having this idea to modify the resulting project after
> generating
> > from a given archetype. In my particular case I'd like to be able to
> delete
> > certain files, modify the pom.xml to add/remove dependencies, etc. After
> > speaking with Herve Boutemy he suggested it would be a nice addition to
> the
> > maven archetype plugin to be able to run a script after the project is
> > generated from an archetype. I filed the enhancement here:
> >
> > https://issues.apache.org/jira/browse/ARCHETYPE-494
> >
> > I've also implemented it in a separate branch here:
> >
> >
> https://git1-us-west.apache.org/repos/asf?p=maven-archetype.git;a=commit;h=d
> > 60b876506e9b60ffa115c63425f837793fcaacf
> >
> > The idea is very basic - if the archetype plugin finds a file called
> > "post_create.groovy" in META-INF folder it will try to execute it,
> passing
> > all the environment variables to it. I've also added a sample test-case.
> >
> > I'd really like if someone takes a look on it before I merge it. Please
> > share your comments here.
> >
> > Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
--
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
Re: ARCHETYPE-494
Posted by Hervé BOUTEMY <he...@free.fr>.
Hi Petar,
Nice work!
I had a look, and I am a bit confused: is it about post-*generate*, ie after a
project is generated from an archetype, or about post-*create*, ie after an
archetype project is built from a sample project? See the workflow drawing I
did to try to make that clear [1]
Because the Jira issue tells that it's about post-generate, but the script
constant is ARCHETYPE_POST_GENERATION_SCRIPT = "META-INF/post_create.groovy"
and a lot of generated classes are about create (ArchetypeCreationRequest,
CreateArchetypeFromProjectMojo, FilesetArchetypeCreator).
I see that Groovy script execution is in DefaultFilesetArchetypeGenerator,
then it's really in archetype:generate, but then I don't understand what's the
purpose of the code in archetype:create-from-project. And the
"archetype.postScript" property name doesn't seem a good choice, since IMHO
causes confusion with "archetype.postPhase": "archetype.postGenerateScript"
would be better. But even the existence of this property seems questionable:
can't it just be in a particular location in sample project, so it gets copied
into META-INF/archetype-post-generate.groovy (whatever the
ARCHETYPE_POST_GENERATION_SCRIPT constant will point to)?
I suppose some additional example in plugin's documentation, would make the
feature easier to understand from an end-user point of view.
It's a good idea: let's continue!
Regards,
Hervé
[1] http://maven.apache.org/archetype/maven-archetype-plugin/
Le jeudi 17 décembre 2015 23:40:28 Petar Tahchiev a écrit :
> Hello all,
>
> I've been having this idea to modify the resulting project after generating
> from a given archetype. In my particular case I'd like to be able to delete
> certain files, modify the pom.xml to add/remove dependencies, etc. After
> speaking with Herve Boutemy he suggested it would be a nice addition to the
> maven archetype plugin to be able to run a script after the project is
> generated from an archetype. I filed the enhancement here:
>
> https://issues.apache.org/jira/browse/ARCHETYPE-494
>
> I've also implemented it in a separate branch here:
>
> https://git1-us-west.apache.org/repos/asf?p=maven-archetype.git;a=commit;h=d
> 60b876506e9b60ffa115c63425f837793fcaacf
>
> The idea is very basic - if the archetype plugin finds a file called
> "post_create.groovy" in META-INF folder it will try to execute it, passing
> all the environment variables to it. I've also added a sample test-case.
>
> I'd really like if someone takes a look on it before I merge it. Please
> share your comments here.
>
> Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org