You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2009/04/19 10:36:19 UTC

svn commit: r766438 - in /tuscany/maven-plugins/trunk/maven-tuscany-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/maven/ src/main/java/org/apache...

Author: antelder
Date: Sun Apr 19 08:36:18 2009
New Revision: 766438

URL: http://svn.apache.org/viewvc?rev=766438&view=rev
Log:
Strawman tuscany:run maven plugin

Added:
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/   (with props)
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/pom.xml
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/
    tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java

Propchange: tuscany/maven-plugins/trunk/maven-tuscany-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Apr 19 08:36:18 2009
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Added: tuscany/maven-plugins/trunk/maven-tuscany-plugin/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-tuscany-plugin/pom.xml?rev=766438&view=auto
==============================================================================
--- tuscany/maven-plugins/trunk/maven-tuscany-plugin/pom.xml (added)
+++ tuscany/maven-plugins/trunk/maven-tuscany-plugin/pom.xml Sun Apr 19 08:36:18 2009
@@ -0,0 +1,268 @@
+<?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/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>4</version>
+    </parent>
+
+    <groupId>org.apache.tuscany.maven.plugins</groupId>
+    <artifactId>maven-tuscany-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <name>Apache Tuscany Maven Tuscany Run Plugin</name>
+    <version>1.0-SNAPSHOT</version>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/tuscany/maven-plugins/trunk/maven-tuscany-plugin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/tuscany/maven-plugins/trunk/maven-tuscany-plugin</developerConnection>
+        <url>http://svn.apache.org/repos/asf/tuscany/</url>
+    </scm>
+
+    <distributionManagement>
+        <repository>
+            <id>apache.releases</id>
+            <name>Apache Release Distribution Repository</name>
+            <url>scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+        </repository>
+        <snapshotRepository>
+            <id>apache.snapshots</id>
+            <name>Apache Development Snapshot Repository</name>
+            <url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
+            <uniqueVersion>false</uniqueVersion>
+        </snapshotRepository>
+    </distributionManagement>
+
+    <repositories>
+       <!-- Apache SNAPSHOT repository for unreleased artifacts -->
+       <repository>
+            <id>apache.snapshots</id>
+            <name>Apache SNAPSHOT Repository</name>
+            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+        <!-- Tuscany repository to hold artifacts that are not published in the public maven repos -->
+        <repository>
+            <id>tuscany.repo</id>
+            <name>Tuscany Maven 2.x Repository</name>
+            <url>http://svn.apache.org/repos/asf/tuscany/maven</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <pluginRepositories>
+        <!-- Apache repository for artifacts released by Apache TLP projects -->
+        <pluginRepository>
+            <id>apache</id>
+            <name>Apache Repository</name>
+            <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </pluginRepository>
+
+        <!-- Apache SNAPSHOT repository for unreleased artifacts -->
+        <pluginRepository>
+            <id>apache.snapshots</id>
+            <name>Apache SNAPSHOT Repository</name>
+            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </pluginRepository>
+
+    </pluginRepositories>
+
+    <profiles>
+        <profile>
+            <id>release</id>
+            <build>
+                <plugins>
+
+                    <plugin>
+                        <inherited>true</inherited>
+                        <artifactId>maven-deploy-plugin</artifactId>
+                        <version>2.4</version>
+                        <configuration>
+                            <altDeploymentRepository>${deploy.altRepository}</altDeploymentRepository>
+                            <updateReleaseInfo>true</updateReleaseInfo>
+                        </configuration>
+                    </plugin>
+
+                    <plugin>
+                        <artifactId>maven-gpg-plugin</artifactId>
+                        <version>1.0-alpha-4</version>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>sign</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>deploy</id>
+            <build>
+                <defaultGoal>deploy</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <version>2.0.4</version>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+    <dependencies>
+       <dependency>
+          <groupId>org.apache.maven</groupId>
+          <artifactId>maven-project</artifactId>
+          <version>2.0.3</version>
+       </dependency>
+       <dependency>
+          <groupId>org.apache.maven</groupId>
+          <artifactId>maven-plugin-api</artifactId>
+          <version>2.0.3</version>
+       </dependency>
+          <dependency>
+          <groupId>org.apache.maven</groupId>
+          <artifactId>maven-artifact</artifactId>
+          <version>2.0.3</version>
+       </dependency>
+
+       <dependency>
+          <groupId>org.apache.tuscany.sca</groupId>
+          <artifactId>tuscany-node-impl</artifactId>
+          <version>2.0-SNAPSHOT</version>
+       </dependency>
+
+       <dependency>
+          <groupId>org.apache.tuscany.sca</groupId>
+          <artifactId>tuscany-implementation-java-runtime</artifactId>
+          <version>2.0-SNAPSHOT</version>
+       </dependency>
+
+    </dependencies>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+            <resource>
+                <directory>.</directory>
+                <targetPath>META-INF</targetPath>
+                <filtering>true</filtering>
+                <includes>
+                    <include>LICENSE</include>
+                    <include>NOTICE</include>
+                </includes>
+            </resource>
+        </resources>
+
+        <pluginManagement>
+
+            <plugins>
+                <!-- compiler plugin configuration -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>2.0.2</version>
+                    <configuration>
+                        <source>1.5</source>
+                        <target>1.5</target>
+                    </configuration>
+                </plugin>
+
+                <!-- jar plugin configuration -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>2.1</version>
+                    <configuration>
+                        <archive>
+                            <manifestEntries>
+                                <Extension-Name>${project.artifactId}</Extension-Name>
+                                <Specification-Title>${name}</Specification-Title>
+                                <Specification-Vendor>The Apache Software Foundation</Specification-Vendor>
+                                <Specification-Version>${version}</Specification-Version>
+                                <Implementation-Title>${name}</Implementation-Title>
+                                <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+                                <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
+                                <Implementation-Version>${version}</Implementation-Version>
+                            </manifestEntries>
+                         </archive>
+                    </configuration>
+                </plugin>
+
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-release-plugin</artifactId>
+                    <configuration>
+                        <tagBase>https://svn.apache.org/repos/asf/tuscany/maven-plugins/tags</tagBase>
+                        <useReleaseProfile>false</useReleaseProfile>
+                        <preparationGoals>clean install</preparationGoals>
+                        <goals>deploy</goals>
+                        <arguments>-Prelease,deploy</arguments>
+                        <autoVersionSubmodules>true</autoVersionSubmodules>
+                    </configuration>
+                </plugin>
+
+            </plugins>
+
+        </pluginManagement>
+
+    </build>
+
+</project>

