Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. new-project --named plugin-example --topLevelPackage com.plugin.example
- 2. setup plugins
- 3. plugins new-plugin --named Runner --defaultCommand
- 4. forge source-plugin /path/to/plugin/project
- 5. runner --value hey
- "Executed default command with value: hey"
- ----------------------------------------------------------------
- ____ _____
- / ___| ___ __ _ _ __ ___ | ___|__ _ __ __ _ ___
- \___ \ / _ \/ _` | '_ ` _ \ | |_ / _ \| '__/ _` |/ _ \ \\
- ___) | __/ (_| | | | | | | | _| (_) | | | (_| | __/ //
- |____/ \___|\__,_|_| |_| |_| |_| \___/|_| \__, |\___|
- |___/
- [no project] Desktop $
- [no project] Desktop $ new-project --named plugin-example --topLevelPackage com.plugin.example
- ? Use [/Users/lbaxter/Desktop/plugin-example] as project directory? [Y/n]
- Wrote /Users/lbaxter/Desktop/plugin-example/src/main/resources/META-INF/forge.xml
- ***SUCCESS*** Created project [plugin-example] in new working directory [/Users/lbaxter/Desktop/plugin-example]
- [plugin-example] plugin-example $
- [plugin-example] plugin-example $ setup plugins
- ? The [forge.api] facet depends on the following missing facet(s): [CDIFacet]. Install as well? [Y/n]
- Wrote /Users/lbaxter/Desktop/plugin-example/src/main/resources/META-INF/beans.xml
- ***SUCCESS*** Installed [forge.spec.cdi] successfully.
- ***SUCCESS*** Installed [forge.api] successfully.
- [plugin-example] plugin-example $
- [plugin-example] plugin-example $ plugins new-plugin --named Runner --defaultCommand
- ? In which package you'd like to create [Runner], or enter for default: [com.plugin.example]
- Wrote /Users/lbaxter/Desktop/plugin-example/src/main/java/com/plugin/example/Runner.java
- Picked up type <JavaResource>: com.plugin.example.Runner
- [plugin-example] Runner.java $
- [plugin-example] Runner.java $
- [plugin-example] Runner.java $ ls -la
- package com.plugin.example;
- import org.jboss.forge.shell.plugins.Plugin;
- import org.jboss.forge.shell.plugins.Alias;
- import org.jboss.forge.shell.ShellPrompt;
- import javax.inject.Inject;
- import org.jboss.forge.shell.plugins.PipeOut;
- import org.jboss.forge.shell.plugins.Option;
- import org.jboss.forge.shell.plugins.DefaultCommand;
- public @Alias("runner") class Runner implements org.jboss.forge.shell.plugins.Plugin {
- @Inject private ShellPrompt prompt;
- @DefaultCommand public void run( PipeOut out, @Option(name="value") final String arg){
- System.out.println("Executed default command with value: " + arg);
- }
- }
- [plugin-example] Runner.java $
- [plugin-example] Runner.java $ cd ../../../../../../../
- [plugin-example] plugin-example $ forge source-plugin .
- ***INFO*** Invoking build with underlying build system.
- [INFO] Scanning for projects...
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Building plugin-example 1.0.0-SNAPSHOT
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 2.606s
- [INFO] Finished at: Tue May 03 13:52:54 EDT 2011
- [INFO] Final Memory: 36M/81M
- [INFO] ------------------------------------------------------------------------
- ***SUCCESS*** Build successful.
- ***INFO*** Installing plugin artifact.
- Wrote /Users/lbaxter/.forge/plugins/com.plugin.example$plugin-example$1$1.0.0-SNAPSHOT.jar
- ***SUCCESS*** Installed from [plugin-example] successfully.
- [plugin-example] plugin-example $
- [plugin-example] plugin-example $
- [plugin-example] plugin-example $ runner --value hey
- Executed default command with value: hey
- [plugin-example] plugin-example $
- Oops!... I just wrote a Forge plugin.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement