6 Deploying and Packaging from a Split Development Directory
wldeploy and
wlpackage tasks.Deploying Applications Using wldeploy
The wldeploy task provides an easy way to deploy directly from the split development directory. The wldeploy Ant task exposes many of the options of the weblogic.Deployer command-line utility.
For direct deployment from a split development directory, set source to the build directory produced by wlcompile. The server process must be able to read that build tree and the source directory identified by its .beabuild.txt file; the paths are resolved in the server’s filesystem. If the source tree is unavailable there, use wlpackage to create a complete EAR or exploded EAR and deploy that packaged output instead.
This example uses the stored-credential customization described in Chapter 4. Set dest.dir to the split build tree, app.name to the deployment name, adminurl to the intended Administration Server endpoint, and wls.userConfigFile/wls.userKeyFile to the protected matching credential files already created for that account.
<wldeploy action="deploy" source="${dest.dir}" name="${app.name}"
adminurl="${adminurl}"
userConfigFile="${wls.userConfigFile}"
userKeyFile="${wls.userKeyFile}"/>
BuildXMLGen generates a deploy target. Customize that target’s credential attributes as described in Generating a Basic build.xml File Using weblogic.BuildXMLGen; the preceding task shows the resulting stored-credential form.
See wldeploy Ant Task Reference, for a complete command reference.
Packaging Applications Using wlpackage
Use wlpackage when you want to deliver your application to another group or individual for evaluation, testing, performance profiling, or production deployment.
The wlpackage Ant task uses the contents of both the source and build directories to create either a deployable archive file (.EAR file), or an exploded archive directory representing the enterprise application (exploded .EAR directory).
Archive Versus Exploded Archive Directory
An exploded (unarchived) application directory lets you replace individual files without rebuilding the entire archive. Whether a particular change takes effect automatically or requires an update or redeployment depends on the resource type and configured reload behavior. For production update procedures, see Developing Applications for Production Redeployment. See also Deployment Archive Files Versus Exploded Archive Directories in Deploying Applications to Oracle WebLogic Server. Developing Applications for Production Redeployment
You can also package applications in a single archived file, which is convenient for packaging modules and applications for distribution. Archive files are easier to copy, they use up fewer file handles than an exploded directory, and they can save disk space with file compression.
The Java classloader can search for Java class files (and other file types) in a JAR file the same way that it searches a directory in its classpath. Because the classloader can search a directory or a JAR file, you can deploy Jakarta EE modules on WebLogic Server in either a JAR (archived) file or an exploded (unarchived) directory.
wlpackage Ant Task Example
After compiling the split-directory application and running any additional precompilation or generation steps it requires, use wlpackage to produce either an EAR archive or a complete exploded EAR for distribution. The following illustrative build file continues the earA suite layout from Chapter 4; it is not the installed MedRec sample. Run it at the suite root after setting the WebLogic environment. source/earA and build/earA must already exist and contain the intended source/build outputs. Keep dist outside both input trees.
<project name="earA-packaging" default="package.ear" basedir=".">
<taskdef name="wlpackage"
classname="weblogic.ant.taskdefs.build.WLPackageTask"/>
<property name="src.dir" location="source/earA"/>
<property name="dest.dir" location="build/earA"/>
<property name="dist.dir" location="dist"/>
<target name="package.ear">
<mkdir dir="${dist.dir}"/>
<wlpackage srcdir="${src.dir}" destdir="${dest.dir}"
tofile="${dist.dir}/earA.ear"/>
</target>
<target name="package.exploded">
<delete dir="${dist.dir}/earA-exploded"/>
<wlpackage srcdir="${src.dir}" destdir="${dest.dir}"
todir="${dist.dir}/earA-exploded"/>
</target>
</project>
Use ant -f package-build.xml package.ear or ant -f package-build.xml package.exploded after saving this example as package-build.xml. Choose the output format appropriate to your deployment procedure. package.exploded deletes only the previous generated dist/earA-exploded output before copying, so use that path exclusively for this package.
wlpackage Ant Task Attribute Reference
The following table describes the attributes of the wlpackage Ant task.
Table 6-1 Attributes of the wlpackage Ant Task
| Attribute | Description | Data Type | Required? |
|---|---|---|---|
|
|
Name of the EAR archive file into which the |
File (path resolved relative to the Ant project base directory) | Specify exactly one of tofile or todir; setting both or neither is an error. |
|
|
Name of an exploded directory into which the Creates the output directory if needed. If the directory already exists, the task copies into it and does not delete files absent from the current source/build trees. For a complete release package, use a fresh generated output directory or remove the previous generated package directory before invoking wlpackage. |
File (path resolved relative to the Ant project base directory) | Specify exactly one of tofile or todir; setting both or neither is an error. |
|
|
Specifies the source directory of your split development directory application. The source directory contains all editable files for your project—Java source files, editable descriptor files, JSPs, static content, and so forth. |
File (path resolved relative to the Ant project base directory) |
Yes. |
|
|
Existing build directory containing the application’s compiled classes and any other outputs required by the application. Run wlcompile first, and run wlappc or your custom generation steps where required. wlpackage combines the source/build trees; it does not compile Java sources or generate deployment descriptors. | File (path resolved relative to the Ant project base directory) |
Yes. |
For custom selections, use Ant fileset elements with dir, includes and excludes as appropriate; custom selections replace rather than extend the defaults described above.
Both srcdir and destdir must exist and be directories. Use an output path outside both input trees; see the packaging example.