Maven2

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(Resin deployment plugins: added sample pom.xml and executions)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Resin 3.1 has a Maven2 snapshot repository at http://caucho.com/m2-snapshot
+
* Maven2 release repository: http://caucho.com/m2
 +
* Maven2 snapshot repository: http://caucho.com/m2-snapshot
  
 +
* groupId - com.caucho
 +
 +
===Artifacts ===
 +
 +
* resin : main Resin jar
 +
* resin-ant : ant plugins
 +
* resin-ejb : ejb api
 +
* resin-hessian : Hessian and Burlap jar
 +
* resin-jsdk : servlet api
 +
* resin-maven-plugin : maven plugin
 +
* resin-quercus : Quercus
 +
* resin-util : utilities shared for resin and quercus
 +
* resin-support : plugins and drivers for third-party
 +
* resin-webbeans : webbeans api (early draft)
 +
 
The Resin Maven plugin supports the following commands:
 
The Resin Maven plugin supports the following commands:
  
Line 10: Line 26:
 
resin:jspc compiles JSP files in the build directory
 
resin:jspc compiles JSP files in the build directory
  
== Step by Step ==
+
== Step by Step for resin:run ==
  
 
<ol>
 
<ol>
Line 127: Line 143:
  
 
The resin:jspc plugin will precompile any JSP files in your project, putting the compiled classes in the usual WEB-INF/work.
 
The resin:jspc plugin will precompile any JSP files in your project, putting the compiled classes in the usual WEB-INF/work.
 +
 +
= Resin deployment plugins =
 +
 +
== Mojo and parameter summary ==
 +
{|border="1"
 +
!Mojo
 +
!Parameter name
 +
!System property
 +
!Required?
 +
!Default
 +
!Description
 +
|-
 +
!rowspan="5" style="vertical-align: top; text-align:left;"|Common properties for all Mojos
 +
|server
 +
|resin.server
 +
|Yes
 +
|N/A
 +
|The IP or address of the Resin server
 +
|-
 +
|port
 +
|resin.port
 +
|Yes
 +
|N/A
 +
|The port of the Resin server's HTTP port
 +
|-
 +
|user
 +
|resin.user
 +
|Yes
 +
|N/A
 +
|The user to use when logging into the Resin server
 +
|-
 +
|password
 +
|resin.password
 +
|Yes
 +
|N/A
 +
|The password to use when logging into the Resin server
 +
|-
 +
|commitMessage
 +
|resin.commitMessage
 +
|No
 +
|N/A
 +
|The commit message to log for any changes to the application repository
 +
|-
 +
!rowspan="7" style="vertical-align: top; text-align:left;"|resin:upload-war
 +
|warFile
 +
|resin.warFile
 +
|Yes
 +
|${project.build.directory}/${project.build.finalName}.war (the war file produced for the project)
 +
|The war file to upload to the Resin server
 +
|-
 +
|stage
 +
|resin.stage
 +
|No
 +
|"default"
 +
|The stage to use for the deployed application
 +
|-
 +
|virtualHost
 +
|resin.virtualHost
 +
|No
 +
|"default"
 +
|The virtual host to use for the deployed application
 +
|-
 +
|contextRoot
 +
|resin.contextRoot
 +
|Yes
 +
|/${project.build.finalName}<br/>(the "final name" of the project)
 +
|The context root of the deployed application
 +
|-
 +
|version
 +
|resin.version
 +
|No
 +
|N/A
 +
|The version to use for the deployed application
 +
|-
 +
|archive
 +
|resin.archive
 +
|No
 +
|false
 +
|When set to true, an archive tag is set in addition to the main tag.  Can also be an explicit tag.
 +
|-
 +
|writeHead
 +
|resin.writeHead
 +
|No
 +
|true
 +
|When set to true and using versioning, a "head" tag is also set.
 +
|-
 +
!rowspan="10" style="vertical-align: top; text-align:left;"|resin:copy-tag
 +
|stage
 +
|resin.stage
 +
|No
 +
|"default"
 +
|The stage of the target tag
 +
|-
 +
|virtualHost
 +
|resin.virtualHost
 +
|No
 +
|"default"
 +
|The virtual host of the target tag
 +
|-
 +
|contextRoot
 +
|resin.contextRoot
 +
|Yes (if tag not given)
 +
|/${project.build.finalName}<br/>(the "final name" of the project)
 +
|The context root of the target tag
 +
|-
 +
|version
 +
|resin.version
 +
|No
 +
|N/A
 +
|The version of the target tag
 +
|-
 +
|sourceStage
 +
|resin.sourceStage
 +
|No
 +
|"default"
 +
|The stage of the source tag
 +
|-
 +
|sourceVirtualHost
 +
|resin.sourceVirtualHost
 +
|No
 +
|"default"
 +
|The virtual host of the source tag
 +
|-
 +
|sourceContextRoot
 +
|resin.sourceContextRoot
 +
|Yes (if sourceTag not given)
 +
|N/A
 +
|The context root of the source tag
 +
|-
 +
|sourceVersion
 +
|resin.sourceVersion
 +
|No
 +
|N/A
 +
|The version of the source tag
 +
|-
 +
|tag
 +
|resin.tag
 +
|Yes (if contextRoot not given)
 +
|N/A
 +
|An explicit target tag
 +
|-
 +
|sourceTag
 +
|resin.sourceTag
 +
|Yes (if sourceContextRoot not given)
 +
|N/A
 +
|An explicit source tag
 +
|-
 +
!rowspan="5" style="vertical-align: top; text-align:left;"|resin:delete-tag
 +
|stage
 +
|resin.stage
 +
|No
 +
|"default"
 +
|The stage of the tag to be deleted
 +
|-
 +
|virtualHost
 +
|resin.virtualHost
 +
|No
 +
|"default"
 +
|The virtual host of the tag to be deleted
 +
|-
 +
|contextRoot
 +
|resin.contextRoot
 +
|Yes (if tag not given)
 +
|/${project.build.finalName}<br/>(the "final name" of the project)
 +
|The context root of the tag to be deleted
 +
|-
 +
|version
 +
|resin.version
 +
|No
 +
|N/A
 +
|The version of the tag to be deleted
 +
|-
 +
|tag
 +
|resin.tag
 +
|Yes (if contextRoot not given)
 +
|N/A
 +
|An explicit tag to be deleted
 +
|-
 +
!rowspan="5" style="vertical-align: top; text-align:left;"|resin:query-tags
 +
|stage
 +
|resin.stage
 +
|Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given
 +
|"default"
 +
|The query pattern for the stage portion of tags in the repository
 +
|-
 +
|virtualHost
 +
|resin.virtualHost
 +
|Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given
 +
|"default"
 +
|The query pattern for the virtual host portion of tags in the repository
 +
|-
 +
|contextRoot
 +
|resin.contextRoot
 +
|Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given
 +
|/${project.build.finalName}<br/>(the "final name" of the project)
 +
|The query pattern for the context root portion of tags in the repository
 +
|-
 +
|version
 +
|resin.version
 +
|Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given
 +
|N/A
 +
|The query pattern for the version portion of tags in the repository
 +
|-
 +
|pattern
 +
|resin.pattern
 +
|Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given
 +
|N/A
 +
|An explicit query pattern for entire tags in the repository
 +
|}
 +
 +
== Example pom.xml setup ==
 +
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 +
    <modelVersion>4.0.0</modelVersion>
 +
    <groupId>com.test</groupId>
 +
    <artifactId>test</artifactId>
 +
    <packaging>war</packaging>
 +
    <version>1.0-SNAPSHOT</version>
 +
    <name>test Maven Webapp</name>
 +
    <url>http://maven.apache.org</url>
 +
    <dependencies>
 +
    </dependencies>
 +
    <pluginRepositories>
 +
      <pluginRepository>
 +
        <snapshots>
 +
          <enabled>true</enabled>
 +
          <updatePolicy>always</updatePolicy>
 +
          <checksumPolicy>ignore</checksumPolicy>
 +
        </snapshots>
 +
          <id>caucho</id>
 +
          <name>Caucho</name>
 +
          <url>http://caucho.com/m2-snapshot</url>
 +
      </pluginRepository>
 +
    </pluginRepositories>
 +
       
 +
    <build>
 +
      <finalName>foo</finalName>
 +
 
 +
      <plugins>
 +
        <plugin>
 +
          <groupId>com.caucho</groupId>
 +
          <artifactId>resin-maven-plugin</artifactId>
 +
          <version>4.0-SNAPSHOT</version>
 +
          <configuration>
 +
            <server>127.0.0.1</server>
 +
            <port>8086</port>
 +
            <user>foo</user>
 +
            <password>test</password>
 +
          </configuration>
 +
        </plugin>
 +
      </plugins>
 +
    </build>
 +
  </project>
 +
 +
This example adds the Caucho Maven repository and configures the plugin with some of the standard required arguments for all the goals.  It specifies how to contact the server to perform any of the Mojos in the Resin plugin.  Once these parts are added to the pom.xml, you can run the Resin deploy goals directly and pass arguments on the command line, if necessary.
 +
 +
This goal builds the war and uploads it to Resin, using the finalName ("foo" in this case) as the context root:
 +
 +
  mvn resin:upload-war
 +
 +
To change the context root, use
 +
 +
  mvn resin:upload-war -Dresin.contextRoot="bar"
 +
 +
To upload a version without making it live:
 +
 +
  mvn resin:upload-war -Dresin.version="1.0" -Dresin.writeHead="false"
 +
 +
To make that version live using the copy-tags goal:
 +
 +
  mvn resin:copy-tag -Dresin.sourceContextRoot='foo' -Dresin.sourceVersion='1.0'
 +
 +
To query all versions of the webapp in the repository:
 +
 +
  mvn resin:query-tags -Dresin.version='.*

Latest revision as of 20:08, 22 September 2009

  • groupId - com.caucho

Contents

Artifacts

  • resin : main Resin jar
  • resin-ant : ant plugins
  • resin-ejb : ejb api
  • resin-hessian : Hessian and Burlap jar
  • resin-jsdk : servlet api
  • resin-maven-plugin : maven plugin
  • resin-quercus : Quercus
  • resin-util : utilities shared for resin and quercus
  • resin-support : plugins and drivers for third-party
  • resin-webbeans : webbeans api (early draft)

The Resin Maven plugin supports the following commands:

 mvn resin:run
 mvn resin:jspc

resin:run starts a Resin instance pointing to your build directory

resin:jspc compiles JSP files in the build directory

Step by Step for resin:run

  1. install maven from http://maven.apache.org
  2. Create an empty .war project (see http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html)
    unix> mvn archetype:create \
        -DarchetypeGroupId=org.apache.maven.archetypes \
        -DarchetypeArtifactId=maven-archetype-webapp \
        -DgroupId=com.mycompany.app \
        -DartifactId=my-webapp
    
  3. Add the caucho release repository to my-webapp/pom.xml
    <project ...>
      ...
       <pluginRepositories>
          <pluginRepository>
            <id>caucho</id>
            <name>Caucho</name>
            <url>http://caucho.com/m2</url>
          </pluginRepository>
        </pluginRepositories>
      ...
    </project>  
    
  4. Add the resin plugin to my-webapp/pom.xml
    <project ...>
       ...
      <build>
        <finalName>my-webapp</finalName>
    
          <plugins>
    	<plugin>
              <groupId>com.caucho</groupId>
              <artifactId>resin-maven-plugin</artifactId>
              <version>3.1.5</version>
    	</plugin>
          </plugins>
      </build>
    
  5. Compile and start resin with "mvn resin:run"
  6. Browse http://localhost:8080/my-webapp

Pointing Resin to the build directory

Resin can point a web-app directly to the Maven build directory, letting you deploy automatically without involving any extra maven plugins. The resin.conf configuration looks like:

 <resin xmlns="http://caucho.com/ns/resin">
    ...
    <cluster id="">
      ...
      <host id="">
        ...
        <web-app id="my-webapp" 
                            root-directory="/home/ferg/maven/my-webapp/target/my-webapp"/>
        ...

You can also grab a generated .war file directly and have it expand into your own Resin workspace, by setting the 'archive-path' attribute of a <web-app> defined in the resin.conf:

  <resin ...
      ...
      <host id="">
      ...
         <web-app id="/my-webapp" root-directory="my-webapp-dir"
                             archive-path="/home/ferg/maven/my-webapp/target/my-webapp.war"/>
      ...

Adding Resin plugin to pom.xml

To add Resin plugins to your maven build, modify the pom.xml as follows:

 <project ...>
   ...
 
    <pluginRepositories>
      <pluginRepository>
        <id>caucho-snap</id>
        <name>Caucho Snapshots</name>
        <url>http://caucho.com/m2-snapshot</url>
      </pluginRepository>
    </pluginRepositories>
 
   ...
 
    <build>
      ...
      <plugins>
        <plugin>
          <groupId>com.caucho</groupId>
          <artifactId>resin-maven-plugin</artifactId>
          <version>3.1-SNAPSHOT</version>
        </plugin>
      </plugins>
 
    </build
 </project>

resin:run

On the command line, you can then use

 mvn resin:run

resin:run will start a new Resin instance based on your maven build area. You can then browse the instance directly to verify your code.

resin:jspc

The resin:jspc plugin will precompile any JSP files in your project, putting the compiled classes in the usual WEB-INF/work.

Resin deployment plugins

Mojo and parameter summary

Mojo Parameter name System property Required? Default Description
Common properties for all Mojos server resin.server Yes N/A The IP or address of the Resin server
port resin.port Yes N/A The port of the Resin server's HTTP port
user resin.user Yes N/A The user to use when logging into the Resin server
password resin.password Yes N/A The password to use when logging into the Resin server
commitMessage resin.commitMessage No N/A The commit message to log for any changes to the application repository
resin:upload-war warFile resin.warFile Yes ${project.build.directory}/${project.build.finalName}.war (the war file produced for the project) The war file to upload to the Resin server
stage resin.stage No "default" The stage to use for the deployed application
virtualHost resin.virtualHost No "default" The virtual host to use for the deployed application
contextRoot resin.contextRoot Yes /${project.build.finalName}
(the "final name" of the project)
The context root of the deployed application
version resin.version No N/A The version to use for the deployed application
archive resin.archive No false When set to true, an archive tag is set in addition to the main tag. Can also be an explicit tag.
writeHead resin.writeHead No true When set to true and using versioning, a "head" tag is also set.
resin:copy-tag stage resin.stage No "default" The stage of the target tag
virtualHost resin.virtualHost No "default" The virtual host of the target tag
contextRoot resin.contextRoot Yes (if tag not given) /${project.build.finalName}
(the "final name" of the project)
The context root of the target tag
version resin.version No N/A The version of the target tag
sourceStage resin.sourceStage No "default" The stage of the source tag
sourceVirtualHost resin.sourceVirtualHost No "default" The virtual host of the source tag
sourceContextRoot resin.sourceContextRoot Yes (if sourceTag not given) N/A The context root of the source tag
sourceVersion resin.sourceVersion No N/A The version of the source tag
tag resin.tag Yes (if contextRoot not given) N/A An explicit target tag
sourceTag resin.sourceTag Yes (if sourceContextRoot not given) N/A An explicit source tag
resin:delete-tag stage resin.stage No "default" The stage of the tag to be deleted
virtualHost resin.virtualHost No "default" The virtual host of the tag to be deleted
contextRoot resin.contextRoot Yes (if tag not given) /${project.build.finalName}
(the "final name" of the project)
The context root of the tag to be deleted
version resin.version No N/A The version of the tag to be deleted
tag resin.tag Yes (if contextRoot not given) N/A An explicit tag to be deleted
resin:query-tags stage resin.stage Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given "default" The query pattern for the stage portion of tags in the repository
virtualHost resin.virtualHost Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given "default" The query pattern for the virtual host portion of tags in the repository
contextRoot resin.contextRoot Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given /${project.build.finalName}
(the "final name" of the project)
The query pattern for the context root portion of tags in the repository
version resin.version Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given N/A The query pattern for the version portion of tags in the repository
pattern resin.pattern Yes (At least one pattern (either stage, virtualHost, contextRoot, version, or pattern) must be given N/A An explicit query pattern for entire tags in the repository

Example pom.xml setup

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.test</groupId>
   <artifactId>test</artifactId>
   <packaging>war</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>test Maven Webapp</name>
   <url>http://maven.apache.org</url>
   <dependencies>
   </dependencies>
   <pluginRepositories>
     <pluginRepository>
       <snapshots>
         <enabled>true</enabled>
         <updatePolicy>always</updatePolicy>
         <checksumPolicy>ignore</checksumPolicy>
       </snapshots>
         <id>caucho</id>
         <name>Caucho</name>
         <url>http://caucho.com/m2-snapshot</url>
     </pluginRepository>
   </pluginRepositories>
       
   <build>
     <finalName>foo</finalName>
 
     <plugins>
       <plugin>
         <groupId>com.caucho</groupId>
         <artifactId>resin-maven-plugin</artifactId>
         <version>4.0-SNAPSHOT</version>
         <configuration>
           <server>127.0.0.1</server>
           <port>8086</port>
           <user>foo</user>
           <password>test</password>
         </configuration>
       </plugin>
     </plugins>
   </build>
 </project>

This example adds the Caucho Maven repository and configures the plugin with some of the standard required arguments for all the goals. It specifies how to contact the server to perform any of the Mojos in the Resin plugin. Once these parts are added to the pom.xml, you can run the Resin deploy goals directly and pass arguments on the command line, if necessary.

This goal builds the war and uploads it to Resin, using the finalName ("foo" in this case) as the context root:

 mvn resin:upload-war

To change the context root, use

 mvn resin:upload-war -Dresin.contextRoot="bar"

To upload a version without making it live:

 mvn resin:upload-war -Dresin.version="1.0" -Dresin.writeHead="false"

To make that version live using the copy-tags goal:

 mvn resin:copy-tag -Dresin.sourceContextRoot='foo' -Dresin.sourceVersion='1.0'

To query all versions of the webapp in the repository:

 mvn resin:query-tags -Dresin.version='.*
Personal tools