In my previous blog article, I recommended use of SubVersion repository to share ADF Library JAR files across various JDeveloper applications. Now i will show steps on how to create Deployment Profile to create ADF Library JAR files.
Deployment Profile is JDeveloper concept which is basically visual editor to define how certain archives are build, it can be used to generate EAR, WAR, JAR, MAR etc.
Here are an important notes on development and run time dependencies for JDeveloper.
- Build Output refers to classes folder of Project, where all Java files are compiled. Other types of files are just copied from src to classes on Make or Build.
- Dependencies section on Project Properties is only used for running code in JDeveloper only, so it must reference Build Output (classes sub-folder), which will help you debug your application efficiently in JDeveloper included in Embedded WebLogic server.
- Deployment section of Project Properties is used for generating Artifacts for deployment and is never utilized when running in JDeveloper. Hence all references in this section must reference other Deployment profiles instead of Build Output.
- For dependency on Projects within your application, use Dependencies from Project Properties. For dependency on Projects within other applications use ADF Library JAR from Resource Pallet.
One main goal in packaging artifacts for deployment should be to only include compiled classes and other files from the project itself and not from it’s dependencies. In case of .war and .ear file, you can include JAR files generated by other projects. If you include same class in multiple JAR files, it can cause confusion and weird behavior when code executes on Application Server like WebLogic.
For example, see below Dependencies setup for FlexDeployServies project, which depends on FlexDeployCore and FlexDeployModel projects. It references Build Output from both projects.
Creating Deployment Profiles
- Click New button on Deployment section of Project Properties and Select ADF Library JAR file as Profile Type.
- Follow specific naming conventions. I like to just use Project Name here. So adflib<Project Name> becomes Deployment Profile name.
- Mirror Project’s Dependencies setup, but select Deployment Profiles for dependency projects instead of Build Output. This will make sure that JAR file built using this Profile will only have classes from this project.
- JDeveloper will also run referenced Deployment Profiles first before running this particular Deployment Profile. ADF Library JAR file will also record metadata indicating this dependency and will be useful when this JAR is added to another Project.
- You will notice this in ADF Library Dependencies library when this JAR is added to a different Project.
- select connections that you want exposed to projects that will use this JAR file.
- This information is also recorded in ADF Library JAR, so when this JAR is added to another Project, these connections will be automatically created.
- If you select Connection Details for Include, users will just have to provide user and password information on target application. If you have some test connections that you do not want exposed in this manner, you can unselect those on this section.
- It is also good practice to name your database connections with some logical name as they are automatically propogated. In our case, we have flexdb connection and when Embedded WebLogic starts, it will automatically have jdbc/flexdbDS data source for use by running application. This applies to other types of connections like MapViewer, Content Repository as well.
- as explained in previous blog entry, we are checking out ADF Library JAR files in dependencies sub-folder of application using svn:externals property. And folder structure in this is same as source folder structure, so application folder and project sub-folder is present for each ADF Library JAR.
- Now, as we build Deployment Profile, make sure that JAR is generated in the same folder structure. By default, JDeveloper will generate all jars in deploy sub-folder. Change JAR File: path as shown below to be under dependencies sub-folder of your application root folder.
Now, you can run this profile using DevOps tool like FlexDeploy to commit and tag generated files in SubVersion. I will explain that in my next blog post.