Vous êtes sur la page 1sur 10

mvn install:install-file -DgroupId=org.apache.

axis2 -DartifactId=axis2-tools -Dv


ersion=1.2 -Dpackaging=jar -Dfile=D:\ganesh_works\All_Jars\install\axis2-tools-1
.2.jar
http://subclipse.tigris.org/install.html
1. http://www.sonatype.com
http://www.sonatype.com/book/reference/installation.html#section-installation-te
st-install
2. http://maven.apache.org/
3. http://www.theserverside.com/tt/articles/article.tss?l=SettingUpMavenReposito
ry
A. Maven Installation Guide
Install the maven in your apache folder
then do the following settings
right click on My computer and click on system properties tab
and click on environment variables and do the following

IN user variables do the following


click on new .
enter the variable name as M2 and variable values as %M2_HOME%\bin
Again click on new .
enter the variable name as M2_HOME and variable values as C:\Program Files\Apac
he Software Foundation\apache-maven-2.0.9
In system variables
click on path and click on edit
and append ;C:\Program Files\Apache Software Foundation\apache-maven-2.0.9\bin
click on JAVA_HOME and click on edit , if not there then click on new
and enter the variable name as JAVA_HOME AND VALUES AS C:\Program Files\Java\jdk
1.6.0

Guidelines to build the project in maven.


1. Instructions :

1. To check whether maven installed properly or not , type the following command
mvn --version
2. Create a project
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
or
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app
or
mvn archetype:generate

3. COMPILE
A). For simple java Application
a.) compile the resources( .properties file) if present
mvn process-resources
b.) compile application sources
mvn compile

c.) compile test sources and run my unit tests


mvn test-compile
mvn test
a) To ignore test cases
IN pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
using command line
To ignore the test failure, that is to test this successfully by ignoring
test
mvn test -Dmaven.test.failure.ignore=true
b) To skip test cases
Using pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
or
using command line
mvn test -Dmaven.skip=true

4. Build project
a) mvn package
or
maven jar
b) mvn package -Dmaven.test.failure.ignore=true
or
mvn package -Dmaven.skip=true
5. To install the jar
a) mvn install
b) using command line
mvn install -Dmaven.test.failure.ignore=true
or
mvn install -Dmaven.skip=true
c)
maven.junit.fork=true
To install the jar file manually
mvn install:install-file -DgroupId=jini -DartifactId=mahalo \
-Dversion=2.1 -Dpackaging=jar -Dfile=/path/to/file
eg.
mvn install:install-file -DgroupId=junit -DartifactId=junit -Dversion=4.3.1 -Dpa
ckaging=jar -Dfile=D:\ganesh_works\All_Jars\BS-project-jars\junit-4.3.1.jar

6. Now test the newly compiled and packaged JAR with the following command:
a) To run the file manually
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
b) Executing the application
mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main

7. site: generates site documentation for this project


mvn site
8. deploy the application
mvn deploy
9. clean: cleans up artifacts created by prior builds
mvn clean
or
mvn clean dependency:copy-dependencies package
10. This will remove the target directory with all the build data before startin
g so that it is fresh.
Perhaps you'd like to generate an IntelliJ IDEA descriptor for the project?
mvn idea:idea

11. This can be run over the top of a previous IDEA project - it will update the
settings rather than starting fresh.
If you are using Eclipse IDE, just call:
mvn eclipse:eclipse
12. Uninstalling maven
Remove the folder in which maven in installed.

B). For Web Services


