I've been looking for better and faster ways to develop some of my solutions, while Gradle is quite promising in my opinion, I still prefer Apache Maven for collaborative projects, even Ant sounds good when you can predict any scenario for your application/project.
I had searching a lot about a RestEasy Archetype, but I haven't found. RestEasy is a project which Maven is strongly used, although I am not sure if I did my search properly, but just in case I create a simple RestEasy Archetype, which you can download from here.
Once you have Maven installed and configured, you just will unzip this zip file, and will type mvn install. You will see the following results into your console:
[INFO] [jar:jar]
[INFO] [install:install]
[INFO] Installing /Users/edgarsilva/redhat/dev/NetBeansProjects/resteasy-archetype/target/resteasy-archetype-1.0-SNAPSHOT.jar to /Users/edgarsilva/.m2/repository/org/jboss/resteasy/resteasy-archetype/1.0-SNAPSHOT/resteasy-archetype-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Wed Feb 25 04:26:00 BRT 2009
[INFO] Final Memory: 9M/16M
[INFO] ------------------------------------------------------------------------
edgar-silvas-macbook:resteasy-archetype edgarsilva$
Now, you are ready to create RestEasy projects using Maven Archetypes, to do that, you can use your preferred IDE or just can type in the console for instance, the following command:
mvn archetype:create -DarchetypeVersion=1.0-SNAPSHOT -Darchetype.interactive=false -DgroupId=sample -DarchetypeArtifactId=resteasy-archetype -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.jboss.resteasy -DartifactId=sample
This command, will create a project called "sample" which contains everything you need for developing and deploying RestEasy Applications into JBoss Application Server.
In the following image, you can see the project opened using NetBeans:
If you run mvn:install you will see Maven in action downloading everything required for building your project. In addition, this archetype includes JBoss AppServer tasks, which you can use for deploying, starting or stooping the server anytime you want. After typing mvn install, this goal will compile and generated a war file into target folder, however you may call the command mvn jboss:start that you will see the following output:
[jsilva@jsilva esresteasy]$ mvn jboss:start
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jboss'.
[INFO] artifact org.codehaus.mojo:jboss-maven-plugin: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building esresteasy
[INFO] task-segment: [jboss:start]
[INFO] ------------------------------------------------------------------------
[INFO] [jboss:start]
[INFO] Starting JBoss...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Feb 25 16:30:56 BRT 2009
[INFO] Final Memory: 3M/74M
[INFO] ------------------------------------------------------------------------
[jsilva@jsilva esresteasy]$
Not only starting JBoss AppServer, you are also able to deploy your application using the command: mvn jboss:deploy :
[jsilva@jsilva esresteasy]$ mvn jboss:deploy
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jboss'.
[INFO] ------------------------------------------------------------------------
[INFO] Building esresteasy
[INFO] task-segment: [jboss:deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [jboss:deploy]
[INFO] Deploying /opt/java/workspace/esresteasy/target/esresteasy.war to JBoss.
[INFO] No server specified for authentication - using defaults
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Feb 25 16:39:41 BRT 2009
[INFO] Final Memory: 3M/74M
[INFO] ------------------------------------------------------------------------
If you look the JBossApp Server console you can see your project deployed into JBoss:
16:39:39,812 INFO [TomcatDeployment] deploy, ctxPath=/esresteasy, vfsUrl=
16:39:39,930 ERROR [STDERR] 52 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider DataSourceProvider
16:39:39,935 ERROR [STDERR] 57 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider DefaultTextPlain
16:39:39,936 ERROR [STDERR] 58 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.StringTextStar
16:39:39,937 ERROR [STDERR] 59 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.InputStreamProvider
16:39:39,939 ERROR [STDERR] 61 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.ByteArrayProvider
16:39:39,941 ERROR [STDERR] 63 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider
16:39:39,942 ERROR [STDERR] 64 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider
16:39:39,944 ERROR [STDERR] 66 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.StreamingOutputProvider
16:39:39,950 ERROR [STDERR] 72 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Adding built in provider org.jboss.resteasy.plugins.providers.IIOImageProvider
16:39:40,084 ERROR [STDERR] 206 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - Adding scanned resource: esresteasy.Hello
16:39:40,087 INFO [STDOUT] FOUND JAX-RS resource: esresteasy.Hello
I am looking for an easy way to pass information of some users inputs to fill some information into my pom.xml, the same strategy used in seam-gen for instance and also in esb-gen, but I am still looking for how to do that.
Seems that Maven Archetype is changing or moving for a next generation (http://docs.codehaus.org/display/MAVEN/ArchetypeNG) , hopefully the actual archetypes are still working fine.
Tuesday, February 24, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment