Deployment Profiles explained
By rovarghe on Jul 31, 2013
A Deployment Profile is a data structure in JDeveloper that describes how to put together the contents of a Project or Application for publishing to a remote target. The target can be the file system, an Application Server, a Mobile device, etc. anything that JDeveloper can interface with.
The most common type of Deployment Profile is a JAR Profile, which lets you simply zip up all the contents of the project into a .jar file. A JAR Profile consists of one or more FileGroups, similar to Ant filesets, but at a higher level of abstraction. A FileGroup has Contributors, that act as the source of files, and filter patterns that select from them. Finally it has a target location within the jar where the selected files should end up.
For example, a "Project Source" contributor would provide all source files, a pattern of "Include **" would select all the files and a target of "src" would put all the source files under the "/src/" directory within the .jar archive.
Similarly, a "Project Output" contributor would get all the compiled .class files. Arbitrary directories can also be added as contributors, but this is usually not a good idea, its better to express the dependency to that directory in some other form and have one of the standard or pre-defined contributors bring it in.
So far we've been referring to a specific type of FileGroup called a Packaging file group. Another useful FileGroup which can be included in a JAR Profile is the Library file group. This file group gathers all the Libraries of a project and adds each one as a contributor source. Based on the definition of the library, it also makes some choices as to which ones to omit. For example, libraries that are not marked 'Deployed by Default' are not added. Users have the option to override the default. Just like the Packagingfile group, the Libraryfile group also lets you select the actual files from the library using patterns, by default all files from a certain library are added (in JDeveloper each Library can have several jar files).
All these actions can be done via UI, or using the API. A default "JAR Profile" is an instance of the ArchiveProfile class. A ProfileFactory is provided as a facade to create any type of profile.
import oracle.ide.Context; import oracle.jdeveloper.deploy.ProfileFactory; import oracle.jdeveloper.deploy.jar.ArchiveProfile; ProfileFactory factory = ProfileFactory.getInstance(); // Create a context for the profile. // Here we have a pre-existing project. Context context = new Context( project ); // Create a JAR profile with a single packaging file group and a single // library file group MyProfile p = factory.create( "name1", ArchiveProfile.class, context);
Next we'll see how to deploy this profile to disk.