However, even though the nested directory structure seems to work quite well he
re, it has several
drawbacks:
Eclipse users will have issues with this structure as Eclipse doesn t yet support
nested projects.
You d need to consider the three modules as one project, but then you ll be restrict
ed in several
ways. For example, the three modules wouldn t be able to have different natures (W
eb
application project, EJB project, EAR project).
It doesn t allow flexible packaging. For example, the ejb or web modules might dep
end on a
utility JAR and this JAR may be also required for some other EAR. Or the ejb mod
ule might
be producing a client EJB JAR which is not used by the EAR, but by some client-s
ide
application.
These examples show that there are times when there is not a clear parent for a
module. In
those cases using a nested directory structure should be avoided. In addition, t
he nested
strategy doesn t fit very well with the Assembler role as described in the J2EE sp
ecification.
The Assembler has a pool of modules and its role is to package those modules for
deployment.
Depending on the target deployment environment the Assembler may package things
differently: one EAR for one environment or two EARs for another environment whe
re a different
set of machines are used, etc. A flat layout is more neutral with regard to asse
mbly and should
thus be preferred.

The directory structure of Web Services application are :


application
|
|---src
| |
| |---main
| | |
| | |---java
| | | |
| | | |--source package and files
| | | |
| | |
| | |---resources
| | | |
| | | |--resource files
| | |
| | |---wsdl
| | | |
| | | |--web services files and folders
| | |
| |
| |
| |---test
| |
|
|
|---pom.xml
|
Working on project containig many modules ( sub-projects)
If a project consists of many modules in it, then while building the module
then that module refers
to the parent's POM.xml .
So before packaging each module ( sub projects) we need to install the parent
POM into our
local repository so it can be further built on.
daytrader
|
|
|--ejb
|
|
|--web
|
|--ear
|
|
|--streamer
|
|
|--wsappclient
|
|
|--pom.xml
|
|

1. Now run mvn -N install in daytrader/ in order to install the parent POM in yo
ur local
repository and make it available to all modules:
C:\dev\m2book\code\j2ee\daytrader>mvn -N install
Now we are ready to develop to generate the sub-projects .
2. go to C:\dev\m2book\code\j2ee\daytrader\wsappclient>
The location of WSDL source can be customized using the sourceDirectory property
.
In order to generate the Java source files from the TradeServices.wsdl file, the
wsappclient/pom.xml file must declare and configure the Axis Tools plugin
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
As before, you need to add the J2EE specifications JAR to compile the project's
Java sources. Thus
the following three dependencies have been added to your POM:
1. axis
2. axis-jaxrpc
3. geronimo-j2ee_1.4_spec
4. activation
5. mail
6.

<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee_1.4_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Also u need to manually install the activation and mail jar.
3. now run the following command
mvn install
eg.
C:\dev\m2book\code\j2ee\daytrader\wsappclient>mvn install
4.

b)
In order to generate the Java source files from the TradeServices.wsdl file, th
e
wsappclient/pom.xml file must declare and configure the Axis Tools plugin
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
various ways to make web services
1.Axis2 tools maven plugin
plugins : axistools-maven-plugin
dependencies : 1. axis
2. axis-jaxrpc
3. geronimo-j2ee_1.4_spec
install the below two jars manually
4. activation
5. mail
eg.
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal> or wsdl2java
</goals>
</execution>
</executions>
<configuration>
<sourceDirectory>
src/main/resources/META-INF/wsdl
</sourceDirectory>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee_1.4_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

2. Axis2 java2wsdl maven plugin


Plugins : axis2-java2wsdl-maven-plugin
dependencies : axis2
eg.
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-java2wsdl-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
<configuration>
<className>com.test.Calculator</className>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

3. Axis2 wsdl2java maven plugin


Plugins : axis2-wsdl2java-maven-plugin
dependencies : axis2
eg.
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2java-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<configuration>
<className>com.test.Calculator</className>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

4.How to use Maven2 WSDL2Code plugin in Axis2


Apache Axis2 ships with a lot of useful tools to make web service developer's li
fe easier.
Maven2 WSDL2Code plugin is one of them which can be used to generate server side
skeletons or
client stubs from a given WSDL using a maven pom.xml.
Lets see how this plugin can be used.
Plugins : axis2-wsdl2code-maven-plugin
Dependencies : axis2
eg.
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>org.charitha</packageName>
<wsdlFile>src/main/resources/calculator.wsdl</wsdlFile>
<databindingName>adb</databindingName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

Vous aimerez peut-être aussi