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) <sourceDirectory>
    (-o|outputDirectory) <outputDirectory>
    (-r|--ruleSet) <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
    <project name="Flex PMD example" default="flexPmdWithDefaultRuleset" basedir=".">
    <description>
    Flex PMD example
    </description>
    <property name="src.dir" value="${basedir}/classes/"/>
    <property name="bin.dir" value="${basedir}/../bin/"/>
    <property name="flexpmd.version" value="1.0.RC3"/>
    <property name="flexpmd.dir" value="${basedir}/../flexpmd"/>

    <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"
    

    <flexPmd sourceDirectory="${src.dir}" outputDirectory="${bin.dir}" ruleSet="${flexpmd.dir}/pmd.xml"/>
    </target>
    <target name=
    "flexPmdWithDefaultRuleset"

    <flexPmd sourceDirectory="${src.dir}" outputDirectory="${bin.dir}"/>
    </target>
    </project>

  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
    <pluginRepositories>
    <pluginRepository>
    <id>
    flexpmd.opensource.adobe
    </id>
    <releases>
    <enabled>
    true
    </enabled>
    </releases>
    <snapshots>
    <enabled>
    false
    </enabled>
    </snapshots>
    <name>
    FlexPMD repository on opensource.adobe.com
    </name>
    <url>
    http://opensource.adobe.com/svn/opensource/flexpmd/maven-repository/release/
    </url>
    </pluginRepository>
    </pluginRepositories>
    <reporting>
    <plugins>
    <plugin>
    <groupId>
    com.adobe.ac
    </groupId>
    <artifactId>
    flex-pmd-maven-plugin
    </artifactId>
    <version>
    1.0.RC3
    </version>
    </plugin>
    </plugins>
    </reporting>

  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
    <plugin>
    <groupId>com.adobe.ac</groupId>
    <artifactId>flex-pmd-maven-plugin</artifactId>
    <version>1.0.RC5</version>
    <configuration>
    <ruleSet>${basedir}/your-flex-pmd-ruleset.xml</ruleSet>
    </configuration>
    </plugin>

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

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks