Deploying Projects

Overview

The Curl® IDE deployment tools are designed to enable you to relocate and reconfigure your application to suit various deployment scenarios. Consider the following hypothetical situation:
You develop a Web application that is part of a larger Web site. You do your initial development and testing with the Curl IDE entirely in your local network file system, using local copies of Curl packages, directories of image files, and other resources already present on the site. You then copy your application to a test server for further testing. Finally, you deploy your finished part of the larger application to the Web site. You also want to store design specifications with the application, but do not want to copy them to either the test or the deployment server.
To perform all these tasks effectively, you need tools to help you do the following things:
IDE projects provide deployment tools and a deployment strategy that help you with all of these tasks.

The Curl IDE Deployment Strategy

Summary:
Deployment enables you to:
  • Define deployment targets.
  • Deploy your application in different ways to different targets.
  • Control caching and synchronization
  • Sign your applet during deployment
The Curl IDE handles project deployment as part of overall project management. The chapter Organizing Your Work with Projects discusses the use of projects during initial application development.

Deployment Targets

To use the Curl deployment system, you must first define one or more deployment targets. A deployment target is a name associated with a location. Because deploying a project involves copying many of the projects resources to the target, the target location must be a directory that the IDE can write files to. If you have direct access to the file system of your Web server, you can deploy your project directly to the server. Otherwise, you must deploy to a directory and transfer the files to the Web server by FTP or some other means.
Each project includes a default deployment target called default that deploys the project to a subdirectory called deploy-default in the project directory. Use the IDE Project Properties dialog to add and modify deployment targets. Select Edit Target Settings on the Project to open the Project Properties dialog with the Targets tab selected. Select Add... to add a new target, and Settings... to modify an existing target. See Targets.
A project can have several deployment targets, but only one target is active at a time. The active target of the current project is listed to the right of the manifest name in the title bar of the IDE project pane. The deployment commands on the Projects menu read Deploy target-name and Deploy target-name for OCC when there is an active deployment target.
The Current Target command on the Projects menu lists all currently available deployment targets for the project, indicates the active target, and allows you to select a new active target.
When you deploy a project, the deployment tool removes all contents from the target directory before writing the new deployed files. For this reason, it is not advisable to write files to this directory other than those the deployment process puts there.

Manifests and Deployment

The purpose of the project manifest is to enable the files in the project to find the resources they need. The IDE automatically updates the project manifest file as you develop your application. The section The Project File and Project Manifest discusses the role of the manifest file in project development.
When you deploy a project, the resources needed by files in the project may be found in a different location. For example, during development you may use a local copy of a package, located in a subdirectory of the project directory. When you deploy the project, the same package may be located in a different directory, where it is shared by several applications. In this situation, the deployed project needs a manifest that is different from the one used during development.
The project Component Target Settings enable you to specify how the IDE should construct a manifest for the deployed project. You also use Component Target Settings to specify other useful deployment information, such as whether to generate documentation for a package.
You can set Component Target Settings individually for each resource in the project. You can also treat a given component differently for different deployment targets. For example, consider the scenario described at the beginning of this chapter. You might need to copy all of the project's resources to the test server. On the other hand, when you deploy to the Web server, you might need to copy some resources, and specify a location on the server where the application can find the rest.

Caching and Synchronization

An important performance feature of the Curl RTE is that it caches packages downloaded by applets that it runs. Performance improves if an applet can use a package already cached on the client rather than downloading it. The end user can control the caching behavior of the RTE on the client through the General tab on the Curl Control Panel. When you deploy a new version of an application to a Web server, you want to be able to ensure that the new versions are downloaded as needed. There are several ways to control synchronization. The section Caching and Synchronization discusses these issues in detail.

Code Signing

Code Signing allows you to digitally sign a Curl applet and its manifest. This feature is available only in the Curl Pro/IDE version. See Curl and Curl Pro Products. Code signing offers the following advantages:
In order to sign an application, you must first obtain a public key/private key pair from a suitable Certificate Authority. These are institutions such as Verisign® or Thawte® which issue public key/private key pairs. Then you select code signing and specify the certificate file in the Target Settings dialog box. See Targets. The certificate file should be in PKCS#12 format, also known as PFX format.
Signed applets and their manifests contain a {curl-file-signature ...} form near the top of the file. A signed Curl file is not evaluated unless and until the signature is verified. If the signature cannot be verified, the applet or one of its components from the manifest has been corrupted in some manner.
End users running a signed applet interact with a dialog that allows them to select one of the following options:
If the applet certificate is found to be invalid when running an applet, the end user can select from the following options:
Note: Code signing is not supported on Mac platforms.

Deploying for Occasionally Connected Computing

You can also use the IDE deployment system to prepare an archive file for applications that use the Curl Occasionally Connected Computing (OCC) feature. Instead of using the Deploy command on the Project menu, use Deploy for OCC. For more information on OCC, see Occasionally Connected Computing. For more information on the Project menu, see Project Menu.

Editing Component Target Settings

Summary:
Component Target settings let you treat each resource in your project differently on deployment.
Once you have created and selected an active target, you can specify target settings for each file and resource in your project. The target settings determine what the IDE does with that resource when it deploys the project. Use the Show Target Settings command on the Project menu to show setting indicators, which appear to the right of the file name in the Project pane. This menu item for this command changes to Hide Target Settings when the setting indicators are visible.
Select the Edit Component Target Settings command on the Project menu to open the Component Target Settings dialog. You can also open this dialog by clicking on the setting indicator. This dialog lists all setting available for the currently selected resource.
One action that is available for all types of resources is Do not include in target manifest. Use this setting for resources you want to include in your project, but do not want to deploy with the application, such as product specifications or progress notes.
Other settings depend on the type of resource.

Files and Directories

Settings for files and directories:

