You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Stefan Seifert (JIRA)" <ji...@apache.org> on 2018/09/04 08:50:00 UTC
[jira] [Commented] (ARCHETYPE-274) Conditionally include or exclude
a file from archetype during generation
[ https://issues.apache.org/jira/browse/ARCHETYPE-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602773#comment-16602773 ]
Stefan Seifert commented on ARCHETYPE-274:
------------------------------------------
as a workaround you can use the {{archetype-post-generate.groovy}} script to achieve this.
see this archetypes which make advanced use of groovy scripts to filter out files or whole modules based on archetype parameters:
* https://github.com/wcm-io/wcm-io-maven-archetype-aem
* https://github.com/wcm-io/wcm-io-maven-archetype-aem-confmgmt
the groovy script is located at {{src/main/resources/META-INF/archetype-post-generate.groovy}}.
> Conditionally include or exclude a file from archetype during generation
> ------------------------------------------------------------------------
>
> Key: ARCHETYPE-274
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-274
> Project: Maven Archetype
> Issue Type: Improvement
> Components: Generator
> Affects Versions: 2.0-alpha-4
> Reporter: Dan Allen
> Priority: Major
>
> I would like to be able to control which files are placed into the generated project based on the value of a property that is defined during archetype:generate. For instance, I forsee the following prompt:
> Define value for groupId: : com.example
> Define value for artifactId: : myproject
> Define value for package: com.example: :
> Define value for extraSupport: : y
> Based on the value of extraSupport, I want to include (or not include) a file in the generated project. If the user does not want the extra support, I don't want to clutter up the generated project with unnecessary files.
> It's all about customization of the project based on what the developer intends to use. While I could create a whole other archetype, sometimes the changes are so slight that it would be easier to include/exclude a file.
> Is there a way to control this behavior using the archetype-metadata.xml descriptor?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)