nathanmarz/storm-starter — Issue #7: Update documentation on how to run examples via Maven
Author: jcscoobyrs
Created: 2012-02-29 00:21:33+00:00
State: open

The current documentation has some faulty docs, at least in my experience, on how to actually run the example topologies via Maven. The current docs say something like this:

```
mvn -f m2-pom.xml package
```

Trying that with any of the valid topology samples fails because without an actual goal for Maven to run, Maven is unhappy. Here is an example:

```
$ mvn -f m2-pom.xml storm.starter.WordCountTopology
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for storm.starter:storm-starter:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 137, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building storm-starter 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.623s
[INFO] Finished at: Tue Feb 28 17:11:36 MST 2012
[INFO] Final Memory: 4M/554M
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "storm.starter.WordCountTopology". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
```

What you can do is use the [maven-exec-plugin](http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html) to execute the main class. Here is a working example based on the previous example:

```
mvn -f m2-pom.xml exec:java -Dexec.classpathScope=compile -Dexec.mainClass=storm.starter.WordCountTopology
```

That being said, it might be worth updating the documentation to suggest running the examples like this:

```
mvn -f m2-pom.xml exec:java -Dexec.classpathScope=compile -Dexec.mainClass=
```

Of course, it might also be worth mentioning that you need to compile the code prior to running it or you can update the working example above to actually compile prior to execution with this:

```
mvn -f m2-pom.xml compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=
```

Usually I'd go through the whole process of forking and sending a pull request but since this is a one-line change that requires more work explaining the change than doing the change, I figured I'd create an issue with some context/detail.