Packages

Settings for packages:
To use deployment most effectively, you need to organize your application so that all Curl source files other than applet files are included in a package file. The IDE determines what files constitute a package by reading the package file and noting include statements. The IDE cannot recognize any files in include statements in .scurl files other than the package file. It also does not recognize files accessed with the evaluate procedure.

Delegate-to

A manifest enables a Curl applet to locate resources. One manifest can use another manifest to provide resource information through the delegate-to mechanism. See Manifest Delegation. You can add a manifest to a project, which adds a delegate-to expression to the project manifest, with the Add Delegate-to command on the Project menu.
Settings for delegate-to:

Deployment Examples

This section uses a several sample projects to illustrate project deployment. You can find this example in c:\build\jcurl\docs\default\examples\uguide\deployment.zip. See Extended Examples for more information on working with extended examples.
Extract the files from this archive into a convenient directory. Extracting the files creates three directories, applet-project, use-package, and use-delegate-to. Each directory contains an IDE project. All of these projects have three deployment targets.

Deploying Local Resources

First, use the IDE to open the project in applet-project. This project contains an applet file start.curl, a package called DOC.LOGO that contains a source file called show-logo.scurl, and a directory called images that contains a file curllogo.gif. The applet uses the procedure show-logo, which is defined in the package DOC.LOGO, to display the image file located in the directory images.
All of these resources are present in the directory that contains the project. Double click on the root node of the project to open the project manifest file, which contains component expressions that identify the file, package, and directory resources.
Select Show Component Target Settings on the Project menu to see settings for each component. Note that all three deployment targets simply copy the applet and all of its resources to the target.
Deploy APPLET-PROJECT to the default target, and at least one of the additional targets. Note that the applet runs correctly and displays the Curl logo in all deployed locations.

Deploying a Non-local Package

Now use the IDE to open the project in use-package. This project contains an applet file start.curl, and the package DOC.LOGO defined in APPLET-PROJECT. Double click on the root node of the project to open the project manifest file, which contains component expressions that identify the file and package resources. In this case, the location for the package is defined relative to the current project directory.
The component target settings for this project specify that start.curl be copied to the target location. Resources that are not located in the project directory cannot be copied during deployment. Therefore, the package cannot be copied. The component target setting is use path, which instructs the IDE to create a component expression in the deployed manifest that uses the same location path used by the project manifest.
Deploy USE-PACKAGE to the default target, and at least one of the additional targets. Note that the applet does not run correctly in the default target directory, because this directory does not have the same relationship to APPLET-PROJECT. If you copied this directory to a location on a web site where APPLET-PROJECT was already deployed, the applet would run correctly. The alternative deployment targets put the directories in the right relationship to each other, so the applet does run correctly in these locations.
Note that while the applet can use its project manifest to locate the package DOC.LOGO, it has no direct access to the directory images.

Deploying a Delegated Manifest

Now use the IDE to open the project in use-delegate-to. This project contains an applet file start.curl, and a delegated manifest for the project APPLET-PROJECT. Double click on the root node of the project to open the project manifest file, which contains a delegate-to expression that identifies the manifest.
The deployment targets directory-deploy and local-deploy write the project files to the directory DelegateDemo. The project APPLET-PROJECT is deployed to DeployDemo. In order to find the project resources, the component target setting for the APPLET-PROJECT manifest is Include in target manifest using alternate path:. The supplied path specifies the location of the deployed project. This setting instructs the IDE to create a delegate-to expression in the deployed manifest that uses the specified path.
Deploy this project to either of the targets directory-deploy or local-deploy. Like USE-PACKAGE, this project relies on APPLET-PROJECT being present in the correct relationship. Because it uses a delegate-to to add a package manifest, this project has access to all the resources of the project APPLET-PROJECT. The applet start.curl uses manifest-url to access the image file in applet-project directly, as well as through the package DOC.LOGO.

Automated Deployment

You can automate the IDE deployment operation and include it in build scripts and other automated contexts. You can use different deployment targets and perform many different deployment operations on a project, such as creating documentation and pcurling packages.
The Curl IDE includes a script for deploying projects, called deploy-project.xcurl. You can find this script in c:\build\jcurl\ide\bin. See Scripts for more information on writing and using Curl scripts.
Use the following syntax to run the deployment script:
Syntax:curl deploy-project.xcurl [target] project-file
where flags are:
  • (--help | --usage | -h | -?)
    Print out a help message with the command line options.
  • (--target | -t) target-name
    Deploys the target target-name. If omitted, all targets in the project are deployed.
  • --occ
    Deploys using OCC. If omitted, the deploying is done without OCC support.
  • (--preflight | -p) (none | dialog | throw)
    If dialog or throw, the deploy operation is preflighted before finishing. The preflight checks to make sure that the deploy target directory only contains files that are in the image that is about to be deployed. If dialog, then a dialog is shown to ask the user how to proceed. If throw, then an error is thrown and the deploy fails. If none, then no preflight check is done.
  • (--verbose | -v)
    Print messages to stderr during deployment to describe which targets are being deployed.
If an error occurs while deploying a target, the error is printed to stderr and no more targets are deployed.
The automated deployment API is not documented in the API Reference, so all the required components are described below:
DeployPreflight is an enum with three possible values:
The class ProjectDescription represents the project state on disk. The factory ProjectDescription.from-url creates a ProjectDescription given a Url to a Curl project (.cprj) file.
The method ProjectDescription.deploy deploys one of the project's targets. It has the following syntax:
Syntax:
{deploy
    target,
    occ? = false,
    preflight = DeployPreflight.dialog
}
           
where:
The property ProjectDescription.targets is an Iterator-of TargetDescription that returns all the targets in the project.
The class TargetDescription represents a deploy target in a project. It contains the following fields: