Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.
The "MavenPlugin" page has been changed by StephenConnolly. http://wiki.apache.org/cassandra/MavenPlugin?action=diff&rev1=1&rev2=2 -------------------------------------------------- There is a Maven plugin for Cassandra. It is hosted at the mojo project: [[http://mojo.codehaus.org/cassandra-maven-plugin/|Mojo's Cassandra Maven Plugin]] + The plugin has the following goals. + + * cassandra:start Starts up a test instance of Cassandra in the background. + * cassandra:stop Stops the test instance of Cassandra that was started using cassandra:start. + * cassandra:run Starts up a test instance of Cassandra in the foreground. + * cassandra:load Runs a cassandra-cli script against the test instance of Cassandra. + * cassandra:repair Runs nodetool repair against the test instance of Cassandra. + * cassandra:flush Runs nodetool flush against the test instance of Cassandra. + * cassandra:compact Runs nodetool compact against the test instance of Cassandra. + * cassandra:cleanup Runs nodetool cleanup against the test instance of Cassandra. + * cassandra:delete Deletes the the test instance of Cassandra. + + == Step-by-step develop a Cassandra backed web application in 2 minutes == + + Here is a from zero to web application step-by-step guide. We assume that you have Apache Maven 3.0.2 installed and configured with proxies correctly. + + 1. Verify that Maven is installed and that you are using Java 6. + + {{{ + $ mvn -version + Apache Maven 3.0.2 (r1056850; 2011-01-09 00:58:10+0000) + Java version: 1.6.0_20, vendor: Sun Microsystems Inc. + Java home: /usr/java/jdk1.6.0_20/jre + Default locale: en_US, platform encoding: UTF-8 + OS name: "linux", version: "2.6.18-194.26.1.el5", arch: "amd64", family: "unix" + }}} + You are looking to verify the {{{Apache Maven 3.0.2}}} and that the Java version starts with {{{1.6.}}} + + 1. Create a basic web application + + {{{ + $ mvn archetype:generate + [INFO] Scanning for projects... + [INFO] + [INFO] ------------------------------------------------------------------------ + [INFO] Building Maven Stub Project (No POM) 1 + [INFO] ------------------------------------------------------------------------ + ... + Choose archetype: + ... + 102: remote -> maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.) + ... + Choose a number: 99: + }}} + Note that the numbers you will see are different every time. You are looking for the one that is {{{maven-archetype-webapp}}} + + Type in the number of {{{maven-archetype-webapp}}} and press {{{ENTER}}}. + + {{{ + Choose a number: 99: 102 + Choose version: + 1: 1.0-alpha-1 + 2: 1.0-alpha-2 + 3: 1.0-alpha-3 + 4: 1.0-alpha-4 + 5: 1.0 + Choose a number: 5: + }}} + + For archetypes, you usually pick the latest version, if you want to follow exactly, pick version {{{1.0}}} + + {{{ + Define value for property 'groupId': : + }}} + + We'll use {{{org.apache.wiki.cassandra.mavenplugin}}} as the groupId. You should use a domain name that you control reversed as is the fashion for package names. + + {{{ + Define value for property 'groupId': : org.apache.wiki.cassandra.mavenplugin + Define value for property 'artifactId': : webapp + Define value for property 'version': 1.0-SNAPSHOT: : 1.0-SNAPSHOT + Define value for property 'package': org.apache.wiki.cassandra.mavenplugin: : + Confirm properties configuration: + groupId: org.apache.wiki.cassandra.mavenplugin + artifactId: webapp + version: 1.0-SNAPSHOT + package: org.apache.wiki.cassandra.mavenplugin + Y: : + }}} + + Press {{{Y}}} followed by {{{ENTER}}} to create the project. + + {{{ + [INFO] ---------------------------------------------------------------------------- + [INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-webapp:1.0 + [INFO] ---------------------------------------------------------------------------- + [INFO] Parameter: groupId, Value: org.apache.wiki.cassandra.mavenplugin + [INFO] Parameter: packageName, Value: org.apache.wiki.cassandra.mavenplugin + [INFO] Parameter: package, Value: org.apache.wiki.cassandra.mavenplugin + [INFO] Parameter: artifactId, Value: webapp + [INFO] Parameter: basedir, Value: /home/stephenc/src/cassandra-wiki + [INFO] Parameter: version, Value: 1.0-SNAPSHOT + [INFO] ********************* End of debug info from resources from generated POM *********************** + [INFO] project created from Old (1.x) Archetype in dir: /home/stephenc/src/cassandra-wiki + [INFO] ------------------------------------------------------------------------ + [INFO] BUILD SUCCESS + [INFO] ------------------------------------------------------------------------ + [INFO] Total time: 4:57.118s + [INFO] Finished at: Wed Feb 09 11:04:37 GMT 2011 + [INFO] Final Memory: 10M/106M + [INFO] ------------------------------------------------------------------------ + }}} + + 1. At this point we should have a basic web application created in the {{{webapp}}} (or whatever the artifactId you chose was) directory. The directory structure should look a little bit like + + {{{ + webapp + +-- pom.xml + \-- src + \-- main + +-- resources + \-- webapp + +-- WEB-INF + | \-- web.xml + \-- index.jsp + }}} + + 1. We now need to add the client library that we will use to the list of dependencies. Open the {{{pom.xml}}} in your favourite editor. In the {{{<dependencies>}}} section add the hector dependency. (You could use any client library, we will use hector because it is available in the Maven Central repository which makes using it a lot easier) Your {{{pom.xml}}} should look a little something like: + + {{{ + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.wiki.cassandra.mavenplugin</groupId> + <artifactId>webapp</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>webapp Maven Webapp</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>me.prettyprint</groupId> + <artifactId>hector-core</artifactId> + <version>0.7.0-25</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <finalName>webapp</finalName> + </build> + </project> + }}} +
