MyEclipse Deployment Assembly
1. Customizing How Projects Are Deployed
MyEclipse includes support for flexible deployment using deployment assembly. Flexible deployment support allows you to customize how your final archive is assembled. For example, you can map only a subset of your source folders, deploy to paths that don't exist within your workspace project, and generally deviate from a fixed project structure where everything resides under your project's WebRoot folder. For enterprise projects, archive names and utility project deployment can also be controlled here. To configure deployment assembly, right-click the project, select Properties from the menu, expand MyEclipse, and select Deployment Assembly.
2. Adding Libraries, Files, or Projects to a Deployment
You can easily add user libraries, files or projects that you want deployed with your application. From the Deployment Assembly properties page, click the Add button.
When you add resources to an EAR project's deployment assembly, the additions are reflected in the EAR libraries container of the module projects. Java projects are added as a .jar library in the lib folder by default.
3. Customizing the Deploy Name and Path of a JAR
You can change the default deployment name and path of a JAR by simply double-clicking the deploy path. Module deployment URI changes are reflected in application.xml if you generated this file upon project creation.
Note: If you change the path of an archive file that is in lib by default, you must add that resource to the manifest of the modules that require access to the archive file. See Configuring Manifest Entries.
4. Mapping a Custom Folder to a New Deployment Path
In your EAR project, you might want to create a folder for a set of custom libraries, for example. Using deployment assembly, you can map that folder to the lib folder so the libraries are accessible to the EAR modules. In the example below, the CustomLibs folder is added to the deployment assembly, and the deploy path is changed to lib. With this mapping, the files in the CustomLibs folder appear in the module EAR Libraries.
If you add a library to an EAR module or change the deploy path of an EAR project library, you must add the resource to the module project manifest so the library can be referenced both during development and at deployment. Libraries in the EAR lib folder are referenced by EAR modules automatically. Other libraries, including those residing in the EAR root, must be referenced through MANIFEST.MF. In the example below, the deploy path of a library in the EAR deployment assembly was changed from lib to other. To include the library in the EAR Libraries of the module, add the library to the module's manifest.
Manifest additions appear in the EAR Libraries container as well as in the META-INF/Manifest.mf file.
6. Adding External Archives and Libraries to a Java Project
You have the capability to add external archives and libraries directly to a Java project by right-clicking the project, and selecting Build Path>Add External Archives from the menu. When you do so, the file is added to a Referenced Libraries container. However, because Java projects do not have their own class loaders, these files must be added to the deployment assembly to run on server; the enterprise application must be aware of these additional libraries. Because Web projects have their own class loader, resources added to their deployment assembly are mapped automatically to WEB-INF/lib.
Add to the Java project's deployment assembly by clicking the Add button, and selecting Java Build Path Entries.
The file is mapped automatically to the lib folder of the enterprise application, and appears in the EAR project's deployment assembly.
Note: If you add an external MyEclipse library that is designed for Java projects, the library is automatically mapped in deployment assembly.
6.1 Adding Libraries to a Web Project
A Web project's deployment assembly typically includes all Jar libraries contained in the project's WEB-INF/lib folder. Additionally, a Web project's deployment assembly could be configured to include:
- Jar files that reside in a different location within the project
- External JAR files that reside outside the Eclipse workspace
- User libraries assigned to the project
- JARs from dependent Java projects
- User libraries from dependent Java projects
When a Web project is deployed, it typically requires non-system resources such as the JAR libraries defined in the project as part of the deployment. The MyEclipse Web project Deployment Service allows you to set all deployment assembly configuration in the project's properties. To include build-path libraries in the deployment assembly, right-click the project and select Properties from the menu. Expand MyEclipse, select Deployment Assembly, and click Add. Select Java Build Path Entries to include build-path libraries in the deployment assembly.
If the Web project's deployment mode is "packaged," then the relevant JAR libraries are included in the resulting WAR file that is copied to the target application server's automatic deployment area. If the Web project's deployment mode is "exploded," then the relevant JAR libraries are copied into the expanded WAR file structure in the target application server's automatic deployment area.
7. Hot-Sync for Web Projects
The Deployment Assembly preference for Web projects contains an option that allows for hot-sync'ing utility and EJB module changes to the deployed web application. The Merged deployment of modules option, which is enabled by default, merges classes and resources contained in EJB and Utility projects into the WEB-INF/classes folder when deployed in Exploded mode. This allows the server to pick up changes made to those projects. The default can be set in the Workspace settings or disabled for a particular project.
You have even greater control over merged deployment by specifying the merged deployment setting at the module level. When you add EJB or Java modules to your web project, you can specify if you want the module deployment to be merged. The default is auto, which automatically selects on or off based on the module content. TLD, ejb-jar.xml, or beans.xml files present in a module default the setting to auto (off). You can override the default setting by specifically choosing on or off.
*The module-level merged deployment is available in MyEclipse 2015 CI 9 or later.
8. Customizing the Default Archive Name
A project's archive filename defaults to the project name. Change this default on the Deployment Assembly tab by expanding Advanced. The archive name you specify is used as the name of the deployed archive.