The Artima Developer Community
Sponsored Link

Java Buzz Forum
Plugin code generation (now with Stash!)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mathias Bogaert

Posts: 346
Nickname: pathos
Registered: Aug, 2003

Mathias Bogaert is a senior software architect at Intrasoft mainly doing projects for the EC.
Plugin code generation (now with Stash!) Posted: Mar 25, 2013 10:03 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Mathias Bogaert.
Original Post: Plugin code generation (now with Stash!)
Feed Title: Scuttlebutt
Feed URL: http://feeds.feedburner.com/AtlassianDeveloperBlog
Feed Description: tech gossip by mathias
Latest Java Buzz Posts
Latest Java Buzz Posts by Mathias Bogaert
Latest Posts From Scuttlebutt

Advertisement
I’m a big believer in learning by example. When I’m about to start working with a new library or piece of technology, I first look for prior art to demonstrate the common patterns and idioms associated with its use. For Atlassian plugins, this used to involve trawling through Bitbucket for decent examples or downloading plugin source jars from maven and browsing through them. But there is an easier way! The Atlassian SDK ships with a set of interactive scripts for creating a plugin and customising it to suit your requirements. Step 0: Generating a plugin project The first step is installing the Atlassian SDK or, if you already have it installed, upgrading to a recent version using the atlas-update command. Then, invoking the atlas-create-stash-plugin and following the prompts will create you a shiny new Stash plugin project, in a ready-to-build-and-deploy state. 12345678910$ atlas-create-stash-plugin ... [INFO] [stash:create] Define value for groupId: : com.mycompany.stash.plugin Define value for artifactId: : my-fun-plugin Define value for version: [1.0-SNAPSHOT]: Define value for package: [com.mycompany.stash.plugin]: ... $ ls my-fun-plugin/ LICENSE README pom.xml src At this point, you can start up Stash with your new plugin installed by invoking the atlas-run command. But our plugin (though deployable) doesn’t do anything useful yet. Step 1: Generating customized plugin modules The SDK ships with a second set of commands that allow you to customize your plugin with the various plugin modules supported by Stash. From the newly created plugin directory, running atlas-create-stash-plugin-module will present you with a list of Stash plugin module types: 1234567891011121314151617181920212223242526$ atlas-create-stash-plugin-module ... [INFO] [stash:create-plugin-module] Choose Plugin Module: 1: Changeset Indexer 2: Component Import 3: Component 4: Downloadable Plugin Resource 5: Licensing API Support 6: Module Type 7: REST Plugin Module 8: Repository Hook 9: SCM Request Check 10: Servlet Context Listener 11: Servlet Context Parameter 12: Servlet Filter 13: Servlet 14: SSH Request Handler 15: Keyboard Shortcut 16: Template Context Item 17: Web Item 18: Web Panel Renderer 19: Web Resource 20: Web Resource Transformer Choose a number (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20): (if you don’t see the full list above, try running atlas-update to make sure you’re on the latest version of the SDK) For this example we’ll take a look at option 8, the Repository Hook plugin module that shipped in Stash 2.2. To make things more interesting, let’s create a hook that solves a real problem. Atlassian has a bit of a reputation for enjoying a beer or two. Let’s create a hook that confiscates the metaphorical keys from a developer’s IDE after “Beer O’Clock”. That is, prevent pushes to a repository’s master branch after 5pm on a Friday. Once you’ve selected option 8 (Repository Hook) you’ll be greeted with another interactive prompt that will ask you some simple questions to customize your new plugin module: 123456789101112131415Choose a number (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20): 8 Enter New Classname [MyRepositoryHook]: BeerOClockHook Enter Package Name [com.atlassian.stash.plugin.hook]: Enter Hook Type (pre/post/merge) [post]: pre Show Advanced Setup? (Y/y/N/n) [N]: N [INFO] Adding the following items to the project: [INFO] [class: ccom.atlassian.stash.plugin.hook.BeerOClockHook] [INFO] [dependency: org.mockito:mockito-all] [INFO] [...]

Read: Plugin code generation (now with Stash!)

Topic: Basic concepts of OpenLDAP Previous Topic   Next Topic Topic: Setting up a Go Development Environment


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us