You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2025/01/04 11:16:11 UTC

(maven-archetype) branch master updated: [ARCHETYPE-274] Conditionally include or exclude a file from archetype during generation (#244)

This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-archetype.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ed7d901 [ARCHETYPE-274] Conditionally include or exclude a file from archetype during generation (#244)
5ed7d901 is described below

commit 5ed7d901ef4a18613023907874ee86cd935a1db9
Author: Giovanni van der Schelde <27...@users.noreply.github.com>
AuthorDate: Sat Jan 4 12:16:06 2025 +0100

    [ARCHETYPE-274] Conditionally include or exclude a file from archetype during generation (#244)
---
 NOTICE.txt                                         |  1 -
 .../archetype/creator/FilesetArchetypeCreator.java |  5 +-
 .../DefaultFilesetArchetypeGenerator.java          | 11 ++++
 .../basic-1.0/archetype-resources/pom.xml          |  2 +-
 .../fileset-1.0/archetype-resources/pom.xml        |  2 +-
 .../archetype-resources/subproject/pom.xml         |  2 +-
 .../subproject/subsubproject/pom.xml               |  2 +-
 .../archetypes/old-1.0/archetype-resources/pom.xml |  2 +-
 .../partial-1.0/archetype-resources/pom.xml        |  2 +-
 ...n-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom |  2 +-
 .../src/main/mdo/archetype-descriptor.mdo          | 10 ++++
 archetype-samples/pom.xml                          |  2 +-
 deploySite.sh                                      |  1 -
 .../__projectName__-test2/pom.xml                  |  2 +-
 .../__rootArtifactId__-test1/pom.xml               |  2 +-
 .../src/main/resources/archetype-resources/pom.xml |  2 +-
 .../archetype.properties                           |  8 +--
 .../archetype/pom.xml                              | 44 ++++++++++++++++
 .../META-INF/maven/archetype-metadata.xml          | 60 ++++++++++++++++++++++
 .../main/resources/archetype-resources}/pom.xml    | 15 ++----
 .../archetype-resources/src/main/java/App.java     | 24 +++++++++
 .../src/main/resources/exclude-with-filter.txt     | 20 ++++++++
 .../src/main/resources/exclude-without-filter.txt  | 20 ++++++++
 .../src/main/resources/include-with-filter.txt     | 20 ++++++++
 .../src/main/resources/include-without-filter.txt  | 20 ++++++++
 .../invoker.properties                             | 10 ++--
 .../ARCHETYPE-274_conditional_filesets/pom.xml     | 48 +++++++++++++++++
 .../project.properties                             | 16 +++---
 .../verify.groovy                                  | 35 +++++++++++++
 .../src/main/resources/archetype-resources/pom.xml |  2 +-
 .../src/main/resources/archetype-resources/pom.xml |  2 +-
 .../src/main/resources/archetype-resources/pom.xml |  1 -
 .../resources/projects/basic/reference/pom.xml     |  1 -
 .../src/it/projects/roundtrip-multi/pom.xml        |  2 +-
 .../projects/roundtrip-multi/proficio-api/pom.xml  |  2 +-
 .../projects/roundtrip-multi/proficio-cli/pom.xml  |  2 +-
 .../projects/roundtrip-multi/proficio-core/pom.xml |  2 +-
 .../roundtrip-multi/proficio-model/pom.xml         |  2 +-
 .../roundtrip-multi/proficio-stores/pom.xml        |  2 +-
 .../proficio-stores/proficio-store-memory/pom.xml  |  2 +-
 .../proficio-stores/proficio-store-xstream/pom.xml |  2 +-
 41 files changed, 356 insertions(+), 56 deletions(-)

diff --git a/NOTICE.txt b/NOTICE.txt
index 24e228b4..53a591ca 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,3 +1,2 @@
 This product includes software developed by 
 The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
index 62c92fc7..989e97a5 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
@@ -183,8 +183,9 @@ public class FilesetArchetypeCreator implements ArchetypeCreator {
             Model pom = pomManager.readPom(project.getFile());
 
             List<String> excludePatterns = configurationProperties.getProperty(Constants.EXCLUDE_PATTERNS) != null
-                    ? Arrays.asList(
-                            StringUtils.split(configurationProperties.getProperty(Constants.EXCLUDE_PATTERNS), ","))
+                    ? Arrays.asList(configurationProperties
+                            .getProperty(Constants.EXCLUDE_PATTERNS)
+                            .split(","))
                     : Collections.emptyList();
 
             List<String> fileNames = resolveFileNames(pom, basedir, excludePatterns);
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java b/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
index 49504bd4..1e613531 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java
@@ -780,6 +780,17 @@ public class DefaultFilesetArchetypeGenerator implements FilesetArchetypeGenerat
             FileSet fileSet = iterator.next();
             count++;
 
+            final String includeCondition = fileSet.getIncludeCondition();
+            if (includeCondition != null && !includeCondition.isEmpty()) {
+                final String evaluatedCondition = evaluateExpression(context, "includeCondition", includeCondition);
+                if (!Boolean.parseBoolean(evaluatedCondition)) {
+                    LOGGER.debug(String.format(
+                            "Skipping fileset %s due to includeCondition: %s being: %s",
+                            fileSet, includeCondition, evaluatedCondition));
+                    continue;
+                }
+            }
+
             List<String> fileSetResources =
                     archetypeFilesResolver.filterFiles(moduleOffset, fileSet, archetypeResources);
 
diff --git a/archetype-common/src/test/archetypes/basic-1.0/archetype-resources/pom.xml b/archetype-common/src/test/archetypes/basic-1.0/archetype-resources/pom.xml
index bb055cf1..c02a8792 100644
--- a/archetype-common/src/test/archetypes/basic-1.0/archetype-resources/pom.xml
+++ b/archetype-common/src/test/archetypes/basic-1.0/archetype-resources/pom.xml
@@ -40,4 +40,4 @@
     <!-- empty dependencies, with comments -->
   </dependencies>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/pom.xml b/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/pom.xml
index 33d6dcfa..0cae4563 100644
--- a/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/pom.xml
+++ b/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/pom.xml
@@ -35,4 +35,4 @@
     <module>subproject</module>
   </modules>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/pom.xml b/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/pom.xml
index 3ae5c9a4..4f0d2d1f 100644
--- a/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/pom.xml
+++ b/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/pom.xml
@@ -41,4 +41,4 @@
     <module>subsubproject</module>
   </modules>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/subsubproject/pom.xml b/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/subsubproject/pom.xml
index 4c2bc239..657a8f09 100644
--- a/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/subsubproject/pom.xml
+++ b/archetype-common/src/test/archetypes/fileset-1.0/archetype-resources/subproject/subsubproject/pom.xml
@@ -37,4 +37,4 @@
   <name>Maven archetype Test Subsubfolder</name>
   <packaging>jar</packaging>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-common/src/test/archetypes/old-1.0/archetype-resources/pom.xml b/archetype-common/src/test/archetypes/old-1.0/archetype-resources/pom.xml
index e13e2cd1..0f41174d 100644
--- a/archetype-common/src/test/archetypes/old-1.0/archetype-resources/pom.xml
+++ b/archetype-common/src/test/archetypes/old-1.0/archetype-resources/pom.xml
@@ -36,4 +36,4 @@
     <!-- empty dependencies, with comments -->
   </dependencies>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-common/src/test/archetypes/partial-1.0/archetype-resources/pom.xml b/archetype-common/src/test/archetypes/partial-1.0/archetype-resources/pom.xml
index ce15f3ed..5e014942 100644
--- a/archetype-common/src/test/archetypes/partial-1.0/archetype-resources/pom.xml
+++ b/archetype-common/src/test/archetypes/partial-1.0/archetype-resources/pom.xml
@@ -58,4 +58,4 @@
       </plugin>
     </plugins>
   </reporting>
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-common/src/test/repository/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1-SNAPSHOT/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom b/archetype-common/src/test/repository/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1-SNAPSHOT/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom
index ee213290..81fcae6a 100644
--- a/archetype-common/src/test/repository/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1-SNAPSHOT/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom
+++ b/archetype-common/src/test/repository/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-1-SNAPSHOT/maven-archetype-quickstart-1.0-alpha-1-SNAPSHOT.pom
@@ -23,4 +23,4 @@
   <modelVersion>4.0.0</modelVersion>
   <artifactId>maven-archetype-quickstart</artifactId>
   <version>1.0-alpha-1-SNAPSHOT</version>
-</project>
\ No newline at end of file
+</project>
diff --git a/archetype-models/archetype-descriptor/src/main/mdo/archetype-descriptor.mdo b/archetype-models/archetype-descriptor/src/main/mdo/archetype-descriptor.mdo
index f49089fe..03e3213b 100644
--- a/archetype-models/archetype-descriptor/src/main/mdo/archetype-descriptor.mdo
+++ b/archetype-models/archetype-descriptor/src/main/mdo/archetype-descriptor.mdo
@@ -162,6 +162,16 @@
           <required>false</required>
           <description>Encoding to use when filtering content.</description>
         </field>
+        <field xml.attribute="true">
+          <name>includeCondition</name>
+          <version>1.1.0+</version>
+          <type>String</type>
+          <required>false</required>
+          <description>A string value that should resolve to a boolean value to conditionally include filesets.
+          This condition should be either a boolean as String or a velocity template language statement that resolves
+          to a boolean value. If the descriptor contains includeCondition="${shouldInclude}" and the archetype has
+          a (required) property like shouldInclude=true the fileset is included.</description>
+        </field>
         <field>
           <name>directory</name>
           <version>1.0.0+</version>
diff --git a/archetype-samples/pom.xml b/archetype-samples/pom.xml
index 145c10d9..f0f76df6 100644
--- a/archetype-samples/pom.xml
+++ b/archetype-samples/pom.xml
@@ -26,4 +26,4 @@
     <archetype.properties>archetype.properties</archetype.properties>
   </properties>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/deploySite.sh b/deploySite.sh
index 6c9bbe20..a2d49118 100644
--- a/deploySite.sh
+++ b/deploySite.sh
@@ -21,4 +21,3 @@
 
 mvn package site site:stage -Preporting $@
 mvn scm-publish:publish-scm $@
-
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml
index 05d04167..b0af2139 100644
--- a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml
@@ -30,4 +30,4 @@ under the License.
   </parent>
   <artifactId>${projectName}-test2</artifactId>
   
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml
index 1cf27a3f..450a416c 100644
--- a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml
@@ -30,4 +30,4 @@ under the License.
   </parent>
   <artifactId>${rootArtifactId}-test1</artifactId>
   
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml
index 93ebda49..e9bfe6e7 100644
--- a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml
@@ -33,4 +33,4 @@ under the License.
     <module>${projectName}-test2</module>
   </modules>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/deploySite.sh b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype.properties
similarity index 89%
copy from deploySite.sh
copy to maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype.properties
index 6c9bbe20..74cf9cb4 100644
--- a/deploySite.sh
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype.properties
@@ -1,6 +1,3 @@
-#!/bin/sh
-
-#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,8 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
-
-mvn package site site:stage -Preporting $@
-mvn scm-publish:publish-scm $@
 
+excludePatterns=build.log,invoker.properties,verify.groovy
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/pom.xml
new file mode 100644
index 00000000..ed118c27
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/pom.xml
@@ -0,0 +1,44 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.maven.plugins.archetype.its</groupId>
+        <artifactId>archetype274-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>archetype274-archetype</artifactId>
+    <packaging>maven-archetype</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-archetype-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <archetypeDirectory>src/main/resources</archetypeDirectory>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 00000000..8adfcbb7
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<archetype-descriptor name="include-condition-test">
+
+    <requiredProperties>
+        <requiredProperty key="extraSupport"/>
+        <requiredProperty key="anotherSupport"/>
+    </requiredProperties>
+
+    <fileSets>
+        <fileSet filtered="true" packaged="true">
+            <directory>src/main/java</directory>
+            <includes>
+                <include>**/*.java</include>
+            </includes>
+        </fileSet>
+        <fileSet filtered="false" packaged="false" includeCondition="${extraSupport}">
+            <directory>src/main/resources</directory>
+            <includes>
+                <include>**/include-without-filter.txt</include>
+            </includes>
+        </fileSet>
+        <fileSet filtered="true" packaged="false" includeCondition="${extraSupport}">
+            <directory>src/main/resources</directory>
+            <includes>
+                <include>**/include-with-filter.txt</include>
+            </includes>
+        </fileSet>
+        <fileSet filtered="true" packaged="false" includeCondition="${anotherSupport}">
+            <directory>src/main/resources</directory>
+            <includes>
+                <include>**/exclude-with-filter.txt</include>
+            </includes>
+        </fileSet>
+        <fileSet filtered="false" packaged="false" includeCondition="${anotherSupport}">
+            <directory>src/main/resources</directory>
+            <includes>
+                <include>**/exclude-without-filter.txt</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+</archetype-descriptor>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/pom.xml
similarity index 78%
copy from maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml
copy to maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/pom.xml
index 05d04167..15f4c583 100644
--- a/maven-archetype-plugin/src/it/projects/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/pom.xml
@@ -1,5 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
 <!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
@@ -18,16 +16,13 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
-
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
 
-  <parent>
     <groupId>${groupId}</groupId>
     <artifactId>${artifactId}</artifactId>
     <version>${version}</version>
-  </parent>
-  <artifactId>${projectName}-test2</artifactId>
-  
-</project>
\ No newline at end of file
+    <packaging>pom</packaging>
+
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/java/App.java b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/java/App.java
new file mode 100644
index 00000000..136fea7c
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/java/App.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public class App {
+    public static void main(String[] args) {
+        System.out.println("This file should not be included");
+    }
+}
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/exclude-with-filter.txt b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/exclude-with-filter.txt
new file mode 100644
index 00000000..ccab0c2b
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/exclude-with-filter.txt
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+this should be excluded: ${package}
\ No newline at end of file
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/exclude-without-filter.txt b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/exclude-without-filter.txt
new file mode 100644
index 00000000..ccab0c2b
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/exclude-without-filter.txt
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+this should be excluded: ${package}
\ No newline at end of file
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/include-with-filter.txt b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/include-with-filter.txt
new file mode 100644
index 00000000..d0e51a8d
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/include-with-filter.txt
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+this should be included: ${package}
\ No newline at end of file
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/include-without-filter.txt b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/include-without-filter.txt
new file mode 100644
index 00000000..d0e51a8d
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/archetype/src/main/resources/archetype-resources/src/main/resources/include-without-filter.txt
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+this should be included: ${package}
\ No newline at end of file
diff --git a/deploySite.sh b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/invoker.properties
similarity index 79%
copy from deploySite.sh
copy to maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/invoker.properties
index 6c9bbe20..ebd19f4a 100644
--- a/deploySite.sh
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/invoker.properties
@@ -1,6 +1,3 @@
-#!/bin/sh
-
-#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,8 +14,9 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
 
-mvn package site site:stage -Preporting $@
-mvn scm-publish:publish-scm $@
+invoker.goals.1 = install
+invoker.project.1 = archetype
 
+invoker.goals.2 = org.apache.maven.plugins:maven-archetype-plugin:${project.version}:generate
+invoker.userPropertiesFile = project.properties
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/pom.xml
new file mode 100644
index 00000000..e4202899
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/pom.xml
@@ -0,0 +1,48 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins.archetype.its</groupId>
+    <artifactId>archetype274-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>org.apache.maven.archetype</groupId>
+                <artifactId>archetype-packaging</artifactId>
+                <version>@project.version@</version>
+            </extension>
+        </extensions>
+
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-archetype-plugin</artifactId>
+                    <version>@project.version@</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>
diff --git a/deploySite.sh b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/project.properties
similarity index 75%
copy from deploySite.sh
copy to maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/project.properties
index 6c9bbe20..aff8740f 100644
--- a/deploySite.sh
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/project.properties
@@ -1,6 +1,3 @@
-#!/bin/sh
-
-#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,8 +14,15 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
 
-mvn package site site:stage -Preporting $@
-mvn scm-publish:publish-scm $@
+archetypeGroupId=org.apache.maven.plugins.archetype.its
+archetypeArtifactId=archetype274-archetype
+archetypeVersion=1.0-SNAPSHOT
+
+groupId=com.company
+artifactId=myArtifactId
+version=1.0-SNAPSHOT
+package=com.company.project
 
+extraSupport=true
+anotherSupport=false
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/verify.groovy b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/verify.groovy
new file mode 100644
index 00000000..99511b0a
--- /dev/null
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-274_conditional_filesets/verify.groovy
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File
+
+def mainJava = new File(basedir, "/myArtifactId/src/main/java")
+def includeFirstResource = new File(basedir, "/myArtifactId/src/main/resources/include-with-filter.txt")
+def includeSecondResource = new File(basedir, "/myArtifactId/src/main/resources/include-without-filter.txt")
+def excludeFirstResource = new File(basedir, "/myArtifactId/src/main/resources/exclude-with-filter.txt")
+def excludeSecondResource = new File(basedir, "/myArtifactId/src/main/resources/exclude-without-filter.txt")
+
+assert mainJava.exists() : "${mainJava} should be present."
+assert includeFirstResource.exists() : "${includeFirstResource} should be present."
+assert includeSecondResource.exists() : "${includeSecondResource} should be present."
+assert !excludeFirstResource.exists() : "${excludeFirstResource} should not be present."
+assert !excludeSecondResource.exists() : "${excludeSecondResource} should not be present."
+
+assert includeFirstResource.text.contains("com.company") : "${includeFirstResource} should contain the expected content."
+assert includeSecondResource.text.contains("\${package}") : "${includeSecondResource} should contain the expected content."
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-536_groovy-grape/archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-536_groovy-grape/archetype/src/main/resources/archetype-resources/pom.xml
index 4f81a0f7..e5f0e3c8 100644
--- a/maven-archetype-plugin/src/it/projects/ARCHETYPE-536_groovy-grape/archetype/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-536_groovy-grape/archetype/src/main/resources/archetype-resources/pom.xml
@@ -28,4 +28,4 @@ under the License.
   <version>${version}</version>
   <packaging>pom</packaging>
   
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/ARCHETYPE-679_groovy-modules/archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/projects/ARCHETYPE-679_groovy-modules/archetype/src/main/resources/archetype-resources/pom.xml
index 4f81a0f7..e5f0e3c8 100644
--- a/maven-archetype-plugin/src/it/projects/ARCHETYPE-679_groovy-modules/archetype/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/ARCHETYPE-679_groovy-modules/archetype/src/main/resources/archetype-resources/pom.xml
@@ -28,4 +28,4 @@ under the License.
   <version>${version}</version>
   <packaging>pom</packaging>
   
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/property-setting-cli/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/projects/property-setting-cli/src/main/resources/archetype-resources/pom.xml
index 423aade7..decb371c 100644
--- a/maven-archetype-plugin/src/it/projects/property-setting-cli/src/main/resources/archetype-resources/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/property-setting-cli/src/main/resources/archetype-resources/pom.xml
@@ -31,4 +31,3 @@ under the License.
     <foo>${foo}</foo><!-- foo is an archetypes' required property -->
   </properties>
 </project>
-
diff --git a/maven-archetype-plugin/src/it/projects/property-setting-cli/src/test/resources/projects/basic/reference/pom.xml b/maven-archetype-plugin/src/it/projects/property-setting-cli/src/test/resources/projects/basic/reference/pom.xml
index 62120c43..4ae14faa 100644
--- a/maven-archetype-plugin/src/it/projects/property-setting-cli/src/test/resources/projects/basic/reference/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/property-setting-cli/src/test/resources/projects/basic/reference/pom.xml
@@ -31,4 +31,3 @@ under the License.
     <foo>bar</foo><!-- foo is an archetypes' required property -->
   </properties>
 </project>
-
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/pom.xml
index 1c6fcf38..7a35f480 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/pom.xml
@@ -34,4 +34,4 @@
         <module>proficio-model</module>
         <module>proficio-stores</module>
     </modules>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-api/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-api/pom.xml
index abfeb67b..10a0cd65 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-api/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-api/pom.xml
@@ -37,4 +37,4 @@
       <version>1.0-SNAPSHOT</version>
     </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-cli/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-cli/pom.xml
index 27aff0d4..3ad03b0e 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-cli/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-cli/pom.xml
@@ -47,4 +47,4 @@
       <version>1.0-SNAPSHOT</version>
     </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-core/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-core/pom.xml
index 860bd3eb..4e09342c 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-core/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-core/pom.xml
@@ -37,4 +37,4 @@
       <version>1.0-SNAPSHOT</version>
     </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-model/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-model/pom.xml
index 64b611ba..3c27f9fe 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-model/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-model/pom.xml
@@ -29,4 +29,4 @@
     <artifactId>proficio-model</artifactId>
 
     <name>proficio model</name>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/pom.xml
index a83d25a3..8e5be6b1 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/pom.xml
@@ -35,4 +35,4 @@
         <module>proficio-store-memory</module>
         <module>proficio-store-xstream</module>
     </modules>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-memory/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-memory/pom.xml
index 60e1e0fa..85439e7a 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-memory/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-memory/pom.xml
@@ -37,4 +37,4 @@
       <version>1.0-SNAPSHOT</version>
     </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-xstream/pom.xml b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-xstream/pom.xml
index 5c6f1460..582d1f83 100644
--- a/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-xstream/pom.xml
+++ b/maven-archetype-plugin/src/it/projects/roundtrip-multi/proficio-stores/proficio-store-xstream/pom.xml
@@ -37,4 +37,4 @@
       <version>1.0-SNAPSHOT</version>
     </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>