Advertisement
lincolnthree

Oops! I just wrote another #SeamForge plugin

May 3rd, 2011
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. 1. new-project --named plugin-example --topLevelPackage com.plugin.example
  2. 2. setup plugins
  3. 3. plugins new-plugin --named Runner --defaultCommand
  4. 4. forge source-plugin /path/to/plugin/project
  5. 5. runner --value hey
  6. "Executed default command with value: hey"
  7.  
  8. ----------------------------------------------------------------
  9.  
  10. ____ _____
  11. / ___| ___ __ _ _ __ ___ | ___|__ _ __ __ _ ___
  12. \___ \ / _ \/ _` | '_ ` _ \ | |_ / _ \| '__/ _` |/ _ \ \\
  13. ___) | __/ (_| | | | | | | | _| (_) | | | (_| | __/ //
  14. |____/ \___|\__,_|_| |_| |_| |_| \___/|_| \__, |\___|
  15. |___/
  16.  
  17. [no project] Desktop $
  18. [no project] Desktop $ new-project --named plugin-example --topLevelPackage com.plugin.example
  19. ? Use [/Users/lbaxter/Desktop/plugin-example] as project directory? [Y/n]
  20. Wrote /Users/lbaxter/Desktop/plugin-example/src/main/resources/META-INF/forge.xml
  21. ***SUCCESS*** Created project [plugin-example] in new working directory [/Users/lbaxter/Desktop/plugin-example]
  22. [plugin-example] plugin-example $
  23. [plugin-example] plugin-example $ setup plugins
  24. ? The [forge.api] facet depends on the following missing facet(s): [CDIFacet]. Install as well? [Y/n]
  25. Wrote /Users/lbaxter/Desktop/plugin-example/src/main/resources/META-INF/beans.xml
  26. ***SUCCESS*** Installed [forge.spec.cdi] successfully.
  27. ***SUCCESS*** Installed [forge.api] successfully.
  28. [plugin-example] plugin-example $
  29. [plugin-example] plugin-example $ plugins new-plugin --named Runner --defaultCommand
  30. ? In which package you'd like to create [Runner], or enter for default: [com.plugin.example]
  31. Wrote /Users/lbaxter/Desktop/plugin-example/src/main/java/com/plugin/example/Runner.java
  32. Picked up type <JavaResource>: com.plugin.example.Runner
  33. [plugin-example] Runner.java $
  34. [plugin-example] Runner.java $
  35. [plugin-example] Runner.java $ ls -la
  36.  
  37. package com.plugin.example;
  38. import org.jboss.forge.shell.plugins.Plugin;
  39. import org.jboss.forge.shell.plugins.Alias;
  40. import org.jboss.forge.shell.ShellPrompt;
  41. import javax.inject.Inject;
  42. import org.jboss.forge.shell.plugins.PipeOut;
  43. import org.jboss.forge.shell.plugins.Option;
  44. import org.jboss.forge.shell.plugins.DefaultCommand;
  45.  
  46. public @Alias("runner") class Runner implements org.jboss.forge.shell.plugins.Plugin {
  47. @Inject private ShellPrompt prompt;
  48. @DefaultCommand public void run( PipeOut out, @Option(name="value") final String arg){
  49. System.out.println("Executed default command with value: " + arg);
  50. }
  51. }
  52.  
  53. [plugin-example] Runner.java $
  54. [plugin-example] Runner.java $ cd ../../../../../../../
  55. [plugin-example] plugin-example $ forge source-plugin .
  56. ***INFO*** Invoking build with underlying build system.
  57. [INFO] Scanning for projects...
  58. [INFO]
  59. [INFO] ------------------------------------------------------------------------
  60. [INFO] Building plugin-example 1.0.0-SNAPSHOT
  61. [INFO] ------------------------------------------------------------------------
  62. [INFO] BUILD SUCCESS
  63. [INFO] ------------------------------------------------------------------------
  64. [INFO] Total time: 2.606s
  65. [INFO] Finished at: Tue May 03 13:52:54 EDT 2011
  66. [INFO] Final Memory: 36M/81M
  67. [INFO] ------------------------------------------------------------------------
  68. ***SUCCESS*** Build successful.
  69. ***INFO*** Installing plugin artifact.
  70. Wrote /Users/lbaxter/.forge/plugins/com.plugin.example$plugin-example$1$1.0.0-SNAPSHOT.jar
  71. ***SUCCESS*** Installed from [plugin-example] successfully.
  72. [plugin-example] plugin-example $
  73. [plugin-example] plugin-example $
  74. [plugin-example] plugin-example $ runner --value hey
  75. Executed default command with value: hey
  76. [plugin-example] plugin-example $
  77.  
  78.  
  79. Oops!... I just wrote a Forge plugin.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement