Hi,
with my new Turbine-webapp I wanted to be as flexible as possible and
decided to use Maven and build a webapp from scratch instead of having
pre-built tdk-stuff around.
Also this decision was due to the fact that Maven is very actively developed
and there is a good chance to find assistance.
I went through various obstacles so it took me four weeks after all to get
started (I didn't know anything about Maven before.)
This is a summerize of the major steps that I did.
I hope it will encourage people to follow the same path.
Disclaimer:
Please note, this is just the way I did it!
There might be more efficient ways.
Creating a Maven-driven Turbine Web-Application
-----------------------------------------------
1) Getting started
- installing ant 1.4.1 (later versions should also work)
- get latest stable Maven-edition from cvs HEAD
- checkout jakarta-turbine-2 from CVS
- set MAVEN_HOME
- run jakarta-turbine-maven/>ant �f build-bootstrap.xml in
jakarta-turbine-maven/
--> maven gets built and installed on the system
- build turbine
--> run jakarta-turbine-2/>maven
--> run jakarta-turbine-2/>maven site:generate
In order to proceed you have to switch to Maven-b7!
--> rename your Maven-dir or delete it
--> get Maven-1.0-b7 release build and unpack it, rename root-dir to
MAVEN_HOME
- create a root-directory for your webapp at a place of your choice, for
example "/foo-project/". This is the root-directory of your Maven-Project.
- copy content of
MAVEN_HOME\plugins\maven-examples-plugin-1.1-SNAPSHOT\simple-webapp\
to
foo-project/
- edit foo-project/project.xml according to the needs of your webapp
- create dirs
src/java
src/test
src/schema
src/webapp/WEB-INF
src/webapp/WEB-INF/conf
src/webapp/templates
src/java/com/mycom/myproject/modules/actions
src/java/com/mycom/myproject/modules/screens
- adjust your app-web.xml in src/webapp/WEB-INF/
- copy jakarta-turbine-2/conf/TurbineResources.properties to
src/webapp/WEB-INF/conf/ to have a basic Turbine-configuration
2) Integrating Torque
- install Torque-plugin for maven as explained at
http://jakarta.apache.org/turbine/torque/maven-howto.html
- add Torque settings to foo-project/project.properties according to the
howto
--> set database-access
- add dependencies to to foo-project/project.xml according to the howto
- put Torque.properties to src/webapp/WEB-INF/conf
- put id-table-schema.xml into src/java/schema/
- put turbine-schema.xml into src/java/schema/
- put project-schema.xml into src/java/schema/
Your are now ready to create your project-schema.xml OM-modell. Once you
have done this you can run "maven torque:main" or any other torque:goal.
If you get an error, the torque-plugin that you deployed to Maven is
corrupt.
Try using latest Torque release-build and redeploy the plugin.
If you still get an error, contact the torque-dev-list ;-)
3) Building your webapp
Before you can build your webapp you need to add a few thing to your
project.xml:
First put this into all of your existing <dependency> entries that you added
before:
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
Then, add these dependencies.
<dependency>
<id>turbine</id>
<version>2.2</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<id>torque</id>
<version>3.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<id>mysql-connector-3</id>
<jar>mysql-connector-java-3.0.0-beta-bin.jar</jar>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<id>ecs</id>
<version>1.4.1</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<id>xmlrpc</id>
<version>1.2-a1</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<id>flux</id>
<version>2.2</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
Make sure to have this entry in your project.properties:
"maven.war.src=src/webapp"
Run "foo-project/> maven java:jar war:webapp" to your webapp and find it
under target/
Generelly:
--> foo-project/src/ is where you put your files,
--> foo-project/target/ is maven's scratch place to build things you ask for
(quoted from somone who helped me)
So, put everything you want in your war under src/webapp ( like images/
templates/ etc ) classes and jars will be pulled from the correct locations
and everything else is gotten from src/webapp and packaged up nicely for you
in a war or in target/ (again quoted.)
4) setting up Tomcat and deploying your webapp
If you use a recent Tomcat-edition (4.1.12 for example) you have to
uncomment SSI and CGI entries in conf/web.xml. (see RELEASE-NOTES-4.1.txt in
tomcat/)
If you use Linux you can symlink your webapp to tomcat, otherwise you need
to copy it from target/ to tomcat/webapps/.
Start your tomcat.
Check in tomcat/logs/ for errors. If you get errors you might need to add
additional dependencies.
Then check webapps/foo-project/logs/turbine.log whether Turbine has started
up successfully.
Finally you can run your webapp. The url depends on your web.xml config.
If you like a short URL you might want to rename your foo-project to ROOT.
(not in your project! only in tomcat/webapps/)
You will then be able to access your webapp this way:
server:8080/foo-project.
Voila!
You should see now the Flux-screen.
You are ready to actually start developing your webapp!
Enjoy!
Note: Once I switched to Maven b7, I have been unable to build either torque
or turbine from cvs HEAD using this maven-installation anymore, but after
all I don't care anymore about that, as long as my webapp works.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>