Added: tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java?rev=766438&view=auto
==============================================================================
--- tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java (added)
+++ tuscany/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java Sun Apr 19 08:36:18 2009
@@ -0,0 +1,138 @@
+/*
+ * 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.tuscany.maven.plugin;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * Maven Mojo to run the SCA contribution project in Tuscany.
+ * Invoked with "mvn tuscany:run"
+ * 
+ * @goal run
+ * @requiresDependencyResolution runtime
+ * @execute phase="package"
+ * @description Runs Tuscany directly from a SCA conribution maven project
+ */
+public class TuscanyRunMojo extends AbstractMojo {
+
+    /**
+     * The project artifactId.
+     * 
+     * @parameter expression="${project.artifactId}"
+     * @required
+     */
+    protected String artifactId;
+
+    /**
+     * The project packaging.
+     * 
+     * @parameter expression=".${project.packaging}"
+     * @required
+     */
+    protected String packaging;
+
+    /**
+     * The project build output directory
+     * 
+     * @parameter expression="${project.build.outputDirectory}"
+     * @required
+     */
+    protected File buildDirectory;
+
+    /**
+     * The project build output directory
+     * 
+     * @parameter expression="${project.build.finalName}"
+     * @required
+     */
+    protected File finalName;
+
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        getLog().info("Starting Tuscany Runtime...");
+
+        Contribution contribution = getProjectContribution();
+        // TODO allow specifying dependent contributions
+
+        Node node = NodeFactory.newInstance().createNode(null, contribution);
+        node.start();
+
+        waitForShutdown(node, getLog());
+
+    }
+
+    protected Contribution getProjectContribution() throws MojoExecutionException {
+        try {
+
+            String contribution =
+                new File(buildDirectory.getParent(), finalName.getName() + packaging).toURI().toURL().toString();
+            getLog().info("Project contribution: " + contribution);
+
+            return new Contribution(contribution, contribution);
+
+        } catch (MalformedURLException e) {
+            throw new MojoExecutionException("", e);
+        }
+    }
+
+    protected void waitForShutdown(Node node, Log log) {
+        Runtime.getRuntime().addShutdownHook(new ShutdownThread(node, log));
+        synchronized (this) {
+            try {
+                log.info("Ctrl-C to end...");
+                this.wait();
+            } catch (InterruptedException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    protected static class ShutdownThread extends Thread {
+
+        private Node node;
+        private Log log;
+
+        public ShutdownThread(Node node, Log log) {
+            super();
+            this.node = node;
+            this.log = log;
+        }
+
+        @Override
+        public void run() {
+            try {
+
+                log.info("Stopping Tuscany Runtime...");
+                node.stop();
+                node.destroy();
+
+            } catch (Exception e) {
+                log.error(e);
+            }
+        }
+    }
+}