Posts Tagged External Tools

Deploy your ADF Mobile App to a virtual Android device from JDeveloper IDE

If you tired from the android emulator speed you may have read Chris Muir’s article ADF Mobile: Avoiding the Android Emulator with AndroVM.

In the meantime the successor of AndroVM is GENYMOTION.

If you have configured the port forwarding section from the AndroVM or use GENYMOTION, then you have to deploy your ADF Mobile app first to apk-File and manually install this into to the virtual android image via the android sdk command adb. The virtual Android device must be started to do this.

To do the last step from JDeveloper IDE directly with 1 click following steps help to reach this:

  1. Convention over configuration: Name all of your deployment profiles for android with the same name, eg. all adf mobile samples use the name “ANDROID_MOBILE_NATIVE_archive1”
  2. Create in JDeveloper an external tool
    1. Select from the menu Tools -> External Tools … -> New
    2. Select Tool Type: External Program

    3. Select Program Executable: adb.exe from your Android SDK
      Enter Arguments: install ${workspace.dir}\deploy\ANDROID_MOBILE_NATIVE_archive1\${}.apk

    4. Enter Caption for Menu Items, eg.: Install apk file to virtual Android device

    5. Select Add Items to Menus: Navigator Context Menu

    6. Select Enabled When Specific File Types are selected: Application

Now you first deploy your Application to an Android package:

Then you can install this via application context menu directly to your virtual android devive:

Now you can test your app in the virtual Android device:

That’s it!

Chrysanth WebStory Published by WebStory

, , , , ,


Write ADF static code analysis rules with PMD and running these in JDeveloper

Do you know, that PMD can analyse XML files since version 5? Many of ADF files are XML configuration files – wouldn’t it be a good idea to create some static code analysis rules for ADF too?

Unfortunatly oracle configuration files in most times create references to dtd’s, which are not exist anywhere in the path. Till PMD 5.0.1 such files results in errors, as PMD tries to validate this doctype. I have switched of this validation in PMD release 5.0.2.

Following article requires configuration of PMD as described in my blog PMD Integration with JDeveloper through Ant External Tools.

You can download all requried files from here.

Let’s start from the beginning.

  1. At the moment PMD only provide XML check’s against files with the extension *.xml, there is a feature request to change this behaviour. So at the moment, we have to change the code by ourself to reach the result. Load the the 5.0.4 source code.
  2. Look for the file src\main\java\net\sourceforge\pmd\lang\ and replace the line
    XML(“XML”, null, “xml”, XmlRuleChainVisitor.class, “xml”);
    XML(“XML”, null, “xml”, XmlRuleChainVisitor.class, “xml”, “jws”, “jpr”, “cpx”, “xcfg”, “dcx”, “jpx”);
  3. Change to directory pmd-src-5.0.4
  4. set JAVA_HOME, e.g. to your 1.6 JDeveloper jdk
  5. run “mvn clean package”, I have succesfully used maven 2.2.1 from <JDev-Home>\jdeveloper\apache-maven-2.2.1\bin
  6. If you don’t need further extensions, you can instead running steps 2 till 5 the resulting pmd-5.0.4.jar from my side.
  7. Replace the file pmd-5.0.4.jar in pmd-bin-5.0.4\lib (see my previous blog) with the downloaded file or the file from pmd-src-5.0.4\target
  8. Now is the time to create the first adf static code analysis rule. In the adf architecture course I attend, there was a rule, that the taskflow behaviour “No controller transaction”
    should not be mixed with the other option of this selection list

    In the sourcecode this property is described through the absence of the node adfc-config/task-flow-definition/transaction, the other options create this node and additional child nodes, here e.g. for the option “Always create new transaction”
  9. In PMD you can create two kind of rules: Java and XPath. For our xml Files XPath should be the efficient option. We have to put our configuraration e.g. in file my_pmd_rules.xml in the same directory as pmd.xml in the last blog. For the above rule the XPath query in line 14 find nodes, which does not contain the transaction node
    <?xml version="1.0"?>
    <ruleset name="Oracle ADF rules" xmlns=""
    <description>This ruleset checks Oracle ADF code for bad stuff</description>
    <!-- ADF Rules ############################################################################################### -->
    <rule name="OracleAdfTaskflowShouldNotHaveNoControllerTransaktion" since="5.0" language="xml"
    message='ADF tasklows should normally not contain transaktion behavior "No Controller Transaction"'
    <property name="xpath">
  10. Now we have to change the configuration file pmd.xml from the last blog in the marked lines to call our new configuration and run this on files with defined Extensions
    <?xml version="1.0" encoding="windows-1252" ?>
    <project xmlns="" name="Project1" default="all" basedir=".">
    <path id="classpathForPMD">
    <fileset dir="pmd-bin-5.0.4\lib">
    <include name="**/**.jar"/>
    <taskdef name="pmd" classpathref="classpathForPMD" classname="net.sourceforge.pmd.ant.PMDTask"/>
    <target name="pmdAll">
    <echo message="PMD is running on directory ${dir}" level="info"/>
    <pmd rulesetfiles="my_pmd_rules.xml" failOnRuleViolation="true" minimumPriority="1">
    <fileset dir="${dir}">
    <include name="**/*.java"/>
    <include name="**/*.xml"/>
    <include name="**/*.jws"/>
    <include name="**/*.jpr"/>
    <include name="**/*.cpx"/>
    <include name="**/*.xcfg"/>
    <include name="**/*.dcx"/>
    <include name="**/*.jpx"/>
  11. Now call again pmd from the Fusion Order Demo Application StoreFrontModule
  12. You can see the results for xml in the message pane. Unfortunatly the direct jump to violated files does not work at the moment as pmd delivers for every xml violation -1 as line, but I have created an bug for this

That’s it.

Maybe somebody has an idea, where we can build an extension exchange for ADF rules, e.g. for creating rules for ADF Code Guidelines v1.00 or ADF Naming and Project Layout Guidelines v2.00?

Remember: you are not restricted to ADF files, e.g. we do checks to for JDeveloper application (*.jws) and project files (*.jpr) as well, as this are xml files too. The configuration you see already in step 2.

Chrysanth WebStory Published by WebStory

, , , , ,

Leave a comment

PMD Integration with JDeveloper through Ant External Tools

In the past I read following blogs from Shay Shmeltzer:

Now (after little code change in pmd) this integration is possible. I use here JDeveloper, with other versions this should be very similar. Now let’s start:

1. Create a new folder
2. Download PMD 5.0.4
3. Extract the zip file into the created folder
4. Create a file pmd.xml into the created folder
5. Enter following code into the file pmd.xml:

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="" name="Project1" default="all" basedir=".">
    <path id="classpathForPMD">
        <fileset dir="pmd-bin-5.0.4\lib">
            <include name="**/**.jar"/>
    <taskdef name="pmd" classpathref="classpathForPMD" classname="net.sourceforge.pmd.ant.PMDTask"/>
    <target name="pmdAll">
        <echo message="PMD is running on directory ${dir}" level="info"/>
        <pmd rulesetfiles="rulesets/internal/dogfood.xml" failOnRuleViolation="true" minimumPriority="1">
            <fileset dir="${dir}">
                <include name="**/src/**/*.java"/>
    <target name="pmd">
        <echo message="PMD is running on file ${dir}\${file}" level="info"/>
        <pmd rulesetfiles="rulesets/internal/dogfood.xml" failOnRuleViolation="true">
            <fileset dir="${dir}">
                <include name="${file}"/>

6. Select Tools – Exernal Tools from the JDeveloper menu
7. Press Button New
8. Select Tool Type: Apache Ant
9. Select your created pmd.xml file in Ant Buildfile:

10. Shuttle target pmdAll to SelectedTargets

11. Add Property dir with value ${file.dir}

12. Skip the Options and Process Step to leave the defaults
13. Add the lib directory of pmd as additional classpath entry

14. Enter Caption and Icon as you want

15. Add the tool to the Navigator Context Menu and Main Toolbar and do not forget to set Log Output to Messages Log

16. Press Next and Finish.

Now you can call pmd e.g. from the fusion order demo application

You see the results of the ant process in the message pane and you can click on the link to open the file and jump to the rule violation:

In upcoming blogs I will show you how you can define your own rulesets (replacing the ones in pmd.xml) and how to use it with any kind of xml files, eg. jws, jpr, xcfg etc..

Chrysanth WebStory Published by WebStory

, , , ,

1 Comment