Space: Apache Tuscany Docs 2.x 
(http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x)
Page: Tuscany Maven Archetypes 
(http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/Tuscany+Maven+Archetypes)


Edited by Luciano Resende:
---------------------------------------------------------------------

h1. Tuscany Maven Archetypes

Tuscany provides some [Maven archetypes | 
http://maven.apache.org/guides/introduction/introduction-to-archetypes.html] to 
make it easy to get going using Tuscany. Maven archetypes provide a simple way 
to create a project thats configured with exactly what you need to develop your 
application. You don't need to download, install, or pre-configure Tuscany or 
your environment, thats all done for you automatically, all you need 
pre-installed is Maven and Java.

To give it a try run the following command:

{code}
mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
{code}

That will list out the available archetypes and ask you to choose which one you 
want:

{code}
Choose archetype:
1: http://tuscany.apache.org -> tuscany-contribution-jar (Create an SCA 
contribution JAR)
2: http://tuscany.apache.org -> tuscany-quickstart (Create a Tuscany SCA and 
JSP project)
3: http://tuscany.apache.org -> tuscany-quickstart-stripes (Create a Tuscany 
SCA and Stripes Web Framework project)
4: http://tuscany.apache.org -> tuscany-quickstart-jsf (Create a Tuscany SCA 
and JSF project)
Choose a number:  (1/2/3/4):
{code}

You are then prompted to answer several questions about the project such as the 
Maven group and artifact IDs, Java package names etc. Some of those will show 
default values before the prompt so you can just hit enter to take the default. 
Thats it, and then the Maven project is created in a folder in the current 
directory named after the artifactid you entered.

The following shows the console session for creating an SCA contribution JAR:
{code}
Choose a number:  (1/2/3/4): 4
Define value for groupId: : org.myco.sca.test
Define value for artifactId: : scatest
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  org.myco.sca.test: :
Confirm properties configuration:
groupId: org.myco.sca.test
artifactId: scatest
version: 1.0-SNAPSHOT
package: org.myco.sca.test
 Y: :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 15 seconds
[INFO] Finished at: Tue Mar 31 15:08:45 BST 2009
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------
{code}

That will create a Maven project in a folder named scatest with the following 
directory structure and files:
{code}
scatest\pom.xml
scatest\src\main\java\org\myco\sca\test\HelloworldImpl.java
scatest\src\main\java\org\myco\sca\test\HelloworldService.java
scatest\src\main\resources\helloworld.composite
scatest\src\main\resources\META-INF\sca-contribution.xml
{code}

When using one of the archetypes which create webapp projects the pom.xml is 
configured with the maven Jetty plugin so you can run the webapp right away 
without needing to install the WAR file into an appserver by using the command 
"mvn jetty:run". The following shows an examaple of this using the 
tuscany-quickstart archetype:

{code}
> mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
[INFO] Scanning for projects...
. . .
Choose archetype:
1: http://tuscany.apache.org -> tuscany-contribution-jar (Create an SCA JAR 
contribution project)
2: http://tuscany.apache.org -> tuscany-contribution-zip (Create an SCA ZIP 
contribution project)
3: http://tuscany.apache.org -> tuscany-quickstart (Create a simple SCA webapp 
project)
4: http://tuscany.apache.org -> tuscany-quickstart-jsf (Create a Webapp using 
SCA and JSF)
5: http://tuscany.apache.org -> tuscany-quickstart-stripes (Create a Webapp 
using SCA and the Stripes Web Framework)
Choose a number:  (1/2/3/4/5): 3
Define value for groupId: : mygroup
Define value for artifactId: : mytest
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  mygroup: :
Confirm properties configuration:
groupId: mygroup
artifactId: mytest
version: 1.0-SNAPSHOT
package: mygroup
 Y: :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

> cd mytest
> mvn jetty:run
. . .
[INFO] Started Jetty Server
{code} 

The webapp runs at the context path of the artifact name on port 8080 so on a 
web browser go to http://localhost:8080/mytest/ and you should see a page 
showing:

Calling HelloworldService sayHello("world") returns:
Hello world 



Change your notification preferences: 
http://cwiki.apache.org/confluence/users/viewnotifications.action    

Reply via email to