How to invoke FlexPMD

Table of content

How to invoke FlexPMD?

There are several ways to invoke FlexPMD on your project. If you have an automated build or use a continuous integration server, you may want to run FlexPMD with Ant or Maven. Alternatively, you may prefer to simply invoke FlexPMD from the command-line.

From the command line

Here is how to do so:

  1. Extract the archive found in the download section.
    You should have something like (the version number might change):

    :::xml
    $ ls -1
    LICENSE.txt
    as3-parser-1.0.RC3.jar
    as3-parser-api-1.0.RC3.jar
    as3-plugin-utils-1.0.RC3.jar
    commons-lang-2.4.jar
    flex-pmd-command-line-1.0.RC3.jar
    flex-pmd-command-line-api-1.0.RC3.jar
    flex-pmd-core-1.0.RC3.jar
    flex-pmd-files-1.0.RC3.jar
    flex-pmd-ruleset-1.0.RC3.jar
    flex-pmd-ruleset-api-1.0.RC3.jar
    jsap-2.1.jar
    plexus-utils-1.0.2.jar
    pmd-4.2.2.jar

  2. From this folder, type the following to see usage information:

    :::xml
    $ java -Xmx256m -jar flex-pmd-command-line-1.0.RC3.jar
    Aug 8, 2008 3:07:58 PM com.adobe.ac.pmd.commandline.FlexPMD main
    Usage: java com.adobe.ac.pmd.commandline.FlexPMD
    (-s|sourceDirectory)
    (-o|outputDirectory)
    (-r|--ruleSet)

  3. To actually start FlexPMD, specify your project information using the correct arguments, as shown below:

    :::xml
    $ java -Xmx256m -jar flex-pmd-command-line-1.0.RC3.jar -s ./src/ -o . -r custom_ruleset.xml
    $ java -Xmx256m -jar flex-pmd-command-line-1.0.RC3.jar -s ./src/ -o .

This should generate a pmd.xml file in the output directory you specified. This file (pmd.xml) contains the list of the found violations in the source directory. The file can then be pretty-printed by third party readers like, the Violations Hudson plugin, or the PMD Hudson plugin.

From Ant

  1. Copy the libraries, which are inside the archive, inside a local folder (lib, by example)
  2. Update your build.xml like this one:

    :::xml


    Flex PMD example





    <taskdef name=
    "flexPmd"
    

    classname=
    "com.adobe.ac.pmd.ant.FlexPmdAntTask"
    classpath=
    "${flexpmd.dir}/flex-pmd-ant-task-${flexpmd.version}.jar"

    <classpath>
    <pathelement location=
     "${flexpmd.dir}/flex-pmd-ruleset-api-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/flex-pmd-ruleset-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/flex-pmd-core-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/as3-plugin-utils-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/as3-parser-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/pmd-4.2.2.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/commons-lang-2.4.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/flex-pmd-files-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/as3-parser-api-${flexpmd.version}.jar"
    />
    <pathelement location=
     "${flexpmd.dir}/plexus-utils-1.0.2.jar"
    />
    </classpath>
    </taskdef>
    <target name=
     "flexPmdWithCustomRuleset"
    



    <target name=
    "flexPmdWithDefaultRuleset"



  3. Run the Ant target (ant flexPmdWithCustomRuleset). This will produce a pmd.xml file in the output directory you specified. This file (pmd.xml) contains the list of the found violations in the source directory. The file can then be pretty-printed by third party readers like, the Violations Hudson plugin, or the PMD Hudson plugin.

From Maven

  1. Update your pom.xml by adding the following lines in the reporting section:

    :::xml



    flexpmd.opensource.adobe



    true




    false



    FlexPMD repository on opensource.adobe.com


    http://opensource.adobe.com/svn/opensource/flexpmd/maven-repository/release/







    com.adobe.ac


    flex-pmd-maven-plugin


    1.0.RC3



  2. When the Maven build is run, and the site is generated, a pmd.xml file is generated in the output directory you specified. This file (pmd.xml) contains the list of the found violations in the source directory. The file can then be pretty-printed by third party readers like, the Violations Hudson plugin, or the PMD Hudson plugin.

  3. You may want to run the flexPMD engine with your own project specific ruleset, to do so, add the following configuration section in your plugin definition :

    :::xml

    com.adobe.ac
    flex-pmd-maven-plugin
    1.0.RC5

    ${basedir}/your-flex-pmd-ruleset.xml

From Mac OSX automator

  1. Once downloaded, you will need to start the Automator workflow.

![][5]

  1. you will need to specify where the workflow is located in your file system, so that the FlexPMD engine is found correctly by the script, and also potentially, specify the FlexPMD version you are using

![][6]

  1. You will start the workflow, and you will be asked to choose a source folder, that FlexPMD will run against.

![][7]

  1. After running the FlexPMD engine, the workflow will start up a web page which will display the results.

[ ![][9] ][9]


Related

Wiki: 5
Wiki: 6
Wiki: 9


Anonymous


Cancel   Add attachments