diff --git a/.gitignore b/.gitignore
index 24ad037b..6c652001 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,9 @@ openwhisk-master*
.idea
.vscode
**/.sts4-cache
+target/
+.project
+.settings/
+bin/
+.classpath
+.DS_Store
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 8748b274..763e792f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,10 @@ env:
- DOCKER_COMPOSE_VERSION: 1.13.0
matrix:
- TOOL: docker-compose
- - TOOL: java-action-archetype
+ - TOOL: java-maven/parent
+ - TOOL: java-maven/annotations
+ - TOOL: java-maven/update-maven-plugin
+ - TOOL: java-maven/action-archetype
services:
- docker
diff --git a/README.md b/README.md
index eee3b31d..c7000b16 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,13 @@ This repository is part of [Apache OpenWhisk](http://openwhisk.incubator.apache.
* [docker-compose](docker-compose/README.md) allows testing OpenWhisk locally, using Docker Compose. This is ideal if you are contributing to core development
* [node-local](node-local/README.md) allows testing individual OpenWhisk functions locally, using only node.js. This is ideal if you are writing node.js functions to run in OpenWhisk, but need to emulate some of OpenWhisk's behavior in creating `params` and expecting promises.
-* [maven-java](maven-java/README.md) allows testing OpenWhisk Java Actions. This shows how to package the function dependencies e.g. external jar.
+* *java-maven* tooling to support building / deploying Java actions in OpenWhisk
+ * [action-archetype](java-maven/action-archetype) Archetype for creating a Java Action project using Apache Maven
+ * [annotations](java-maven/annotations) Java annotations to indicate OpenWhisk Actions, Packages, Rules and Triggers
+ * [parent](java-maven/parent) provides a baseline Maven configuration for Maven-based OpenWhisk sub-projects
+ * [update-maven-plugin](java-maven/update-maven-plugin) Apache Maven plugin to read the [annotations](java-maven/annotations) and automatically deploying the Actions, Packages, Rules and Trigger to OpenWhisk
+* [maven-java-examplea](maven-java-example/README.md) shows how to package the function dependencies e.g. external jar.
+* [java-local](java-local) allows testing OpenWhisk Java Actions
## Travis builds
diff --git a/java-action-archetype/.editorconfig b/java-maven/action-archetype/.editorconfig
similarity index 100%
rename from java-action-archetype/.editorconfig
rename to java-maven/action-archetype/.editorconfig
diff --git a/java-action-archetype/.gitignore b/java-maven/action-archetype/.gitignore
similarity index 100%
rename from java-action-archetype/.gitignore
rename to java-maven/action-archetype/.gitignore
diff --git a/java-action-archetype/.travis/build.sh b/java-maven/action-archetype/.travis/build.sh
similarity index 100%
rename from java-action-archetype/.travis/build.sh
rename to java-maven/action-archetype/.travis/build.sh
diff --git a/java-maven/action-archetype/.travis/setup.sh b/java-maven/action-archetype/.travis/setup.sh
new file mode 100755
index 00000000..5a5330fb
--- /dev/null
+++ b/java-maven/action-archetype/.travis/setup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+set -x -e
+uname -sm
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+TOOLDIR="$SCRIPTDIR/../"
+
+# Build the parent so this compiles
+mkdir -p $TOOLDIR/target
+cd $TOOLDIR/target
+git clone https://github.com/klcodanr/incubator-openwhisk-devtools.git
+cd $TOOLDIR/target/incubator-openwhisk-devtools/java-maven/parent
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
+cd $TOOLDIR/target/incubator-openwhisk-devtools/java-maven/annotations
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
+cd $TOOLDIR/target/incubator-openwhisk-devtools/java-maven/update-maven-plugin
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
+
+cd $TOOLDIR
+
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
diff --git a/java-action-archetype/README.md b/java-maven/action-archetype/README.md
similarity index 85%
rename from java-action-archetype/README.md
rename to java-maven/action-archetype/README.md
index 67bf3daf..8de1b90c 100644
--- a/java-action-archetype/README.md
+++ b/java-maven/action-archetype/README.md
@@ -1,12 +1,14 @@
# Maven Archetype for Java Action
+This module is part of the [Apache OpenWhisk](http://openwhisk.incubator.apache.org/) project.
+
This archetype helps to generate the Java Action template project.
## Pre-requisite
The following softwares are required to build and deploy a Java Action to OpenWhisk:
-* (Maven v3.3.x)[https://maven.apache.org] or above
+* [Maven v3.3.x](https://maven.apache.org) or above
* Java 8 or above
[WSK CLI](https://github.com/apache/incubator-openwhisk/blob/master/docs/cli.md) is configured
@@ -29,11 +31,10 @@ The following step shows how to deploy the function to OpenWhisk
```sh
cd demo-function
mvn clean install
-wsk action create demo target/demo-function.jar --main com.example.FunctionApp
```
After successful deployment of the function, we can invoke the same via `wsk action invoke demo --result` to see the response as:
```json
{"greetings": "Hello! Welcome to OpenWhisk" }
-```
\ No newline at end of file
+```
diff --git a/java-action-archetype/pom.xml b/java-maven/action-archetype/pom.xml
similarity index 65%
rename from java-action-archetype/pom.xml
rename to java-maven/action-archetype/pom.xml
index badbf920..3022a2d1 100644
--- a/java-action-archetype/pom.xml
+++ b/java-maven/action-archetype/pom.xml
@@ -2,12 +2,20 @@
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">
4.0.0
- org.apache.openwhisk.java
- java-action-archetype
- 1.0-SNAPSHOT
+
+
+
+ org.apache.openwhisk
+ openwhisk-action-archetype
+ 1.0.0-SNAPSHOT
maven-archetype
- OpenWhisk:: Maven Archetype - Java Action
- http://openwhisk.apache.org
+ Apache OpenWhisk - Java Action Maven Archetype
+
diff --git a/java-action-archetype/src/main/resources/META-INF/maven/archetype.xml b/java-maven/action-archetype/src/main/resources/META-INF/maven/archetype.xml
similarity index 100%
rename from java-action-archetype/src/main/resources/META-INF/maven/archetype.xml
rename to java-maven/action-archetype/src/main/resources/META-INF/maven/archetype.xml
diff --git a/java-action-archetype/src/main/resources/archetype-resources/pom.xml b/java-maven/action-archetype/src/main/resources/archetype-resources/pom.xml
similarity index 71%
rename from java-action-archetype/src/main/resources/archetype-resources/pom.xml
rename to java-maven/action-archetype/src/main/resources/archetype-resources/pom.xml
index c17dbd3f..cd7c55c1 100644
--- a/java-action-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/java-maven/action-archetype/src/main/resources/archetype-resources/pom.xml
@@ -18,6 +18,11 @@
gson
${gson.version}
+
+ org.apache.openwhisk
+ openwhisk-annotations
+ 0.0.1-SNAPSHOT
+
junit
junit
@@ -42,6 +47,21 @@
+
+ org.apache.openwhisk
+ openwhisk-update-maven-plugin
+ 0.0.1-SNAPSHOT
+
+
+
+ update
+
+
+
+
+ $groupId.FunctionApp
+
+
\ No newline at end of file
diff --git a/java-action-archetype/src/main/resources/archetype-resources/src/main/java/FunctionApp.java b/java-maven/action-archetype/src/main/resources/archetype-resources/src/main/java/FunctionApp.java
similarity index 94%
rename from java-action-archetype/src/main/resources/archetype-resources/src/main/java/FunctionApp.java
rename to java-maven/action-archetype/src/main/resources/archetype-resources/src/main/java/FunctionApp.java
index 4b88ea0b..9d4727d8 100644
--- a/java-action-archetype/src/main/resources/archetype-resources/src/main/java/FunctionApp.java
+++ b/java-maven/action-archetype/src/main/resources/archetype-resources/src/main/java/FunctionApp.java
@@ -18,10 +18,12 @@
*/
import com.google.gson.JsonObject;
+import org.apache.openwhisk.annotations.Action;
/**
* Hello FunctionApp
*/
+@Action(name="demo")
public class FunctionApp {
public static JsonObject main(JsonObject args) {
JsonObject response = new JsonObject();
diff --git a/java-action-archetype/src/main/resources/archetype-resources/src/test/java/FunctionAppTest.java b/java-maven/action-archetype/src/main/resources/archetype-resources/src/test/java/FunctionAppTest.java
similarity index 100%
rename from java-action-archetype/src/main/resources/archetype-resources/src/test/java/FunctionAppTest.java
rename to java-maven/action-archetype/src/main/resources/archetype-resources/src/test/java/FunctionAppTest.java
diff --git a/java-action-archetype/src/test/resources/projects/basic/archetype.properties b/java-maven/action-archetype/src/test/resources/projects/basic/archetype.properties
similarity index 100%
rename from java-action-archetype/src/test/resources/projects/basic/archetype.properties
rename to java-maven/action-archetype/src/test/resources/projects/basic/archetype.properties
diff --git a/java-action-archetype/src/test/resources/projects/basic/goal.txt b/java-maven/action-archetype/src/test/resources/projects/basic/goal.txt
similarity index 100%
rename from java-action-archetype/src/test/resources/projects/basic/goal.txt
rename to java-maven/action-archetype/src/test/resources/projects/basic/goal.txt
diff --git a/java-maven/annotations/.travis/build.sh b/java-maven/annotations/.travis/build.sh
new file mode 100755
index 00000000..d29d3fc5
--- /dev/null
+++ b/java-maven/annotations/.travis/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+TOOLDIR="$SCRIPTDIR/../"
+
+cd $TOOLDIR
+
+mvn -V test
+
+#TODO steps that can push this artifact to nexus
diff --git a/java-maven/annotations/.travis/setup.sh b/java-maven/annotations/.travis/setup.sh
new file mode 100755
index 00000000..6aa87cff
--- /dev/null
+++ b/java-maven/annotations/.travis/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -x -e
+uname -sm
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+TOOLDIR="$SCRIPTDIR/../"
+
+# Build the parent so this compiles
+mkdir -p $TOOLDIR/target
+cd $TOOLDIR/target
+git clone https://github.com/klcodanr/incubator-openwhisk-devtools.git
+cd $TOOLDIR/target/incubator-openwhisk-devtools/java-maven/parent
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
+
+cd $TOOLDIR
+
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
diff --git a/java-maven/annotations/README.md b/java-maven/annotations/README.md
new file mode 100644
index 00000000..1ed56c4a
--- /dev/null
+++ b/java-maven/annotations/README.md
@@ -0,0 +1,68 @@
+# OpenWhisk Annotations for Java
+
+This module is part of the [Apache OpenWhisk](http://openwhisk.incubator.apache.org/) project.
+
+This project allows developers to define actions, packages, rules and triggers from annotations on java classes.
+
+## Pre-requisite
+
+The following softwares are required to use this project:
+
+* [Maven v3.3.x](https://maven.apache.org) or above
+* Java 8 or above
+* OpenWhisk CLI
+* [openwhisk-update-maven-plugin](../update-maven-plugin/)
+
+## Adding the Annotations
+
+All of the annotations are added at the class level. You can define more than one annotation per class.
+
+### Action Annotation
+
+The `@Action` annotation defines an OpenWhisk [action](https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md):
+
+```
+@Action(name = "simple-function", packageName = "test", parameters = { @Parameter(key = "Name", value = "Bob") })
+public class FunctionApp {
+```
+
+
+
+### ActionSequence Annotation
+
+The `@ActionSequence` annotation defines an OpenWhisk [action](https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md) sequence:
+
+```
+@Action(name = "simple-function", packageName = "test", parameters = { @Parameter(key = "Name", value = "Bob") })
+public class FunctionApp {
+```
+
+### Package Annotation
+
+The `@Package` annotation defines an OpenWhisk [package](https://github.com/apache/incubator-openwhisk/blob/master/docs/packages.md):
+
+```
+@Package(name = "test")
+public class FunctionApp {
+```
+
+Our recommendation would be to add this to a package-info.java class for the package containing the actions / code for a particular package.
+
+### Rule Annotation
+
+The `@Rule` annotation defines an OpenWhisk [rule](https://github.com/apache/incubator-openwhisk/blob/master/docs/triggers_rules.md):
+
+```
+@Rule(actionName="test/simple-function", name = "dostuffrule", triggerName="dostuff")
+public class FunctionApp {
+```
+
+
+### Trigger Annotation
+
+The `@Trigger` annotation defines an OpenWhisk [trigger](https://github.com/apache/incubator-openwhisk/blob/master/docs/triggers_rules.md):
+
+```
+@Trigger(feed = "/whisk.system/alarms/alarm", name = "dostuff", parameters = { @Parameter(key = "cron", value = "5 * * * *")})
+public class FunctionApp {
+```
diff --git a/java-maven/annotations/pom.xml b/java-maven/annotations/pom.xml
new file mode 100644
index 00000000..bfd80d58
--- /dev/null
+++ b/java-maven/annotations/pom.xml
@@ -0,0 +1,39 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.openwhisk
+ openwhisk
+ 1-SNAPSHOT
+
+
+
+ openwhisk-annotations
+ 0.0.1-SNAPSHOT
+ Apache OpenWhisk Annotations
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
\ No newline at end of file
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Action.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Action.java
new file mode 100644
index 00000000..42ce33bc
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Action.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation to indicate that the specified class should register an OpenWhisk action.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md
+ */
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Action {
+
+ /**
+ * The annotation values for the action
+ */
+ Annotation[] annotations() default {};
+
+ /**
+ * The maximum log size LIMIT in MB for the action (default 10)
+ */
+ int logsize() default -1;
+
+ /**
+ * the maximum memory LIMIT in MB for the action (default 256)
+ */
+ int memory() default -1;
+
+ /**
+ * The name of the action
+ */
+ String name();
+
+ /**
+ * The name of the package for this action
+ */
+ String packageName() default "";
+
+ /**
+ * The parameter values for the action
+ */
+ Parameter[] parameters() default {};
+
+ /**
+ * The timeout LIMIT in milliseconds after which the action is terminated
+ * (default 60000)
+ */
+ int timeout() default -1;
+
+ /**
+ * Treat ACTION as a web action, a raw HTTP web action, or as a standard action;
+ * yes | true = web action, raw = raw HTTP web action, no | false = standard
+ * action
+ */
+ String web() default "";
+
+ /**
+ * Secure the web action. where SECRET is true, false, or any string. Only valid
+ * when the ACTION is a web action
+ */
+ String websecure() default "";
+}
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/ActionSequence.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/ActionSequence.java
new file mode 100644
index 00000000..3f850a4b
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/ActionSequence.java
@@ -0,0 +1,87 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation to indicate that the specified class should register an
+ * OpenWhisk action sequence. Action sequences will not attempt to upload the
+ * class code, but will instead be created as a sequence of other actions.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md
+ */
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface ActionSequence {
+
+ /**
+ * The annotation values for the action
+ */
+ Annotation[] annotations() default {};
+
+ /**
+ * The maximum log size LIMIT in MB for the action (default 10)
+ */
+ int logsize() default -1;
+
+ /**
+ * the maximum memory LIMIT in MB for the action (default 256)
+ */
+ int memory() default -1;
+
+ /**
+ * The name of the action
+ */
+ String name();
+
+ /**
+ * The name of the package for this action
+ */
+ String packageName() default "";
+
+ /**
+ * The parameter values for the action
+ */
+ Parameter[] parameters() default {};
+
+ /**
+ * The comma separated sequence of actions to invoke
+ */
+ String sequence();
+
+ /**
+ * The timeout LIMIT in milliseconds after which the action is terminated
+ * (default 60000)
+ */
+ int timeout() default -1;
+
+ /**
+ * Treat ACTION as a web action, a raw HTTP web action, or as a standard action;
+ * yes | true = web action, raw = raw HTTP web action, no | false = standard
+ * action
+ */
+ String web() default "";
+
+ /**
+ * Secure the web action. where SECRET is true, false, or any string. Only valid
+ * when the ACTION is a web action
+ */
+ String websecure() default "";
+}
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Annotation.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Annotation.java
new file mode 100644
index 00000000..c8e86805
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Annotation.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Adds an annotation with a key and value to an OpenWhisk function.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/annotations.md
+ */
+@Retention(RUNTIME)
+@Target(ANNOTATION_TYPE)
+public @interface Annotation {
+
+ String key();
+
+ String value();
+
+}
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Package.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Package.java
new file mode 100644
index 00000000..f01e0617
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Package.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation to indicate that the specified class should register an
+ * OpenWhisk package.
+ *
+ * By convention, this will usually be registered on a package_info class in the
+ * package containing the actions, feeds and triggers for a particular package.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/packages.md
+ */
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Package {
+
+ /**
+ * The annotation values for the trigger
+ */
+ Annotation[] annotations() default {};
+
+ /**
+ * The name of the trigger
+ */
+ String name();
+
+ /**
+ * The parameter values for the trigger
+ */
+ Parameter[] parameters() default {};
+
+ /**
+ * The scope for this package, should be one of "yes" or "no"
+ */
+ String shared() default "";
+
+}
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Parameter.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Parameter.java
new file mode 100644
index 00000000..70484914
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Parameter.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Adds an parameter with a key and value to an OpenWhisk function.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/parameters.md
+ */
+@Retention(RUNTIME)
+@Target(ANNOTATION_TYPE)
+public @interface Parameter {
+
+ String key();
+
+ String value();
+}
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Rule.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Rule.java
new file mode 100644
index 00000000..7f45cfc8
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Rule.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation to indicate that the specified class should register an
+ * OpenWhisk rule.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/triggers_rules.md
+ */
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Rule {
+
+ /**
+ * The name of the action to execute for this trigger
+ */
+ String actionName();
+
+ /**
+ * The name of the trigger
+ */
+ String name();
+
+ /**
+ * The name of the trigger to execute this rule
+ */
+ String triggerName();
+
+}
diff --git a/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Trigger.java b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Trigger.java
new file mode 100644
index 00000000..c784b225
--- /dev/null
+++ b/java-maven/annotations/src/main/java/org/apache/openwhisk/annotations/Trigger.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * Licensed 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.openwhisk.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation to indicate that the specified class should register an
+ * OpenWhisk trigger.
+ *
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/triggers_rules.md
+ */
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Trigger {
+
+ /**
+ * The annotation values for the trigger
+ */
+ Annotation[] annotations() default {};
+
+ /**
+ * The name of the action to feed this trigger
+ */
+ String feed() default "";
+
+ /**
+ * The name of the trigger
+ */
+ String name();
+
+ /**
+ * The parameter values for the trigger
+ */
+ Parameter[] parameters() default {};
+
+}
diff --git a/java-maven/parent/.travis/build.sh b/java-maven/parent/.travis/build.sh
new file mode 100755
index 00000000..d29d3fc5
--- /dev/null
+++ b/java-maven/parent/.travis/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+TOOLDIR="$SCRIPTDIR/../"
+
+cd $TOOLDIR
+
+mvn -V test
+
+#TODO steps that can push this artifact to nexus
diff --git a/java-action-archetype/.travis/setup.sh b/java-maven/parent/.travis/setup.sh
similarity index 100%
rename from java-action-archetype/.travis/setup.sh
rename to java-maven/parent/.travis/setup.sh
diff --git a/java-maven/parent/README.md b/java-maven/parent/README.md
new file mode 100644
index 00000000..1be35806
--- /dev/null
+++ b/java-maven/parent/README.md
@@ -0,0 +1,5 @@
+# Apache OpenWhisk Parent
+
+This module is part of the [Apache OpenWhisk](https://openwhisk.incubator.apache.org) project.
+
+This is the parent project for Apache OpenWhisk.
diff --git a/java-maven/parent/pom.xml b/java-maven/parent/pom.xml
new file mode 100644
index 00000000..76d6f43e
--- /dev/null
+++ b/java-maven/parent/pom.xml
@@ -0,0 +1,241 @@
+
+
+
+ 4.0.0
+
+
+ org.apache
+ apache
+ 19
+
+
+
+ org.apache.openwhisk
+ openwhisk
+ pom
+ 1-SNAPSHOT
+
+ Apache OpenWhisk - Parent
+ The parent project for Apache OpenWhisk
+ 2016
+
+ http://openwhisk.incubator.apache.org/
+
+
+ GitHub
+ https://github.com/apache/incubator-openwhisk/issues
+
+
+
+
+ UTF-8
+ UTF-8
+
+
+
+ scm:git:https://gitbox.apache.org/repos/asf?p=incubator-openwhisk-devtools.git
+ scm:git:https://gitbox.apache.org/repos/asf?p=incubator-openwhisk-devtools.git
+ https://gitbox.apache.org/repos/asf?p=incubator-openwhisk-devtools.git
+ HEAD
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+
+ javadoc
+
+
+
+
+ maven
+ *.impl:*.internal:${site.javadoc.exclude}
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ true
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+ org.codehaus.mojo
+ ianal-maven-plugin
+
+
+
+ verify-legal-files
+
+
+
+ true
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+
+
+ org.apache.maven.release
+ maven-release-oddeven-policy
+ 2.5.3
+
+
+
+ OddEvenVersionPolicy
+
+
+
+ org.apache.rat
+ apache-rat-plugin
+
+
+
+ src/main/appended-resources/META-INF/*
+
+ velocity.log
+
+ target/*
+
+ README.md
+
+ maven-eclipse.xml
+ .*
+ .*/**
+
+ **/*.json
+
+ DEPENDENCIES
+
+ **/*.rej
+
+ hs_err_*.log
+
+
+
+
+ verify
+
+ check
+
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ ianal-maven-plugin
+ 1.0-alpha-1
+
+
+
+
+
+
+
+ Apache OpenWhisk Development List
+
+ dev-subscribe@openwhisk.incubator.apache.org
+
+
+ dev-unsubscribe@openwhisk.incubator.apache.org
+
+ dev at sling.apache.org
+
+ http://mail-archives.apache.org/mod_mbox/openwhisk-dev/
+
+
+
+ http://openwhisk-dev.markmail.org/
+
+
+ http://www.mail-archive.com/dev@openwhisk.incubator.apache.org/
+
+
+
+
+
+
+
+
+ Apache OpenWhisk Project
+ OpenWhisk
+ http://openwhisk.incubator.apache.org/contributors
+
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+ apache.snapshots
+ Apache Snapshot Repository
+ http://repository.apache.org/snapshots
+
+ false
+
+
+
+
+
\ No newline at end of file
diff --git a/java-maven/update-maven-plugin/.travis/build.sh b/java-maven/update-maven-plugin/.travis/build.sh
new file mode 100755
index 00000000..d29d3fc5
--- /dev/null
+++ b/java-maven/update-maven-plugin/.travis/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+TOOLDIR="$SCRIPTDIR/../"
+
+cd $TOOLDIR
+
+mvn -V test
+
+#TODO steps that can push this artifact to nexus
diff --git a/java-maven/update-maven-plugin/.travis/setup.sh b/java-maven/update-maven-plugin/.travis/setup.sh
new file mode 100755
index 00000000..ece1e793
--- /dev/null
+++ b/java-maven/update-maven-plugin/.travis/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -x -e
+uname -sm
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+TOOLDIR="$SCRIPTDIR/../"
+
+# Build the parent so this compiles
+mkdir -p $TOOLDIR/target
+cd $TOOLDIR/target
+git clone https://github.com/klcodanr/incubator-openwhisk-devtools.git
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -q clean install -f $TOOLDIR/target/incubator-openwhisk-devtools/java-maven/parent/pom.xml
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -q clean install -f $TOOLDIR/target/incubator-openwhisk-devtools/java-maven/annotations/pom.xml
+
+cd $TOOLDIR
+
+mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V clean install
diff --git a/java-maven/update-maven-plugin/README.md b/java-maven/update-maven-plugin/README.md
new file mode 100644
index 00000000..6a8f44ce
--- /dev/null
+++ b/java-maven/update-maven-plugin/README.md
@@ -0,0 +1,146 @@
+# OpenWhisk Update Maven Plugin for Java
+
+This module is part of the [Apache OpenWhisk](http://openwhisk.incubator.apache.org/) project.
+
+This project automatically installs OpenWhisk actions, packages, rules and triggers based on Annotations added to Java classes.
+
+## Pre-requisite
+
+The following softwares are required to use this project:
+
+* [Maven v3.3.x](https://maven.apache.org) or above
+* Java 8 or above
+* OpenWhisk CLI
+* [openwhisk-annotations](../annotations/)
+
+## Adding the Plugin
+
+To enable the plugin in your Maven project, add the following into the build > plugins element within your pom.xml
+
+```
+
+ org.apache.openwhisk
+ openwhisk-update-maven-plugin
+ [VERSION]
+
+
+
+ update
+
+
+
+
+ com.test.FunctionApp
+
+
+```
+
+## Deploying to OpenWhisk
+
+When you build your code with `mvn clean install`, you should see log messages similar to the following:
+
+```
+[INFO] ok: got package test
+[INFO] {
+[INFO] "namespace": "user@email_dev",
+[INFO] "name": "test",
+[INFO] "version": "0.0.13",
+[INFO] "publish": false,
+[INFO] "binding": {},
+[INFO] "actions": [
+[INFO] {
+[INFO] "name": "simple-email",
+[INFO] "version": "0.0.11",
+[INFO] "annotations": [
+[INFO] {
+[INFO] "key": "exec",
+[INFO] "value": "java"
+[INFO] },
+[INFO] {
+[INFO] "key": "web-export",
+[INFO] "value": true
+[INFO] },
+[INFO] {
+[INFO] "key": "raw-http",
+[INFO] "value": false
+[INFO] },
+[INFO] {
+[INFO] "key": "final",
+[INFO] "value": true
+[INFO] }
+[INFO] ]
+[INFO] }
+[INFO] ]
+[INFO] }
+[INFO] Updating OpenWhisk package test
+[INFO] ok: updated package test
+[INFO] ok: got action test/simple-action
+[INFO] {
+[INFO] "namespace": "user@email/test",
+[INFO] "name": "simple-action",
+[INFO] "version": "0.0.11",
+[INFO] "exec": {
+[INFO] "kind": "java",
+[INFO] "main": "com.test.FunctionApp",
+[INFO] "binary": true
+[INFO] },
+[INFO] "annotations": [
+[INFO] {
+[INFO] "key": "exec",
+[INFO] "value": "java"
+[INFO] },
+[INFO] {
+[INFO] "key": "web-export",
+[INFO] "value": true
+[INFO] },
+[INFO] {
+[INFO] "key": "raw-http",
+[INFO] "value": false
+[INFO] },
+[INFO] {
+[INFO] "key": "final",
+[INFO] "value": true
+[INFO] }
+[INFO] ],
+[INFO] "parameters": [
+[INFO] {
+[INFO] "key": "Name",
+[INFO] "value": "Bob"
+[INFO] }
+[INFO] ],
+[INFO] "limits": {
+[INFO] "timeout": 60000,
+[INFO] "memory": 256,
+[INFO] "logs": 10
+[INFO] },
+[INFO] "publish": false
+[INFO] }
+[INFO] Updating OpenWhisk action simple-action
+[INFO] ok: updated action test/simple-action
+[INFO] OpenWhisk Updates Successful!
+```
+
+This will indicate the status of the deployment to OpenWhisk. If the deployment fails, it will provide a log message with details on how to resolve. You can add the `-X` parameter to enable debug level logging in the plugin.
+
+## FAQ
+
+**How do I change the Whisk CLI Path?**
+
+Add a parameter cli into the configuration element of the plugin with the path to the Whisk CLI for your environment, for example to support using BlueMix Functions:
+
+```
+
+ bx wsk
+ [...]
+
+```
+
+**How do I update more than one class in my project in OpenWhisk?**
+
+The main element is a comma-separated list of classes, the plugin will evaluate each class in the list and install anything defined in annotations. For example:
+
+```
+
+ com.test.FunctionApp,com.test.FunctionApp2
+
+```
diff --git a/java-maven/update-maven-plugin/pom.xml b/java-maven/update-maven-plugin/pom.xml
new file mode 100644
index 00000000..3550f10a
--- /dev/null
+++ b/java-maven/update-maven-plugin/pom.xml
@@ -0,0 +1,145 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.openwhisk
+ openwhisk
+ 1-SNAPSHOT
+
+
+
+ openwhisk-update-maven-plugin
+ 0.0.1-SNAPSHOT
+ maven-plugin
+
+ OpenWhisk Update Function Maven Plugin
+
+ https://openwhisk.apache.org/
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ 3.2
+ provided
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 3.0.8
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.4
+
+
+ org.apache.openwhisk
+ openwhisk-annotations
+ 0.0.1-SNAPSHOT
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+
+ openwhisk-update
+ true
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+
+
+ help-goal
+
+ helpmojo
+
+
+
+
+
+
+
+
+ run-its
+
+
+
+
+ org.apache.maven.plugins
+ maven-invoker-plugin
+ 1.7
+
+ true
+ ${project.build.directory}/it
+
+ */pom.xml
+
+ verify
+ ${project.build.directory}/local-repo
+ src/it/settings.xml
+
+ clean
+ test-compile
+
+
+
+
+ integration-test
+
+ install
+ integration-test
+ verify
+
+
+
+
+
+
+
+
+
+
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/TYPE.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/TYPE.java
new file mode 100644
index 00000000..2186ca5e
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/TYPE.java
@@ -0,0 +1,43 @@
+/*
+ * 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.openwhisk.maven;
+
+/**
+ * An enum of the different types supported by OpenWhisk
+ */
+public enum TYPE {
+
+ /**
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md
+ */
+ ACTION,
+
+ /**
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/packages.md
+ */
+ PACKAGE,
+
+ /**
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/triggers_rules.md#associating-triggers-and-actions-by-using-rules
+ */
+ RULE,
+
+ /**
+ * @see https://github.com/apache/incubator-openwhisk/blob/master/docs/triggers_rules.md
+ */
+ TRIGGER
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/UpdateWhiskMojo.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/UpdateWhiskMojo.java
new file mode 100644
index 00000000..583ed84f
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/UpdateWhiskMojo.java
@@ -0,0 +1,260 @@
+/*
+ * 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.openwhisk.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.openwhisk.annotations.Action;
+import org.apache.openwhisk.annotations.ActionSequence;
+import org.apache.openwhisk.annotations.Package;
+import org.apache.openwhisk.annotations.Rule;
+import org.apache.openwhisk.annotations.Trigger;
+import org.apache.openwhisk.maven.commands.ActionCommand;
+import org.apache.openwhisk.maven.commands.ActionSequenceCommand;
+import org.apache.openwhisk.maven.commands.PackageCommand;
+import org.apache.openwhisk.maven.commands.RuleCommand;
+import org.apache.openwhisk.maven.commands.TriggerCommand;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A goal which installs a Java Action into an OpenWhisk instance
+ */
+@Mojo(name = "update", defaultPhase = LifecyclePhase.INSTALL)
+public class UpdateWhiskMojo extends AbstractMojo {
+
+ /**
+ * Specify the whisk API HOST for connecting to OpenWhisk
+ */
+ @Parameter(property = "openwhisk.apihost", required = false)
+ private String apihost;
+
+ /**
+ * Specify the whisk API VERSION for connecting to OpenWhisk
+ */
+ @Parameter(property = "openwhisk.apiversion", required = false)
+ private String apiversion;
+
+ /**
+ * Specify the authorization KEY for connecting to OpenWhisk
+ */
+ @Parameter(property = "openwhisk.auth", required = false)
+ private String auth;
+
+ /**
+ * Specify the client cert for connecting to OpenWhisk
+ */
+ @Parameter(property = "openwhisk.cert", required = false)
+ private String cert;
+
+ /**
+ * The class directory for finding the main class
+ */
+ @Parameter(defaultValue = "${project.build.directory}/classes", required = true, readonly = true)
+ private String classesDirectory;
+
+ /**
+ * The executable for OpenWhisk CLI
+ */
+ @Parameter(defaultValue = "wsk", property = "openwhisk.cli", required = true)
+ private String cli;
+
+ /**
+ * Whether to debug the connection with OpenWhisk
+ */
+ @Parameter(defaultValue = "false", property = "openwhisk.debug", required = false)
+ private Boolean debug;
+
+ /**
+ * Whether to bypass signature checking for the connection with OpenWhisk
+ */
+ @Parameter(defaultValue = "false", property = "openwhisk.insecure", required = false)
+ private Boolean insecure;
+
+ /**
+ * The jar file for OpenWhisk to use for creating the functions
+ */
+ @Parameter(defaultValue = "${project.build.directory}/${project.build.finalName}.jar", property = "openwhisk.jar", required = true)
+ private String jar;
+
+ /**
+ * Specify the client key for connecting to OpenWhisk
+ */
+ @Parameter(property = "openwhisk.key", required = false)
+ private String key;
+
+ /**
+ * Define the logger as a member for easy access
+ */
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * A comma separated list of main classes to load into OpenWhisk
+ */
+ @Parameter(defaultValue = "false", required = true)
+ private String main;
+
+ /**
+ * The namespace to use to deploy to OpenWhisk
+ */
+ @Parameter(property = "openwhisk.namespace", required = false)
+ private String namespace;
+
+ public void execute() throws MojoExecutionException {
+
+ final List globalFlags = calculateGlobalFlags();
+
+ List init = new ArrayList();
+
+ if (cli.contains(" ")) {
+ for (String c : cli.split(" ")) {
+ init.add(c);
+ }
+ } else {
+ init.add(cli);
+ }
+
+ for (String mainClass : this.main.split("\\,")) {
+ mainClass = mainClass.trim();
+ try {
+ processAnnotations(mainClass, init, globalFlags);
+ } catch (IOException e) {
+ throw new MojoExecutionException("IOException occured executing OpenWhisk update", e);
+ }
+ }
+ log.info("OpenWhisk Updates Successful!");
+
+ }
+
+ private List calculateGlobalFlags() {
+ List cmd = new ArrayList();
+ if (debug) {
+ log.debug("Adding debugging flags");
+ cmd.add("-v");
+ cmd.add("-d");
+ }
+ if (insecure) {
+ log.debug("Adding insecure flags");
+ cmd.add("-i");
+ }
+ if (StringUtils.isNotBlank(apihost)) {
+ log.debug("Setting API Host to " + apihost);
+ cmd.add("--apihost");
+ cmd.add(apihost);
+ }
+ if (StringUtils.isNotBlank(apiversion)) {
+ log.debug("Setting API Version to " + apiversion);
+ cmd.add("--apiversion");
+ cmd.add(apiversion);
+ }
+ if (StringUtils.isNotBlank(auth)) {
+ log.debug("Setting auth to " + auth);
+ cmd.add("--auth");
+ cmd.add(auth);
+ }
+ if (StringUtils.isNotBlank(cert)) {
+ log.debug("Setting client cert to " + cert);
+ cmd.add("--cert");
+ cmd.add(cert);
+ }
+ if (StringUtils.isNotBlank(key)) {
+ log.debug("Setting client key to " + key);
+ cmd.add("--key");
+ cmd.add(key);
+ }
+ return cmd;
+ }
+
+ private void processAnnotations(String mc, List cmd, List globalFlags)
+ throws MojoExecutionException, IOException {
+ URLClassLoader cl = null;
+ try {
+ cl = new URLClassLoader(new URL[] { new File(this.classesDirectory).toURI().toURL() },
+ Thread.currentThread().getContextClassLoader());
+ Class> mainClass = cl.loadClass(mc);
+ log.debug("Loaded main class " + mainClass.getCanonicalName());
+
+ Package[] packages = mainClass.getDeclaredAnnotationsByType(Package.class);
+ if (packages != null) {
+ for (Package pkg : packages) {
+ PackageCommand pc = new PackageCommand(namespace, pkg, cmd, globalFlags);
+ pc.execute();
+ }
+ }
+
+ Action[] actions = mainClass.getDeclaredAnnotationsByType(Action.class);
+ if (actions != null) {
+ for (Action action : actions) {
+ ActionCommand ac = new ActionCommand(namespace, action, cmd, globalFlags, jar, mc);
+ ac.execute();
+ }
+ }
+
+ ActionSequence[] actionSequences = mainClass.getDeclaredAnnotationsByType(ActionSequence.class);
+ if (actionSequences != null) {
+ for (ActionSequence actionSequence : actionSequences) {
+ ActionSequenceCommand asc = new ActionSequenceCommand(namespace, actionSequence, cmd, globalFlags);
+ asc.execute();
+ }
+ }
+
+ Trigger[] triggers = mainClass.getDeclaredAnnotationsByType(Trigger.class);
+ if (triggers != null) {
+ for (Trigger trigger : triggers) {
+ TriggerCommand tc = new TriggerCommand(namespace, trigger, cmd, globalFlags);
+ tc.execute();
+ }
+ }
+
+ Rule[] rules = mainClass.getDeclaredAnnotationsByType(Rule.class);
+ if (rules != null) {
+ for (Rule rule : rules) {
+ RuleCommand rc = new RuleCommand(namespace, rule, cmd, globalFlags);
+ rc.execute();
+ }
+ }
+
+ } catch (ClassNotFoundException e) {
+ log.error("Unable to find main class: " + main, e);
+ throw new MojoExecutionException("Unable to find main class: " + main, e);
+ } catch (MalformedURLException e) {
+ log.error("Malformed URL for class directory: " + classesDirectory, e);
+ throw new MojoExecutionException("Malformed URL for class directory: " + classesDirectory, e);
+ } finally {
+ if (cl != null) {
+ try {
+ cl.close();
+ } catch (IOException e) {
+ // Swallow the exception
+ }
+ }
+ }
+ }
+
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/ActionCommand.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/ActionCommand.java
new file mode 100644
index 00000000..3ee50ac9
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/ActionCommand.java
@@ -0,0 +1,75 @@
+/*
+ * 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.openwhisk.maven.commands;
+
+import java.util.List;
+
+import org.apache.openwhisk.annotations.Action;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A command for creating an action in OpenWhisk
+ */
+public class ActionCommand extends Command {
+
+ private final Logger log = LoggerFactory.getLogger(ActionCommand.class);
+
+ public ActionCommand(String namespace, Action action, List init, List globalFlags, String jar, String main) {
+ super(init, namespace, action.packageName(), action.name(), globalFlags);
+
+ cmd.add(jar);
+ cmd.add("--main");
+ cmd.add(main);
+
+ this.addAnnotations(action.annotations());
+ this.addParameters(action.parameters());
+
+ if (action.logsize() != -1) {
+ log.debug("Setting logsize to " + action.logsize());
+ cmd.add("--logsize");
+ cmd.add(String.valueOf(action.logsize()));
+ }
+ if (action.memory() != -1) {
+ log.debug("Setting memory to " + action.memory());
+ cmd.add("--memory");
+ cmd.add(String.valueOf(action.memory()));
+ }
+ if (action.timeout() != -1) {
+ log.debug("Setting timeout to " + action.timeout());
+ cmd.add("--timeout");
+ cmd.add(String.valueOf(action.timeout()));
+ }
+ if (StringUtils.isNotBlank(action.web())) {
+ log.debug("Setting web to " + action.web());
+ cmd.add("--web");
+ cmd.add(action.web());
+ }
+ if (StringUtils.isNotBlank(action.websecure())) {
+ log.debug("Setting web-secure to " + action.websecure());
+ cmd.add("--web-secure");
+ cmd.add(action.websecure());
+ }
+ }
+
+ @Override
+ public String getType() {
+ return "action";
+ }
+
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/ActionSequenceCommand.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/ActionSequenceCommand.java
new file mode 100644
index 00000000..6960ff22
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/ActionSequenceCommand.java
@@ -0,0 +1,77 @@
+/*
+ * 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.openwhisk.maven.commands;
+
+import java.util.List;
+
+import org.apache.openwhisk.annotations.ActionSequence;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A command for creating an action sequence in OpenWhisk
+ */
+public class ActionSequenceCommand extends Command {
+
+ private final Logger log = LoggerFactory.getLogger(ActionSequenceCommand.class);
+
+ public ActionSequenceCommand(String namespace, ActionSequence actionSequence, List init,
+ List globalFlags) {
+ super(init, namespace, actionSequence.packageName(), actionSequence.name(), globalFlags);
+
+ this.addAnnotations(actionSequence.annotations());
+ this.addParameters(actionSequence.parameters());
+
+ if (actionSequence.logsize() != -1) {
+ log.debug("Setting logsize to " + actionSequence.logsize());
+ cmd.add("--logsize");
+ cmd.add(String.valueOf(actionSequence.logsize()));
+ }
+ if (actionSequence.memory() != -1) {
+ log.debug("Setting memory to " + actionSequence.memory());
+ cmd.add("--memory");
+ cmd.add(String.valueOf(actionSequence.memory()));
+ }
+ if (StringUtils.isNotBlank(actionSequence.sequence())) {
+ log.debug("Setting sequence to " + actionSequence.sequence());
+ cmd.add("--sequence");
+ cmd.add(actionSequence.sequence());
+ }
+ if (actionSequence.timeout() != -1) {
+ log.debug("Setting timeout to " + actionSequence.timeout());
+ cmd.add("--timeout");
+ cmd.add(String.valueOf(actionSequence.timeout()));
+ }
+ if (StringUtils.isNotBlank(actionSequence.web())) {
+ log.debug("Setting web to " + actionSequence.web());
+ cmd.add("--web");
+ cmd.add(actionSequence.web());
+ }
+ if (StringUtils.isNotBlank(actionSequence.websecure())) {
+ log.debug("Setting web-secure to " + actionSequence.websecure());
+ cmd.add("--web-secure");
+ cmd.add(actionSequence.websecure());
+ }
+ }
+
+ @Override
+ public String getType() {
+ return "action";
+ }
+
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/Command.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/Command.java
new file mode 100644
index 00000000..2f516494
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/Command.java
@@ -0,0 +1,182 @@
+/*
+ * 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.openwhisk.maven.commands;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.openwhisk.annotations.Annotation;
+import org.apache.openwhisk.annotations.Parameter;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An abstract OpenWhisk command, base class for the specific types to extend.
+ */
+public abstract class Command {
+
+ private static final Logger log = LoggerFactory.getLogger(Command.class);
+
+ protected final List cmd = new ArrayList();
+
+ private final List getCmd = new ArrayList();
+
+ private List globalFlags = null;
+
+ private String name;
+
+ private String namespace;
+
+ public Command(List init, String namespace, String name, List globalFlags) {
+ this(init, namespace, "", name, globalFlags);
+ }
+
+ public Command(List init, String namespace, String pkg, String name, List globalFlags) {
+ log.debug("Creating command for {}/{}", pkg, name);
+ this.setNamespace(namespace);
+ this.setName(name);
+ this.cmd.addAll(init);
+ this.cmd.add(getType());
+
+ // figure out the name
+ String fqn = "";
+ if(StringUtils.isNotEmpty(namespace)) {
+ fqn = "/"+namespace;
+ }
+ if (StringUtils.isNotBlank(pkg)) {
+ fqn+=pkg + "/" ;
+ }
+ fqn+=name;
+
+ // construct the get command
+ getCmd.addAll(init);
+ getCmd.add(getType());
+ getCmd.add("get");
+ getCmd.add(fqn);
+ getCmd.addAll(globalFlags);
+
+ if (itemExists()) {
+ this.cmd.add("update");
+ } else {
+ this.cmd.add("create");
+ }
+ this.cmd.add(fqn);
+ this.globalFlags = globalFlags;
+ }
+
+ protected void addAnnotations(Annotation[] annotations) {
+ if (annotations != null) {
+ for (Annotation a : annotations) {
+ cmd.add("-a");
+ cmd.add(a.key());
+ cmd.add(a.value());
+ }
+ }
+ }
+
+ protected void addParameters(Parameter[] parameters) {
+ if (parameters != null) {
+ for (Parameter p : parameters) {
+ cmd.add("-p");
+ cmd.add(p.key());
+ cmd.add(p.value());
+ }
+ }
+ }
+
+ public void execute() throws IOException, MojoExecutionException {
+
+ log.info("Updating OpenWhisk {} {}", getType(), name);
+
+ cmd.addAll(globalFlags);
+
+ log.debug("Executing OpenWhisk CLI Command with command: {}", cmd);
+ ProcessBuilder builder = new ProcessBuilder();
+ builder.command(cmd);
+ Process pr = builder.start();
+
+ readInput(pr.getInputStream(), false);
+ if (readInput(pr.getErrorStream(), true)) {
+ throw new MojoExecutionException("Call to OpenWhisk failed!");
+ }
+
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public abstract String getType();
+
+ private boolean itemExists() {
+ boolean exists = true;
+ try {
+ log.debug("Checking to see if {} {} exists", getType(), name);
+
+ log.debug("Executing OpenWhisk CLI Command with command: {}", getCmd);
+ ProcessBuilder builder = new ProcessBuilder();
+ builder.command(getCmd);
+ Process pr = builder.start();
+
+ readInput(pr.getInputStream(), false);
+ if (readInput(pr.getErrorStream(), false)) {
+ exists = false;
+ }
+ } catch (Exception e) {
+ log.warn("Exception checking to see if entity exists, ", e);
+ exists = false;
+ }
+ return exists;
+ }
+
+ private boolean readInput(InputStream is, boolean err) {
+ boolean read = false;
+ BufferedReader input = new BufferedReader(new InputStreamReader(is));
+ String line = null;
+ try {
+ while ((line = input.readLine()) != null) {
+ if (err) {
+ log.error(line);
+ } else {
+ log.info(line);
+ }
+ read = true;
+ }
+ } catch (IOException e) {
+ log.error("Exception reading response from OpenWhisk CLI Command", e);
+ }
+ return read;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/PackageCommand.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/PackageCommand.java
new file mode 100644
index 00000000..2c0c8e66
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/PackageCommand.java
@@ -0,0 +1,52 @@
+/*
+ * 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.openwhisk.maven.commands;
+
+import java.util.List;
+
+import org.apache.openwhisk.annotations.Package;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A command for creating a package in OpenWhisk
+ */
+public class PackageCommand extends Command {
+
+ private final Logger log = LoggerFactory.getLogger(PackageCommand.class);
+
+ public PackageCommand(String namespace, Package pkg, List init, List globalFlags) {
+ super(init, namespace, pkg.name(), globalFlags);
+
+ this.addAnnotations(pkg.annotations());
+ this.addParameters(pkg.parameters());
+
+ if (!StringUtils.isBlank(pkg.shared())) {
+ log.debug("Setting shared to {}", pkg.shared());
+ cmd.add("--shared");
+ cmd.add(pkg.shared());
+ }
+ }
+
+
+ @Override
+ public String getType() {
+ return "package";
+ }
+
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/RuleCommand.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/RuleCommand.java
new file mode 100644
index 00000000..4ee092ba
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/RuleCommand.java
@@ -0,0 +1,47 @@
+/*
+ * 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.openwhisk.maven.commands;
+
+import java.util.List;
+
+import org.apache.openwhisk.annotations.Rule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A command for creating a rule in OpenWhisk
+ */
+public class RuleCommand extends Command {
+
+ private final Logger log = LoggerFactory.getLogger(RuleCommand.class);
+
+ public RuleCommand(String namespace, Rule rule, List init, List globalFlags) {
+ super(init, namespace, rule.name(), globalFlags);
+
+ log.debug("Setting trigger name to {}", rule.triggerName());
+ cmd.add(rule.triggerName());
+
+ log.debug("Setting trigger name to {}", rule.actionName());
+ cmd.add(rule.actionName());
+ }
+
+ @Override
+ public String getType() {
+ return "rule";
+ }
+
+}
diff --git a/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/TriggerCommand.java b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/TriggerCommand.java
new file mode 100644
index 00000000..72f19535
--- /dev/null
+++ b/java-maven/update-maven-plugin/src/main/java/org/apache/openwhisk/maven/commands/TriggerCommand.java
@@ -0,0 +1,50 @@
+/*
+ * 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.openwhisk.maven.commands;
+
+import java.util.List;
+
+import org.apache.openwhisk.annotations.Trigger;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A command for creating a trigger in OpenWhisk
+ */
+public class TriggerCommand extends Command {
+
+ private final Logger log = LoggerFactory.getLogger(RuleCommand.class);
+
+ public TriggerCommand(String namespace, Trigger trigger, List init, List globalFlags) {
+ super(init, namespace, trigger.name(), globalFlags);
+
+ this.addAnnotations(trigger.annotations());
+ this.addParameters(trigger.parameters());
+ if (StringUtils.isBlank(trigger.feed())) {
+ log.debug("Setting feed to {}", trigger.feed());
+ cmd.add("--feed");
+ cmd.add(trigger.feed());
+ }
+ }
+
+ @Override
+ public String getType() {
+ return "trigger";
+ }
+
+}
diff --git a/maven-java/.editorconfig b/maven-java-example/.editorconfig
similarity index 100%
rename from maven-java/.editorconfig
rename to maven-java-example/.editorconfig
diff --git a/maven-java/.gitignore b/maven-java-example/.gitignore
similarity index 100%
rename from maven-java/.gitignore
rename to maven-java-example/.gitignore
diff --git a/maven-java/.mvn/wrapper/maven-wrapper.jar b/maven-java-example/.mvn/wrapper/maven-wrapper.jar
similarity index 100%
rename from maven-java/.mvn/wrapper/maven-wrapper.jar
rename to maven-java-example/.mvn/wrapper/maven-wrapper.jar
diff --git a/maven-java/.mvn/wrapper/maven-wrapper.properties b/maven-java-example/.mvn/wrapper/maven-wrapper.properties
similarity index 100%
rename from maven-java/.mvn/wrapper/maven-wrapper.properties
rename to maven-java-example/.mvn/wrapper/maven-wrapper.properties
diff --git a/maven-java/README.md b/maven-java-example/README.md
similarity index 100%
rename from maven-java/README.md
rename to maven-java-example/README.md
diff --git a/maven-java/dependency-reduced-pom.xml b/maven-java-example/dependency-reduced-pom.xml
similarity index 100%
rename from maven-java/dependency-reduced-pom.xml
rename to maven-java-example/dependency-reduced-pom.xml
diff --git a/maven-java/mvnw b/maven-java-example/mvnw
similarity index 100%
rename from maven-java/mvnw
rename to maven-java-example/mvnw
diff --git a/maven-java/mvnw.cmd b/maven-java-example/mvnw.cmd
similarity index 100%
rename from maven-java/mvnw.cmd
rename to maven-java-example/mvnw.cmd
diff --git a/maven-java/pom.xml b/maven-java-example/pom.xml
similarity index 96%
rename from maven-java/pom.xml
rename to maven-java-example/pom.xml
index 0db049e5..aad81135 100644
--- a/maven-java/pom.xml
+++ b/maven-java-example/pom.xml
@@ -3,7 +3,7 @@
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">
4.0.0
openwhisk.example.maven
- maven-java
+ maven-java-example
1.0-SNAPSHOT
jar
OpenWhisk::Examples::Maven with External Deps
diff --git a/maven-java/src/main/java/org/apache/openwhisk/example/maven/App.java b/maven-java-example/src/main/java/org/apache/openwhisk/example/maven/App.java
similarity index 100%
rename from maven-java/src/main/java/org/apache/openwhisk/example/maven/App.java
rename to maven-java-example/src/main/java/org/apache/openwhisk/example/maven/App.java