Thanks to Deepak Gothe for explaining me about maven.

 The SUN Portlet Repository can be accessed from the following location :

Following are the steps required to build a portlet war file from the portlet source present in the sun portlet repository :

  1. Here I will take the example of rssportlet. Download the rss portlet src from the following location https://portlet-repository.dev.java.net/files/documents/5129/57742/rssportlet-src-20070514.zip
  2. Download maven-2.0.5 from the following location:
  3. gzip -d maven-2.0.5-bin.tar.gz
  4. tar -xvf maven-2.0.5-bin.tar
  5. Add the below proxy settings in the following file<maven_install_dir>/conf/settings.xml           

   <proxy>
      <id>http</id>
      <active>true</active>
      <protocol>http</protocol>
      <username></username>
      <password></password>
      <host>ENTER YOUR PROXY</host>
      <port>8080</port>
      <nonProxyHosts>local.net,some.host.com</nonProxyHosts>
    </proxy>
    <proxy>
      <id>https</id>
      <active>true</active>
      <protocol>https</protocol>
      <username></username>
      <password></password>
      <host>ENTER YOUR PROXY</host>
      <port>8080</port>
      <nonProxyHosts>local.net,some.host.com</nonProxyHosts>
    </proxy>

    6. run export JAVA_HOME=/usr/jdk/latest

    7. unzip rssportlet-src-20070514.zip

    8. cd to the directory rssportlet

    9. run  <maven_install_dir>/bin/mvn package. If this gives the following error :

 

[INFO] [war:war]
[INFO] Exploding webapp...
[INFO] Assembling webapp rssportlet in /space/rssportlet/dist/rssportlet
[INFO] Copy webapp webResources to /space/rssportlet/dist/rssportlet
[INFO] Copy webapp webResources to /space/rssportlet/dist/rssportlet
[INFO] Generating war /space/rssportlet/dist/rssportlet.war
[INFO] Building war: /space/rssportlet/dist/rssportlet.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30 seconds
[INFO] Finished at: Sun Oct 07 19:30:07 IST 2007
[INFO] Final Memory: 7M/121M
A Brief Description on the working of maven :

1. maven reads the <rssportlet_dir>/pom.xml

2. It reads the repository entry in pom.xml  and downloads the depedencies for the rssportlet from the repository(http://repo1.maven.org/maven2) to $HOME/.m2/repository directory . Following is the repository tag :

 

    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <url>http://repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>maven-repository.dev.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>https://maven-repository.dev.java.net/nonav/repository</url>
            <layout>legacy</layout>
        </repository>
    </repositories>

3. Then maven reads plugin tag and downloads the plugins required

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.4</source>
                    <target>1.4</target>
                </configuration>
            </plugin>
4. You can see maven-compiler-plugin downloaded to the maven repository, see below :

bash-3.00# ls $HOME/.m2/repository/org/apache/maven/plugins/maven-
maven-clean-plugin/     maven-plugins/          maven-surefire-plugin/
maven-compiler-plugin/  maven-resources-plugin/ maven-war-plugin/

5. Next maven reads the dependencies tag. For ex :

       <dependency>
            <groupId>rome</groupId>
            <artifactId>rome</artifactId>
            <version>0.9</version>
            <scope>compile</scope>
        </dependency>

6. You can see rome downloaded to the maven repository, see below :

bash-3.00# ls /.m2/repository/rome/rome/0.9
rome-0.9.jar       rome-0.9.jar.sha1  rome-0.9.pom       rome-0.9.pom.sha1

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by siddeshk123