You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2016/07/12 11:42:26 UTC
[1/3] maven-archetype git commit: [ARCHETYPE-491] Allow to run
integration test with another archetype as parent project
Repository: maven-archetype
Updated Branches:
refs/heads/master 147ff3dc6 -> 51f37fbd8
[ARCHETYPE-491] Allow to run integration test with another archetype as parent project
This closes #8
Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/50ec46b5
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/50ec46b5
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/50ec46b5
Branch: refs/heads/master
Commit: 50ec46b58af6084429622bc3bf645d5963f84634
Parents: 147ff3d
Author: Konrad Windszus <ko...@netcentric.biz>
Authored: Sat Oct 3 17:47:31 2015 +0200
Committer: Michael Osipov <mi...@apache.org>
Committed: Mon Jul 11 17:39:27 2016 +0200
----------------------------------------------------------------------
.../invoker.properties | 1 +
.../pom.xml | 63 ++++++
.../META-INF/maven/archetype-metadata.xml | 34 +++
.../main/resources/archetype-resources/pom.xml | 32 +++
.../archetype-resources/src/main/java/App.java | 36 +++
.../resources/projects/archetype.pom.properties | 4 +
.../resources/projects/archetype.properties | 4 +
.../projects/basic/archetype.properties | 4 +
.../src/test/resources/projects/basic/goal.txt | 1 +
.../resources/projects/basic/reference/pom.xml | 32 +++
.../src/main/java/build/archetype/App.java | 36 +++
.../test/resources/projects/basic/verify.groovy | 1 +
.../test-settings.xml | 55 +++++
.../verify.bsh | 46 ++++
.../archetype/mojos/IntegrationTestMojo.java | 221 ++++++++++++++-----
15 files changed, 520 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/invoker.properties
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/invoker.properties b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/invoker.properties
new file mode 100644
index 0000000..3802c4a
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = clean integration-test
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/pom.xml
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/pom.xml b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/pom.xml
new file mode 100644
index 0000000..4fff62d
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/pom.xml
@@ -0,0 +1,63 @@
+<?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>org.apache.maven.plugins.archetype.its</groupId>
+ <artifactId>build-archetype-and-run-its-with-existing-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>build-archetype-with-existing-parent</name>
+ <description>packages an archetype then runs IT (archetype:integration-test) within a Maven Project being created through another archetype</description>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>@project.version@</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <settingsFile>${basedir}/test-settings.xml</settingsFile>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ </configuration>
+
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <includeEmptyDirs>true</includeEmptyDirs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..28ff4bf
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,34 @@
+<?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 xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ name="build-archetype-IT">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..7ba4cfb
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,32 @@
+<?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>
+## There should be no parent specified, as it should be set automatically
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+
+ <name>archetype build IT</name>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/src/main/java/App.java
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/src/main/java/App.java b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/src/main/java/App.java
new file mode 100644
index 0000000..0e020bd
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/main/resources/archetype-resources/src/main/java/App.java
@@ -0,0 +1,36 @@
+package ${package};
+
+/*
+ * 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!" );
+ System.out.println( "groupId = ${groupId}" );
+ System.out.println( "artifactId = ${artifactId}" );
+ System.out.println( "package = ${package}" );
+ System.out.println( "packageInPathFormat = ${packageInPathFormat}" );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.pom.properties
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.pom.properties b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.pom.properties
new file mode 100644
index 0000000..0dfcb2b
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.pom.properties
@@ -0,0 +1,4 @@
+# https://github.com/mojohaus/pom-root, creates simple pom with packaging pom
+groupId=org.codehaus.mojo.archetypes
+artifactId=pom-root
+version=1.1
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.properties
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.properties b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.properties
new file mode 100644
index 0000000..3fbeda5
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/archetype.properties
@@ -0,0 +1,4 @@
+groupId=com.company
+artifactId=project
+version=1.0-SNAPSHOT
+package=com.company.project
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/archetype.properties
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/archetype.properties b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/archetype.properties
new file mode 100644
index 0000000..2607200
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/archetype.properties
@@ -0,0 +1,4 @@
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
+package=build.archetype
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/goal.txt
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/goal.txt b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/goal.txt
new file mode 100644
index 0000000..f8808ba
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/goal.txt
@@ -0,0 +1 @@
+compile
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/pom.xml
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/pom.xml b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/pom.xml
new file mode 100644
index 0000000..62a4b5b
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/pom.xml
@@ -0,0 +1,32 @@
+<?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>
+ <artifactId>project</artifactId>
+ <groupId>com.company</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>archetype.it</groupId>
+ <artifactId>basic</artifactId>
+ <version>0.1-SNAPSHOT</version>
+
+ <name>archetype build IT</name>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java
new file mode 100644
index 0000000..3119279
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/reference/src/main/java/build/archetype/App.java
@@ -0,0 +1,36 @@
+package build.archetype;
+
+/*
+ * 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!" );
+ System.out.println( "groupId = archetype.it" );
+ System.out.println( "artifactId = basic" );
+ System.out.println( "package = build.archetype" );
+ System.out.println( "packageInPathFormat = build/archetype" );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/verify.groovy
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/verify.groovy b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/verify.groovy
new file mode 100644
index 0000000..b8e0729
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/src/test/resources/projects/basic/verify.groovy
@@ -0,0 +1 @@
+System.out.println("Yeah Baby, it rocks!")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/test-settings.xml
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/test-settings.xml b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/test-settings.xml
new file mode 100644
index 0000000..ab9e16e
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/test-settings.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/verify.bsh
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/verify.bsh b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/verify.bsh
new file mode 100644
index 0000000..2d245ae
--- /dev/null
+++ b/maven-archetype-plugin/src/it/build-archetype-and-run-its-with-existing-parent/verify.bsh
@@ -0,0 +1,46 @@
+
+/*
+ * 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.*;
+import org.codehaus.plexus.util.*;
+
+basedir = new File( basedir, "target/test-classes/projects/basic/project/project/basic" );
+if ( !basedir.exists() ) {
+ throw new Exception( basedir + " is missing." );
+}
+
+File main = new File( basedir, "src/main" );
+
+// check <fileset packaged="true">
+File app = new File( main, "java/build/archetype/App.java" );
+if ( !app.isFile() )
+{
+ throw new Exception( app + " file is missing or not a file." );
+}
+
+File buildLog = new File( basedir, "build.log" );
+
+String content = FileUtils.fileRead( buildLog, "UTF-8" );
+
+int idx = content.indexOf( "Yeah Baby, it rocks!" );
+if ( idx < 0 )
+{
+ throw new Exception( "build.log missing System.out.println from verify.groovy" );
+}
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/50ec46b5/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java
----------------------------------------------------------------------
diff --git a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java
index 66966d4..c7ecb8d 100644
--- a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java
+++ b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/IntegrationTestMojo.java
@@ -19,12 +19,37 @@ package org.apache.maven.archetype.mojos;
* under the License.
*/
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.maven.archetype.ArchetypeGenerationRequest;
import org.apache.maven.archetype.ArchetypeGenerationResult;
import org.apache.maven.archetype.common.Constants;
import org.apache.maven.archetype.exception.ArchetypeNotConfigured;
import org.apache.maven.archetype.generator.ArchetypeGenerator;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -48,25 +73,6 @@ import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
/**
* <p>
* Execute the archetype integration tests, consisting in generating projects from the current archetype and optionally
@@ -84,6 +90,43 @@ import java.util.Set;
* the IT.</li>
* </ul>
* <p/>
+ * To let the IT create a Maven module below some other Maven project (being generated from another archetype)
+ * one can additionally specify an optional <code>archetype.pom.properties</code> file in the parent directory,
+ * specifying the archetype's <code>groupId</code>, <code>artifactId</code> and <code>version</code> along with its
+ * <code>archetype.properties</code> file, containing properties for project generation. Both files are leveraged
+ * to create the parent project for this IT. Parent projects can be nested.
+ * An example structure for such an integration test looks like this
+ * <table>
+ * <tr>
+ * <th>File/Directory</code></td>
+ * <th>Description</td>
+ * </tr>
+ * <tr>
+ * <td><code>src/test/resources/projects/it1</code></td>
+ * <td>Directory for integration test 1</td>
+ * </tr>
+ * <tr>
+ * <td><code>src/test/resources/projects/it1/archetype.pom.properties</code></td>
+ * <td>GAV for the archetype from which to generate the parent</td>
+ * </tr>
+ * <tr>
+ * <td><code>src/test/resources/projects/it1/archetype.properties</code></td>
+ * <td>All required properties for the archetype being specified by <code>archetype.pom.properties</code> on this level</td>
+ * </tr>
+ * <tr>
+ * <td><code>src/test/resources/projects/it1/child</code></td>
+ * <td>Directory for maven module within integration test 1 (this folder's name is not relevant)</td>
+ * </tr>
+ * <tr>
+ * <td><code>src/test/resources/projects/it1/child/goal.txt</code></td>
+ * <td>The file containing the list of goals to be executed against the generated project</td>
+ * </tr>
+ * <tr>
+ * <td><code>src/test/resources/projects/it1/child/archetype.properties</code></td>
+ * <td>All required properties for this project's archetype</td>
+ * </tr>
+ * </table>
+ * <p/>
* Notice that it is expected to be run as part as of a build after the <code>package</code> phase and not directly as a
* goal from CLI.
*
@@ -100,6 +143,18 @@ public class IntegrationTestMojo
@Component
private Invoker invoker;
+ @Component
+ private ArtifactFactory artifactFactory;
+
+ @Component
+ private ArtifactResolver artifactResolver;
+
+ @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true )
+ protected List remoteRepositories;
+
+ @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
+ protected ArtifactRepository localRepository;
+
/**
* The archetype project to execute the integration tests on.
*/
@@ -240,7 +295,7 @@ public class IntegrationTestMojo
try
{
- List<File> projectsGoalFiles = FileUtils.getFiles( testProjectsDirectory, "*/goal.txt", "" );
+ List<File> projectsGoalFiles = FileUtils.getFiles( testProjectsDirectory, "**/goal.txt", "" );
if ( projectsGoalFiles.size() == 0 )
{
@@ -427,40 +482,15 @@ public class IntegrationTestMojo
{
Properties properties = getProperties( goalFile );
- String basedir = goalFile.getParentFile().getPath() + "/project";
+ File basedir = new File( goalFile.getParentFile(), "project" );
FileUtils.deleteDirectory( basedir );
- FileUtils.mkdir( basedir );
+ FileUtils.mkdir( basedir.toString() );
+
+ basedir = setupParentProjects( goalFile.getParentFile().getParentFile(), basedir );
- //@formatter:off
- ArchetypeGenerationRequest request =
- new ArchetypeGenerationRequest().setArchetypeGroupId( project.getGroupId() ).setArchetypeArtifactId(
- project.getArtifactId() ).setArchetypeVersion( project.getVersion() ).setGroupId(
- properties.getProperty( Constants.GROUP_ID ) ).setArtifactId(
- properties.getProperty( Constants.ARTIFACT_ID ) ).setVersion(
- properties.getProperty( Constants.VERSION ) ).setPackage(
- properties.getProperty( Constants.PACKAGE ) ).setOutputDirectory( basedir ).setProperties(
- properties );
- //@formatter:on
-
- ArchetypeGenerationResult result = new ArchetypeGenerationResult();
-
- archetypeGenerator.generateArchetype( request, archetypeFile, result );
-
- if ( result.getCause() != null )
- {
- if ( result.getCause() instanceof ArchetypeNotConfigured )
- {
- ArchetypeNotConfigured anc = (ArchetypeNotConfigured) result.getCause();
-
- throw new IntegrationTestFailure(
- "Missing required properties in archetype.properties: " + StringUtils.join(
- anc.getMissingProperties().iterator(), ", " ), anc );
- }
-
- throw new IntegrationTestFailure( result.getCause().getMessage(), result.getCause() );
- }
+ ArchetypeGenerationRequest request = generate( project.getGroupId(), project.getArtifactId(), project.getVersion(), archetypeFile, properties, basedir.toString() );
File reference = new File( goalFile.getParentFile(), "reference" );
@@ -486,6 +516,97 @@ public class IntegrationTestMojo
}
}
+ private ArchetypeGenerationRequest generate( String archetypeGroupId, String archetypeArtifactId, String archetypeVersion, File archetypeFile, Properties properties, String basedir ) throws IntegrationTestFailure
+ {
+ //@formatter:off
+ ArchetypeGenerationRequest request =
+ new ArchetypeGenerationRequest().setArchetypeGroupId( archetypeGroupId ).setArchetypeArtifactId(
+ archetypeArtifactId ).setArchetypeVersion( archetypeVersion ).setGroupId(
+ properties.getProperty( Constants.GROUP_ID ) ).setArtifactId(
+ properties.getProperty( Constants.ARTIFACT_ID ) ).setVersion(
+ properties.getProperty( Constants.VERSION ) ).setPackage(
+ properties.getProperty( Constants.PACKAGE ) ).setOutputDirectory( basedir ).setProperties(
+ properties );
+ //@formatter:on
+
+ ArchetypeGenerationResult result = new ArchetypeGenerationResult();
+
+ archetypeGenerator.generateArchetype( request, archetypeFile, result );
+
+ if ( result.getCause() != null )
+ {
+ if ( result.getCause() instanceof ArchetypeNotConfigured )
+ {
+ ArchetypeNotConfigured anc = (ArchetypeNotConfigured) result.getCause();
+
+ throw new IntegrationTestFailure(
+ "Missing required properties in archetype.properties: " + StringUtils.join(
+ anc.getMissingProperties().iterator(), ", " ), anc );
+ }
+
+ throw new IntegrationTestFailure( result.getCause().getMessage(), result.getCause() );
+ }
+ return request;
+ }
+
+ private File setupParentProjects( File configFolder, File buildFolder )
+ throws IOException, MojoExecutionException, IntegrationTestFailure
+ {
+ // look for 'archetype.pom.properties'
+ File archetypePomPropertiesFile = new File( configFolder, "archetype.pom.properties" );
+ if ( !archetypePomPropertiesFile.exists() )
+ {
+ getLog().debug( "No 'archetype.pom.properties' file found in " + configFolder );
+ return buildFolder;
+ }
+
+ // go up to the parent configuration folder
+ buildFolder = setupParentProjects( configFolder.getParentFile(), buildFolder );
+
+ Properties archetypePomProperties = loadProperties( archetypePomPropertiesFile );
+ String groupId = archetypePomProperties.getProperty( Constants.GROUP_ID );
+ if ( StringUtils.isEmpty( groupId ) )
+ {
+ throw new MojoExecutionException( "Property " + Constants.GROUP_ID + " not set in " + archetypePomPropertiesFile );
+ }
+ String artifactId = archetypePomProperties.getProperty( Constants.ARTIFACT_ID );
+ if ( StringUtils.isEmpty( artifactId ) )
+ {
+ throw new MojoExecutionException( "Property " + Constants.ARTIFACT_ID + " not set in " + archetypePomPropertiesFile );
+ }
+ String version = archetypePomProperties.getProperty( Constants.VERSION );
+ if ( StringUtils.isEmpty( version ) )
+ {
+ throw new MojoExecutionException( "Property " + Constants.VERSION + " not set in " + archetypePomPropertiesFile );
+ }
+
+ File archetypeFile;
+ try
+ {
+ archetypeFile = getArchetypeFile( groupId, artifactId, version );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new MojoExecutionException( "Could not resolve archetype artifact " , e );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ throw new MojoExecutionException( "Could not find archetype artifact " , e );
+ }
+ Properties archetypeProperties = getProperties( archetypePomPropertiesFile );
+ getLog().info( "Setting up parent project in " + buildFolder );
+ ArchetypeGenerationRequest request = generate( groupId, artifactId, version, archetypeFile, archetypeProperties, buildFolder.toString() );
+ return new File( buildFolder, request.getArtifactId() );
+ }
+
+ private File getArchetypeFile( String groupId, String artifactId, String version )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+ Artifact archetypeArtifact = artifactFactory.createBuildArtifact( groupId, artifactId, version, "maven-archetype" );
+ artifactResolver.resolve( archetypeArtifact, remoteRepositories, localRepository );
+ return archetypeArtifact.getFile();
+ }
+
private Properties getProperties( File goalFile )
throws IOException
{
[3/3] maven-archetype git commit: [ARCHETYPE-503] Unit tests with
archetype-post-generate.groovy fail on Windows
Posted by mi...@apache.org.
[ARCHETYPE-503] Unit tests with archetype-post-generate.groovy fail on Windows
Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/51f37fbd
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/51f37fbd
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/51f37fbd
Branch: refs/heads/master
Commit: 51f37fbd809844df8a1a5d4b67641af6b2ff3da8
Parents: 11907b6
Author: Michael Osipov <mi...@apache.org>
Authored: Tue Jul 12 13:41:21 2016 +0200
Committer: Michael Osipov <mi...@apache.org>
Committed: Tue Jul 12 13:41:21 2016 +0200
----------------------------------------------------------------------
.../META-INF/archetype-post-generate.groovy | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/51f37fbd/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy
index 269196b..3ac5757 100644
--- a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy
+++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy
@@ -2,7 +2,7 @@ println "Executing the archetype-post-generate.groovy script...";
def outputDirectory = new File( request.getOutputDirectory() );
-def packageFolder = request.getPackage().replaceAll( '\\.', this.'file.separator' );
+def packageFolder = request.getPackage().replace( '.', '/' );
def toDelete = new File( outputDirectory, request.getArtifactId() + "/src/main/java/${packageFolder}/ToDelete.java" );
[2/3] maven-archetype git commit: [ARCHETYPE-502] XMLOutputter
generates files with inconsistent line ending on Windows
Posted by mi...@apache.org.
[ARCHETYPE-502] XMLOutputter generates files with inconsistent line ending on Windows
Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/11907b61
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/11907b61
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/11907b61
Branch: refs/heads/master
Commit: 11907b619a2c363def22fe5a2d8decc8a89ffeca
Parents: 50ec46b
Author: Michael Osipov <mi...@apache.org>
Authored: Tue Jul 12 13:04:46 2016 +0200
Committer: Michael Osipov <mi...@apache.org>
Committed: Tue Jul 12 13:04:46 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/maven/archetype/common/util/XMLOutputter.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/11907b61/archetype-common/src/main/java/org/apache/maven/archetype/common/util/XMLOutputter.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/common/util/XMLOutputter.java b/archetype-common/src/main/java/org/apache/maven/archetype/common/util/XMLOutputter.java
index 25fde61..ff25994 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/common/util/XMLOutputter.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/common/util/XMLOutputter.java
@@ -52,6 +52,7 @@ package org.apache.maven.archetype.common.util;
* on the JDOM Project, please see <http://www.jdom.org/>.
*/
+import org.codehaus.plexus.util.StringUtils;
import org.jdom.Attribute;
import org.jdom.CDATA;
import org.jdom.Comment;
@@ -854,7 +855,7 @@ public class XMLOutputter
throws IOException
{
out.write( "<!--" );
- out.write( comment.getText() );
+ out.write( StringUtils.unifyLineSeparators( comment.getText(), currentFormat.lineSeparator ) );
out.write( "-->" );
}