summaryrefslogtreecommitdiffstats
path: root/maven-plugins/trunk/maven-tuscany-plugin
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-04-19 08:36:18 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-04-19 08:36:18 +0000
commitf092056d428a18aa52b32538532f97b2a7b7b8f4 (patch)
tree15d77bcfdab54de3bca027cc1f8703e9707b4e90 /maven-plugins/trunk/maven-tuscany-plugin
parent8f70a12249558f8b342a57740b6d6423ea23da57 (diff)
Strawman tuscany:run maven plugin
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@766438 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'maven-plugins/trunk/maven-tuscany-plugin')
-rw-r--r--maven-plugins/trunk/maven-tuscany-plugin/pom.xml268
-rw-r--r--maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java138
2 files changed, 406 insertions, 0 deletions
diff --git a/maven-plugins/trunk/maven-tuscany-plugin/pom.xml b/maven-plugins/trunk/maven-tuscany-plugin/pom.xml
new file mode 100644
index 0000000000..4872bce834
--- /dev/null
+++ b/maven-plugins/trunk/maven-tuscany-plugin/pom.xml
@@ -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>
diff --git a/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java b/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java
new file mode 100644
index 0000000000..ccf6d0ef8b
--- /dev/null
+++ b/maven-plugins/trunk/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java
@@ -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);
+ }
+ }
+ }
+}