You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by io...@apache.org on 2010/09/03 16:05:19 UTC
svn commit: r992300 - in /karaf/trunk/archetypes: ./ command/ command/src/
command/src/main/ command/src/main/resources/
command/src/main/resources/META-INF/
command/src/main/resources/META-INF/maven/
command/src/main/resources/archetype-resources/ com...
Author: iocanel
Date: Fri Sep 3 14:05:17 2010
New Revision: 992300
URL: http://svn.apache.org/viewvc?rev=992300&view=rev
Log:
Added karaf module archetypes. Added command archetype. Added itests for karaf archetypes
Added:
karaf/trunk/archetypes/
karaf/trunk/archetypes/command/
karaf/trunk/archetypes/command/pom.xml
karaf/trunk/archetypes/command/src/
karaf/trunk/archetypes/command/src/main/
karaf/trunk/archetypes/command/src/main/resources/
karaf/trunk/archetypes/command/src/main/resources/META-INF/
karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/
karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype-metadata.xml
karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype.xml
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/NOTICE
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/pom.xml
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/java/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/java/
karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/java/__command__Test.java
karaf/trunk/archetypes/command/src/test/
karaf/trunk/archetypes/command/src/test/resources/
karaf/trunk/archetypes/command/src/test/resources/projects/
karaf/trunk/archetypes/command/src/test/resources/projects/basic/
karaf/trunk/archetypes/command/src/test/resources/projects/basic/archetype.properties
karaf/trunk/archetypes/itests/
karaf/trunk/archetypes/itests/pom.xml
karaf/trunk/archetypes/itests/src/
karaf/trunk/archetypes/itests/src/test/
karaf/trunk/archetypes/itests/src/test/java/
karaf/trunk/archetypes/itests/src/test/java/org/
karaf/trunk/archetypes/itests/src/test/java/org/apache/
karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/
karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/
karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/AbstractArchetypeTest.java
karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/CommandArchetypeTest.java
karaf/trunk/archetypes/itests/src/test/resources/
karaf/trunk/archetypes/itests/src/test/resources/archetype-pom.xml
karaf/trunk/archetypes/pom.xml
Added: karaf/trunk/archetypes/command/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/pom.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/pom.xml (added)
+++ karaf/trunk/archetypes/command/pom.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.karaf</groupId>
+ <artifactId>archetypes</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.karaf.archetypes</groupId>
+ <artifactId>archetypes-command</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+
+ <name>Apache Karaf :: Command Archetype</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-5</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-5</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
Added: karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype-metadata.xml (added)
+++ karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype-metadata.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor 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="org.apache.karaf.archetypes.command"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <requiredProperties>
+ <requiredProperty key="scope"/>
+ <requiredProperty key="command"/>
+ <requiredProperty key="description"/>
+ </requiredProperties>
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory></directory>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory></directory>
+ <includes>
+ <include>NOTICE</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
Added: karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype.xml (added)
+++ karaf/trunk/archetypes/command/src/main/resources/META-INF/maven/archetype.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,22 @@
+<?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>
+ <id>karaf-command-archetype</id>
+</archetype>
Added: karaf/trunk/archetypes/command/src/main/resources/archetype-resources/NOTICE
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/archetype-resources/NOTICE?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/archetype-resources/NOTICE (added)
+++ karaf/trunk/archetypes/command/src/main/resources/archetype-resources/NOTICE Fri Sep 3 14:05:17 2010
@@ -0,0 +1,21 @@
+Apache Felix Karaf
+Copyright 2010 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+
+III. License Summary
+- Apache License 2.0
Added: karaf/trunk/archetypes/command/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/archetype-resources/pom.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/archetype-resources/pom.xml (added)
+++ karaf/trunk/archetypes/command/src/main/resources/archetype-resources/pom.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>bundle</packaging>
+ <version>${version}</version>
+ <name>Apache Karaf :: Shell ${scope} Commands</name>
+
+ <description>Provides the OSGi ${scope} commands</description>
+
+ <properties>
+ <junit.version>4.7_1</junit.version>
+ <felix.osgi.version>1.4.0</felix.osgi.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${felix.osgi.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${felix.osgi.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>${package}*;version=${project.version}</Export-Package>
+ <Import-Package>!${project.artifactId}*,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.karaf.shell.console,
+ *
+ </Import-Package>
+ <Private-Package>!*</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java (added)
+++ karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java Fri Sep 3 14:05:17 2010
@@ -0,0 +1,22 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+#set( $cmd = $command.toLowerCase())
+
+package ${package};
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+
+/**
+ * Displays the last log entries
+ */
+@Command(scope = "${scope}", name = "${cmd}", description = "${description}")
+public class ${command} extends OsgiCommandSupport {
+
+ protected Object doExecute() throws Exception {
+ System.out.println("Executing command ${cmd}");
+ return null;
+ }
+}
Added: karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml (added)
+++ karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,16 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+#set( $cmd = $command.toLowerCase())
+<?xml version="1.0" encoding="UTF-8"?>
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+ <command name="${scope}/${cmd}">
+ <action class="${package}.${command}">
+ </action>
+ </command>
+ </command-bundle>
+</blueprint>
Added: karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/java/__command__Test.java
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/java/__command__Test.java?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/java/__command__Test.java (added)
+++ karaf/trunk/archetypes/command/src/main/resources/archetype-resources/src/test/java/__command__Test.java Fri Sep 3 14:05:17 2010
@@ -0,0 +1,31 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+
+package ${package};
+
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for {@link ${command}}
+ */
+@SuppressWarnings("unchecked")
+public class ${command}Test extends TestCase {
+
+ private ${command} command;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testCommand() {
+
+ }
+}
Added: karaf/trunk/archetypes/command/src/test/resources/projects/basic/archetype.properties
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/command/src/test/resources/projects/basic/archetype.properties?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/command/src/test/resources/projects/basic/archetype.properties (added)
+++ karaf/trunk/archetypes/command/src/test/resources/projects/basic/archetype.properties Fri Sep 3 14:05:17 2010
@@ -0,0 +1,7 @@
+#Mon Jul 19 10:12:55 EEST 2010
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
+scope=scp
+command=cmd
+description=Test Command
Added: karaf/trunk/archetypes/itests/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/itests/pom.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/itests/pom.xml (added)
+++ karaf/trunk/archetypes/itests/pom.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>archetypes</artifactId>
+ <groupId>org.apache.karaf</groupId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.karaf.archetypes</groupId>
+ <artifactId>archetypes-itests</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ <name>Apache Karaf :: Archetypes :: ITests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>classworlds</groupId>
+ <artifactId>classworlds</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-embedder</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>2.0.9</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Dmaven.repo.local=${settings.localRepository}</argLine>
+ <forkMode>always</forkMode>
+ <workingDirectory>${basedir}</workingDirectory>
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/AbstractArchetypeTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/AbstractArchetypeTest.java?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/AbstractArchetypeTest.java (added)
+++ karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/AbstractArchetypeTest.java Fri Sep 3 14:05:17 2010
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+package org.apache.karaf.archetypes;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Properties;
+import java.util.UUID;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.cli.ConsoleDownloadMonitor;
+import org.apache.maven.embedder.MavenEmbedder;
+import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
+import org.apache.maven.embedder.MavenEmbedderLogger;
+import org.apache.maven.embedder.PlexusLoggerAdapter;
+import org.apache.maven.monitor.event.DefaultEventMonitor;
+import org.apache.maven.monitor.event.EventMonitor;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
+
+public abstract class AbstractArchetypeTest extends TestCase {
+
+ private static final String MAVEN_REPO_LOCAL = "maven.repo.local";
+ private static final File baseDir = new File(System.getProperty("basedir", ".")).getAbsoluteFile();
+ private MavenEmbedder maven;
+ private Properties sysProps = System.getProperties();
+ private String version;
+
+ protected void setUp() throws Exception {
+ maven = new MavenEmbedder();
+ maven.setOffline(false);
+ System.err.println(sysProps.getProperty(MAVEN_REPO_LOCAL));
+ if (StringUtils.isNotEmpty(sysProps.getProperty(MAVEN_REPO_LOCAL))) {
+ maven.setLocalRepositoryDirectory(new File(sysProps.getProperty(MAVEN_REPO_LOCAL)));
+ }
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ maven.setClassLoader(classLoader);
+ MavenEmbedderLogger logger = new MavenEmbedderConsoleLogger();
+ maven.setLogger(logger);
+ maven.start();
+
+ Field f = maven.getClass().getDeclaredField("wagonManager");
+ f.setAccessible(true);
+ WagonManager wagon = (WagonManager) f.get(maven);
+ wagon.setOnline(true);
+
+ MavenProject project = maven.readProject(new File(baseDir, "pom.xml"));
+ maven.setInteractiveMode(false);
+ version = project.getVersion();
+ }
+
+ protected void tearDown() throws Exception {
+ maven.stop();
+ maven = null;
+ System.gc();
+ }
+
+ protected void testKarafArchetype(String artifactId) throws Exception {
+ testArchetype("org.apache.karaf.archetypes", artifactId, version, null);
+ }
+
+ protected void testKarafArchetype(String artifactId, Properties archetypeRequiredParameters) throws Exception {
+ testArchetype("org.apache.karaf.archetypes", artifactId, version, archetypeRequiredParameters);
+ }
+
+ protected void testArchetype(String groupId, String artifactId, String version, Properties archetypeRequiredParameters) throws Exception {
+ File targetDir = new File(baseDir, "target/archetypes/" + artifactId);
+ FileUtils.deleteDirectory(targetDir);
+ targetDir.mkdirs();
+ EventMonitor eventMonitor = new DefaultEventMonitor(new PlexusLoggerAdapter(
+ new MavenEmbedderConsoleLogger()));
+
+ Properties props = new Properties();
+ props.setProperty("archetypeGroupId", groupId);
+ props.setProperty("archetypeArtifactId", artifactId);
+ props.setProperty("archetypeVersion", version);
+ props.setProperty("interactiveMode", "false");
+ props.setProperty("groupId", "sample");
+ props.setProperty("artifactId", UUID.randomUUID().toString());
+ props.setProperty("user.dir", targetDir.getAbsolutePath());
+ props.setProperty("basedir", targetDir.getAbsolutePath());
+
+ //Some archetypes require additional parameters
+ if (archetypeRequiredParameters != null) {
+ for (String key : archetypeRequiredParameters.stringPropertyNames()) {
+ props.setProperty(key, archetypeRequiredParameters.getProperty(key));
+ }
+ }
+
+ MavenProject parent = maven.readProject(getDefaultArchetypePom(new File(targetDir, "pom.xml")));
+ System.setProperties((Properties) sysProps.clone());
+
+ maven.execute(parent,
+ Collections.singletonList("archetype:generate"),
+ eventMonitor,
+ new ConsoleDownloadMonitor(),
+ props,
+ targetDir);
+
+
+ System.setProperties((Properties) sysProps.clone());
+ targetDir = new File(targetDir, props.getProperty("artifactId"));
+ MavenProject prj = maven.readProject(new File(targetDir, "pom.xml"));
+
+ maven.execute(prj,
+ Collections.singletonList("package"),
+ eventMonitor,
+ new ConsoleDownloadMonitor(),
+ new Properties(),
+ targetDir);
+ }
+
+ private File getDefaultArchetypePom(File pomFile) throws IOException {
+ URL archetypePom = getClass().getClassLoader().getResource("archetype-pom.xml");
+ FileUtils.copyURLToFile(archetypePom, pomFile);
+ return pomFile;
+ }
+}
Added: karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/CommandArchetypeTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/CommandArchetypeTest.java?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/CommandArchetypeTest.java (added)
+++ karaf/trunk/archetypes/itests/src/test/java/org/apache/karaf/archetypes/CommandArchetypeTest.java Fri Sep 3 14:05:17 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+package org.apache.karaf.archetypes;
+
+import java.util.Properties;
+
+/**
+ *
+ * @author iocanel
+ */
+public class CommandArchetypeTest extends AbstractArchetypeTest {
+
+ public void testCommand() throws Exception {
+ Properties commandArchetypeParameters = new Properties();
+ commandArchetypeParameters.setProperty("scope", "testscope");
+ commandArchetypeParameters.setProperty("command", "testcommand");
+ commandArchetypeParameters.setProperty("description", "testdescription");
+ testKarafArchetype("archetypes-command", commandArchetypeParameters);
+ }
+}
Added: karaf/trunk/archetypes/itests/src/test/resources/archetype-pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/itests/src/test/resources/archetype-pom.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/itests/src/test/resources/archetype-pom.xml (added)
+++ karaf/trunk/archetypes/itests/src/test/resources/archetype-pom.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,33 @@
+<?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
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>dummy</artifactId>
+ <name>Archetype Manager</name>
+ <version>2.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+</project>
Added: karaf/trunk/archetypes/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/archetypes/pom.xml?rev=992300&view=auto
==============================================================================
--- karaf/trunk/archetypes/pom.xml (added)
+++ karaf/trunk/archetypes/pom.xml Fri Sep 3 14:05:17 2010
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+<!--
+ 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.
+-->
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>karaf</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>archetypes</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+
+ <name>Apache Karaf :: Archetypes</name>
+ <packaging>pom</packaging>
+
+
+ <modules>
+ <module>command</module>
+ <module>itests</module>
+ </modules>
+
+</project>