This document covers the following topics:
You can deploy a Java application in a way similar to deploying a Natural application. Prerequisites:
The Java project must be available as a project in Eclipse.
The Java project must contain an Ant build script. Such a build script can be generated, for example, with the export functionality of Eclipse.
The prerequisites defined by the Ant script (such as Java compiler or Eclipse installations) must be available when you deploy the Java application with NaturalONE.
The purpose of the NaturalONE Java deployment is not the generation of some build script for Java projects. This has to be done separately, with other tools (such as Eclipse). The purpose of the NaturalONE Java deployment is to add some base functionality, such as versioning repository access, and to make use of the already existing build scripts.
The deployment wizard creates a Java deployment file in your project root. This is an Ant script. You can create one or more Java deployment files for a project, and you can also load an existing Java deployment file and modify the current settings.
To use the deployment wizard
In the Navigator view or in the Natural Navigator view, select the Java project for which you want to create the deployment file.
Or:
If you want to load the settings of an existing Java deployment
file, select this file in the Navigator view or in the
Natural Navigator view.
From the
menu or from the context menu, choose .In the resulting New dialog box, expand the Natural node, select Deploy Natural Java Ant and then choose the button.
The first page of the wizard appears (see below).
Specify all required information as described in the topics below. Use the
button repeatedly to proceed from the first page of the wizard to the last page.When all required information has been provided, choose the
button.The different pages of the deployment wizard are described in the following topics:
On the first page of the wizard, you define general settings for the deployment.
The default name for the Java deployment file is javadeploy.xml. This name is shown in this text box when an existing Java deployment file was not selected while invoking the wizard. However, when an existing Java deployment file was selected, the name of the selected file is shown and the settings from this file are automatically loaded.
You can enter any other name for your new deployment file. It is recommended that your new deployment file also has the extension ".xml".
Note:
If you keep the name javadeploy.xml, the
settings from an existing Java deployment file with the same name are loaded
the next time you select the project and invoke the wizard.
If you want to load an existing Java deployment file, choose the
button. A dialog appears, providing for selection all Java deployment files in the current project. Next, you have to choose the button. Otherwise, the settings in this file are not shown in the wizard and may thus be overwritten unintentionally.If you want to return to the default settings of the deployment wizard (this also includes the information that can be specified on the other pages of the wizard), choose the
button.When enabled, all passwords that are used in the deployment file are stored in an encrypted format.
When enabled, the Ant script reports errors and terminates in the case of a build failure.
When disabled, the Ant script still reports errors but build failures are only triggered in severe situations (see also Status Code Handling).
This path should only be changed when you intend to start the deployment from the command line (that is, when the deployment is not to be started from Eclipse).
Specify the directory in which the selected project is to be checked out and where the processing takes place. When the deployment is supposed to run on a different machine, you can insert the desired root path via copy-and-paste.
Specify the name of the Ant build file that is to be used for the deployment of the selected Java project. This build script must have been generated with some other tool in advance. You can also choose the
button to select the build file from a dialog box; in this case, all existing build files in the current Java project are provided for selection.On the second page of the wizard, you define all settings related to the versioning repository. This can be either Subversion (SVN), GIT or CVS.
From the Type drop-down list box, select the type of versioning repository that you are using, and then specify all required information. The names of the text boxes and their availability changes according to the selected type.
The wizard usually collects a set of default information as given for the selected project. In most cases, only minor corrections have to be made to the defaults, for example, user ID and password may have to be provided.
When you start the deployment process from Eclipse, it is not possible
to execute the checkout
and update
targets of the
deployment file since these targets would access the versioning repository, and
this is not feasible from within an Eclipse environment. If you want to check
out a specific revision from the versioning repository or if you want to update
your project with sources from the versioning repository, you have to start the
deployment from the command line as described below.
For testing purposes, for example, it is helpful to start the
deployment process from Eclipse. Since the Java deployment file is an Ant
script, the built-in Eclipse functionality of starting Ant scripts is used
here. The build
target of the Ant script will then be
executed.
To start the deployment from Eclipse
In the Navigator view or in the Natural Navigator view, select your Java deployment file, invoke the context menu and choose .
The deployment process is started, and the output of the deployment file is written to the Console view.
Note:
If you want to change the limit for the console output, you can
do this in the general Eclipse preferences under Run/Debug >
Console.
You can start the deployment process from a Windows command line such as the Command Prompt (cmd.exe) or from a shell command line on a Linux system. When you start the deployment from the command line, special requirements must be met.
The following topics are covered below:
The prerequisites for deploying a Java application are the same as for deploying Natural applications. See Prerequisites in Deploying Natural Applications. However, you have to copy the Java deployment file to the root directory (instead of the Natural deployment file).
In addition, all necessary tools which are referred to in the Ant build file (specified on the first page of the wizard) must be available and accessible on the processing platform.
When all prerequisites are in place, the deployment can be started by issuing specific Ant calls. This section just provides some examples (where the default name javadeploy.xml is used).
Print the help screen of the Ant script:
ant -lib path-to-mylib -f javadeploy.xml help
Perform an initial checkout of the project sources from the versioning repository:
ant -lib path-to-mylib -f javadeploy.xml checkout
Perform an update of the project sources from the versioning repository:
ant -lib path-to-mylib -f javadeploy.xml update
Deploy the sources using the Ant build file which was specified on the first page of the wizard:
ant -lib path-to-mylib -f javadeploy.xml build
With a single call, perform an update of the project sources from the versioning repository first, and then deploy the sources:
ant -lib path-to-mylib -f javadeploy.xml update build
In the above examples, the logging information is written to standard output. If logging information is to be written to a file, use a call such as the following:
ant -lib path-to-mylib -f javadeploy.xml update build -logfile mylogfile.txt
The Ant deployment script for Java can run in two status code modes.
The mode can be toggled by specifying the command line parameter
-Dnatural.ant.java.failonerror
as described in the
following table.
Command Line Option | Description |
---|---|
-Dnatural.ant.java.failonerror=no |
Only severe errors such as missing project directories will lead to a build failure with a status code other than 0. This is the default mode. |
-Dnatural.ant.java.failonerror=yes |
In addition to the severe errors described above, errors occurring during checkout or update will also lead to a status code other than 0 and hence will lead to a build failure. |
Note:
The default mode can also be changed on the
first page of
the deployment wizard.
When the additional status code handling has been enabled, the Ant tool as well as the internally used tools such as SVN, GIT or CVS clients may issue specific status codes. In case the status codes are unclear, refer to the documentation of these tools.