From b06f2ab3a2940d6c396476930b08d2c227f04121 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 29 Dec 2010 18:10:00 +0100 Subject: [PATCH] added an plugin archetype --- maven/pom.xml | 1 + maven/scm-plugin-archetype/pom.xml | 18 ++++ .../META-INF/maven/archetype-metadata.xml | 36 ++++++++ .../resources/META-INF/maven/archetype.xml | 24 ++++++ .../resources/archetype-resources/pom.xml | 39 +++++++++ .../src/main/java/HelloResource.java | 83 +++++++++++++++++++ .../main/resources/META-INF/scm/plugin.xml | 25 ++++++ .../src/main/resources/scm/sample.hello.js | 68 +++++++++++++++ 8 files changed, 294 insertions(+) create mode 100644 maven/scm-plugin-archetype/pom.xml create mode 100644 maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml create mode 100644 maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml create mode 100644 maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java create mode 100644 maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml create mode 100644 maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/scm/sample.hello.js diff --git a/maven/pom.xml b/maven/pom.xml index e9f78282f4..1af1b5accc 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -17,6 +17,7 @@ scm-web-compressor + scm-plugin-archetype diff --git a/maven/scm-plugin-archetype/pom.xml b/maven/scm-plugin-archetype/pom.xml new file mode 100644 index 0000000000..7acb7bbcd9 --- /dev/null +++ b/maven/scm-plugin-archetype/pom.xml @@ -0,0 +1,18 @@ + + + + 4.0.0 + + + scm-maven-plugins + sonia.scm.maven + 1.0-M5-SNAPSHOT + + + sonia.scm.maven + scm-plugin-archetype + 1.0-M5-SNAPSHOT + scm-plugin-archetype + + diff --git a/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..0e81d5fd78 --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,36 @@ + + + + + + + + + src/main/java + + **/*.java + + + + + src/main/resources + + **/*.xml + + + + + src/main/resources + + **/*.js + + + + + \ No newline at end of file diff --git a/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..377c10511d --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,24 @@ + + + + + + + scm-plugin + + + src/main/java/HelloResource.java + + + + src/main/resources/META-INF/scm/plugin.xml + src/main/resources/scm/sample.hello.js + + + \ No newline at end of file diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..a516047fc7 --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,39 @@ +#set($dollar = '$') + + + + 4.0.0 + + + scm-plugins + sonia.scm.plugins + 1.0-M5-SNAPSHOT + + + ${groupId} + ${artifactId} + jar + ${version} + ${dollar}{project.artifactId} + + + + + javax.servlet + servlet-api + ${servlet.version} + provided + + + + + + sonia.scm + scm-test + 1.0-M5-SNAPSHOT + test + + + + + \ No newline at end of file diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java new file mode 100644 index 0000000000..a79b6e49fd --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/java/HelloResource.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + +package ${package}; + +//~--- non-JDK imports -------------------------------------------------------- + +import com.google.inject.Inject; +import com.google.inject.Provider; + +import sonia.scm.security.SecurityContext; + +//~--- JDK imports ------------------------------------------------------------ + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("hello") +public class HelloResource { + + /** + * Constructs ... + * + * + * @param securityContextProvider + */ + @Inject + public HelloResource(Provider securityContextProvider) + { + message = "Hello " + + securityContextProvider.get().getUser().getDisplayName(); + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + @GET + @Produces(MediaType.TEXT_PLAIN) + public String getHelloMessage() + { + return message; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private String message; +} diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml new file mode 100644 index 0000000000..967414b397 --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/scm/plugin.xml @@ -0,0 +1,25 @@ +#set($dollar = '$') + + + + + ${dollar}{project.groupId} + ${dollar}{project.artifactId} + ${dollar}{project.version} + ${dollar}{project.name} + ${dollar}{project.description} + + + + + ${package} + + + + + + + diff --git a/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/scm/sample.hello.js b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/scm/sample.hello.js new file mode 100644 index 0000000000..5169965553 --- /dev/null +++ b/maven/scm-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/scm/sample.hello.js @@ -0,0 +1,68 @@ +/* * + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + +function sayHello(){ + Ext.Ajax.request({ + url: restUrl + 'hello', + method: 'GET', + disableCaching: true, + success: function(response){ + var msg = response.responseText; + Ext.MessageBox.show({ + title: 'Hello Message', + msg: msg, + buttons: Ext.MessageBox.OK, + icon: Ext.MessageBox.INFO + }); + }, + failure: function(){ + Ext.MessageBox.show({ + title: 'Error', + msg: 'Could not display the hello message', + buttons: Ext.MessageBox.OK, + icon: Ext.MessageBox.ERROR + }); + } + }); +} + +loginCallbacks.push(function(){ + var navPanel = Ext.getCmp('navigationPanel'); + var count = navPanel.count() - 1; + navPanel.insertSection(count, { + title: 'Hello World', + items: [{ + label: 'Say Hello', + fn: sayHello + }] + }); +}); \ No newline at end of file