Repository: maven-archetype
Updated Branches:
  refs/heads/master 9f0307987 -> 45d44b1d9


ARCHETYPE-518

Add a commented test-case for ARCHETYPE-518 to demonstrate when parent is 
trying to read
system properties we cannot create archetype from project.


Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/45d44b1d
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/45d44b1d
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/45d44b1d

Branch: refs/heads/master
Commit: 45d44b1d92df582bea9df3069e7dce9e3e106900
Parents: 9f03079
Author: petar.tahchiev <paranoia...@gmail.com>
Authored: Tue Feb 14 14:18:25 2017 +0200
Committer: petar.tahchiev <paranoia...@gmail.com>
Committed: Tue Feb 14 14:18:25 2017 +0200

----------------------------------------------------------------------
 .../creator/FilesetArchetypeCreator.java        |  2 +
 .../creator/DefaultArchetypeCreatorIT.java      | 24 +++++++++-
 .../archetype.properties.sample                 | 25 ++++++++++
 .../pom-parent.xml.sample                       | 45 ++++++++++++++++++
 .../included-system-properties/pom.xml.sample   | 40 ++++++++++++++++
 .../src/main/java/App.java                      | 50 ++++++++++++++++++++
 6 files changed, 184 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/45d44b1d/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
----------------------------------------------------------------------
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 828af40..0022341 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
@@ -435,6 +435,8 @@ public class FilesetArchetypeCreator
                 ProjectBuildingRequest buildingRequest = new 
DefaultProjectBuildingRequest();
                 buildingRequest.setLocalRepository( localRepository );
                 buildingRequest.setRemoteRepositories( 
project.getRemoteArtifactRepositories() );
+//                buildingRequest.setSystemProperties( System.getProperties() 
);
+//                buildingRequest.setUserProperties( configurationProperties );
                 
                 MavenProject p = projectBuilder.build( pa, buildingRequest 
).getProject();
 

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/45d44b1d/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
----------------------------------------------------------------------
diff --git 
a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
 
b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
index 06663f3..f6156e1 100644
--- 
a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
+++ 
b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
@@ -21,6 +21,7 @@ package org.apache.maven.archetype.creator;
 
 import org.apache.maven.archetype.ArchetypeCreationRequest;
 import org.apache.maven.archetype.ArchetypeCreationResult;
+import org.apache.maven.archetype.ArchetypeManager;
 import org.apache.maven.archetype.common.Constants;
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
@@ -32,9 +33,12 @@ import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.project.ProjectBuildingResult;
 //import org.apache.maven.project.MavenProjectBuildingResult;
+import org.apache.maven.repository.internal.MavenRepositorySystemSession;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.PropertyUtils;
 import org.codehaus.plexus.util.StringUtils;
+import org.junit.Ignore;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -56,7 +60,7 @@ public class DefaultArchetypeCreatorIT
         throws Exception
     {
         System.out.println( ">>>>>> testCreateFilesetArchetype( \"" + project 
+ "\" )" );
-        
+
         ProjectBuilder builder = lookup( ProjectBuilder.class );
 
         File projectFile = getProjectFile( project );
@@ -77,7 +81,11 @@ public class DefaultArchetypeCreatorIT
 
         ProjectBuildingRequest buildingRequest = new 
DefaultProjectBuildingRequest();
         buildingRequest.setLocalRepository( localRepository );
-        
+        buildingRequest.setSystemProperties(System.getProperties());
+        MavenRepositorySystemSession repositorySession = new 
MavenRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager( new 
SimpleLocalRepositoryManager(localRepository.getBasedir() ) );
+        buildingRequest.setRepositorySession(repositorySession);
+
         MavenProject mavenProject = builder.build( projectFile, 
buildingRequest ).getProject();
 
         FilesetArchetypeCreator instance =
@@ -183,6 +191,18 @@ public class DefaultArchetypeCreatorIT
         assertExists(template1);
     }
 
+//    @Ignore("ARCHETYPE-518")
+//    public void testSystemPropertiesAreIncluded()
+//                    throws Exception
+//    {
+//        String project = "included-system-properties";
+//
+//        createFilesetArchetype( project );
+//
+//        File template1 = getTemplateFile( project, "src/main/java/App.java" 
);
+//        assertExists(template1);
+//    }
+
     public void testCreateFilesetArchetype1()
         throws Exception
     {

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/45d44b1d/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/archetype.properties.sample
----------------------------------------------------------------------
diff --git 
a/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/archetype.properties.sample
 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/archetype.properties.sample
new file mode 100644
index 0000000..0b139a1
--- /dev/null
+++ 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/archetype.properties.sample
@@ -0,0 +1,25 @@
+# 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.groupId=org.codehaus.mojo.archetypes
+archetype.artifactId=maven-archetype-test
+archetype.version=1.0
+archetype.languages=csharp
+groupId=org.apache.maven.archetype.test
+artifactId=test
+version=1.0-SNAPSHOT
+package=archetype

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/45d44b1d/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom-parent.xml.sample
----------------------------------------------------------------------
diff --git 
a/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom-parent.xml.sample
 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom-parent.xml.sample
new file mode 100644
index 0000000..af18fcc
--- /dev/null
+++ 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom-parent.xml.sample
@@ -0,0 +1,45 @@
+<?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.
+  -->
+<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>com.test</groupId>
+    <artifactId>test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <name>Maven archetype Test Correctly creates archetype when a system 
property is required.</name>
+    <packaging>pom</packaging>
+
+    <profiles>
+        <profile>
+           <id>doclint-java8-disable</id>
+           <activation>
+             <jdk>[1.8,)</jdk>
+           </activation>
+           <properties>
+             
<javadoc.additional.params>-Xdoclint:none</javadoc.additional.params>
+           </properties>
+         </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/45d44b1d/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom.xml.sample
----------------------------------------------------------------------
diff --git 
a/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom.xml.sample
 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom.xml.sample
new file mode 100644
index 0000000..5f694b4
--- /dev/null
+++ 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/pom.xml.sample
@@ -0,0 +1,40 @@
+<?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.
+  -->
+<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>com.test</groupId>
+        <artifactId>test</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>./pom-parent.xml.sample</relativePath>
+    </parent>
+
+    <groupId>org.apache.maven.archetype.test</groupId>
+    <artifactId>included-system-properties</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <name>Maven archetype Test Correctly creates archetype when a system 
property is required.</name>
+    <packaging>pom</packaging>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/45d44b1d/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/src/main/java/App.java
----------------------------------------------------------------------
diff --git 
a/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/src/main/java/App.java
 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/src/main/java/App.java
new file mode 100644
index 0000000..7753325
--- /dev/null
+++ 
b/archetype-testing/archetype-final/src/test/resources/projects/included-system-properties/src/main/java/App.java
@@ -0,0 +1,50 @@
+package org.apache.maven.test;
+
+/*
+ * 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.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+        //A   #\{some}
+        //B   #{some}
+        //C   #{some other}
+        //D   \#{some other}
+        //E   #{}
+        //F   {some}
+        //G   ${someOtherProperty}
+        //H   ${someValue}
+        /*
+        A   #\{some}
+        B   #{some}
+        C   #{some other}
+        D   \#{some other}
+        E   #{}
+        F   {some}
+        G   ${someOtherProperty}
+        H   ${someValue}
+         */
+    }
+}

Reply via email to