I was testing the much improved maven stuff in Jdev for my ADF project and found a couple of differences in my produced jar and the ADF ojdeploy produced one.
First I needed to include the xml, jpx and properties stuff in my jar in the build\resources tag:
So for this I created a mojo plugin and included it in my build step
Onto the plugin:
Create a new maven project in Jdev and make surte the packaging is of type maven-plugin.
Then create a java class (your mojo) and extend org.apache.maven.plugin.AbstractMojo
The @goal sudo annotation denotes the name of your plugin that you will use in the calling project.
/**
* This should generate the extra meta data for adf jar projects.
* @goal adfJarMetadataGenerator
* @phase compile
*/
public class ADFClassMetaDataGenerator extends AbstractMojo {
The @parameter annotation denotes and xml tag that you can pass data to your mojo from the calling project.http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
You then need an public void execute() throws MojoExecutionException { method.
This will go though your project and find the location of your Model.jpx file and your bc4j.xcfg this will allow you to generate the adfm.xml.
adfm.xml
StringBuilder adfmBuilder =
new StringBuilder("\n").append("\n").append("
bc4jFormatName).append("\"/>\n").append("
"\"/>\n").append(" \n");
Then parse the Model.jpx to find all the application modules for the ResourceService.sva.
oracle.adf.common.services.ResourceService.sva
StringBuilder svaBuilder = new StringBuilder("#:__PROLOG__:ADF_LibraryDependencies:!;ADF_DataControl:ADF_BusComps\n");
//for each data control
for(DataControl dc : dcs) {
svaBuilder.append("#:ADF_DataControl:oracle.adf.library.rc.appmodules.AppModuleURLDescriptor:0,").append(dc.getAmName()).append(",").append(dc.getDataContolName()).append(",").append(dc.getFormattedJpxFileName()).append("\n");
}
svaBuilder.append("#:__EPILOG__:\n").append("oracle.adf.library.rc.dependencies.LibDepsServiceStrategy ADF_LibraryDependencies\n").append("oracle.adf.library.rc.dcxdatacontrols.DataControlServiceStrategy ADF_DataControl\n").append("oracle.adf.library.rc.buscomp.BusCompServiceStrategy ADF_BusComps\n");
Then just create these files and you are done.
Do a clean install and you can now use the generator in any of your projects.
Note: This is still a work in progress hopefully I get time to finish it off and I will publish the plugin. But it should give you a good idea of what to do.
First I needed to include the xml, jpx and properties stuff in my jar in the build\resources tag:
Then I needed the adfm.xml and oracle.adf.common.services.ResourceService.sva files all the other files where just text files so I am ignoring them for now.<resource> <directory>src/</directory> <includes> <include>**/*.xml</include> <include>**/*.jpx</include> <include>**/*.xcfg</include> <include>**/*.properties</include> </includes> </resource>
So for this I created a mojo plugin and included it in my build step
<plugin> <groupId>za.co.test.plugins</groupId><artifactId>my-plugins</artifactId><version>1.0-SNAPSHOT</version><executions><execution><phase>compile</phase> <goals> <goal>adfJarMetadataGenerator</goal> </goals> </execution> </executions> </plugin>
Onto the plugin:
Create a new maven project in Jdev and make surte the packaging is of type maven-plugin.
Then create a java class (your mojo) and extend org.apache.maven.plugin.AbstractMojo
The @goal sudo annotation denotes the name of your plugin that you will use in the calling project.
/**
* This should generate the extra meta data for adf jar projects.
* @goal adfJarMetadataGenerator
* @phase compile
*/
public class ADFClassMetaDataGenerator extends AbstractMojo {
The @parameter annotation denotes and xml tag that you can pass data to your mojo from the calling project.http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
/**
* @parameter
*/
private String adfmFileName = "classes/adfm.xml";
/**
* @parameter expression="${project.build.sourceDirectory}"
*/
private File srcDirectory = new File("src/");
/**
* @parameter
*/
private String svaFileName = "classes/oracle.adf.common.services.ResourceService.sva";
* @parameter
*/
private String adfmFileName = "classes/adfm.xml";
/**
* @parameter expression="${project.build.sourceDirectory}"
*/
private File srcDirectory = new File("src/");
/**
* @parameter
*/
private String svaFileName = "classes/oracle.adf.common.services.ResourceService.sva";
You then need an public void execute() throws MojoExecutionException { method.
This will go though your project and find the location of your Model.jpx file and your bc4j.xcfg this will allow you to generate the adfm.xml.
adfm.xml
StringBuilder adfmBuilder =
new StringBuilder("\n").append("
bc4jFormatName).append("\"/>\n").append("
"\"/>\n").append("
Then parse the Model.jpx to find all the application modules for the ResourceService.sva.
oracle.adf.common.services.ResourceService.sva
StringBuilder svaBuilder = new StringBuilder("#:__PROLOG__:ADF_LibraryDependencies:!;ADF_DataControl:ADF_BusComps\n");
//for each data control
for(DataControl dc : dcs) {
svaBuilder.append("#:ADF_DataControl:oracle.adf.library.rc.appmodules.AppModuleURLDescriptor:0,").append(dc.getAmName()).append(",").append(dc.getDataContolName()).append(",").append(dc.getFormattedJpxFileName()).append("\n");
}
svaBuilder.append("#:__EPILOG__:\n").append("oracle.adf.library.rc.dependencies.LibDepsServiceStrategy ADF_LibraryDependencies\n").append("oracle.adf.library.rc.dcxdatacontrols.DataControlServiceStrategy ADF_DataControl\n").append("oracle.adf.library.rc.buscomp.BusCompServiceStrategy ADF_BusComps\n");
Then just create these files and you are done.
Do a clean install and you can now use the generator in any of your projects.
Note: This is still a work in progress hopefully I get time to finish it off and I will publish the plugin. But it should give you a good idea of what to do.
Great post!
ReplyDeleteBTW, does your mojo have any dependency to Oracle ADF library?
Have you made any progress after this post? If so, is there any chance you could make it available?
Thanks a lot.
Sorry I did not get any further - project timelines did not allow and I am on a different project now.
DeleteHopefully I will get back to this at some stage though then I will let you know.
Not a problem.
DeleteWould you mind making make the current code available anyway? I would like to see how you've obtained the data control objects via API.
Any help will be appreaciated.
Regards.
Email me at the email address on my profile and I will see what I can do.
Delete