Home > 未分類 > FlashDevelopにFlexPMDボタンを追加するメモ

FlashDevelopにFlexPMDボタンを追加するメモ

まず、こちらを参考にしてantとやFlexPMDをインストールします。
FlexPMD :: 環境構築から実験まで。-ソースコード解析によるバグの早期発見とコーディング規約準拠-

ここまでたら、もう少し便利に利用したいのでツールバーにボタンを追加するか、マクロを登録しましょう。

ツールバーにボタンを追加する

C:\Program Files\FlashDevelop\Settings\ToolBar.xmlの、からまでの好きな行に

<button label="Flex PMD" click="c:\windows\system32\cmd.exe;/c $(Quote)cd $(ProjectDir)&amp;&amp;ant flexPmdWithDefaultRuleset -buildfile build.xml$(Quote)" tag="c:\windows\system32\cmd.exe;/c $(Quote)cd $(ProjectDir)&amp;&amp;ant flexPmdWithDefaultRuleset -buildfile build.xml$(Quote)" image="486" />

を追加。

マクロを登録する

メニュー>Macros>Edit Macros..を開きます。
出てきたウインドウの左下のAddをクリックするとUntitledというのが出てくるのでそれをクリック、
Labelを&FlexPMDとして、
Entriesのところを開いて

RunProcessCaptured|c:\windows\system32\cmd.exe;/c cd $(ProjectDir)&&ant flexPmdWithDefaultRuleset -buildfile build.xml

とします。
Shortcutなどはお好みでどうぞ。

プロジェクトのPMDを書き出す

どちらかが終わったら、
いままでAntのインストールフォルダ直下に置いていたbuild.xmlをコピーして、
PMDしたいプロジェクトのas3projがあるフォルダに追加。

build.xmlの11行目のsrc.dirのvalueを、クラスを置いてる場所に書き換え。

<property name="src.dir" value="src\" />

みたいな感じに。

あとはFlashDevelopを再起動して、ツールバーに新しく登録された赤いアリさんアイコンか、マクロをクリックしたらpmd.xmlが書き出されます。

FDのプロジェクトテンプレートに、以下のようなbuild.xml.templateファイルを追加するともっと便利かも。
src.dirのvalueを自動的に書き込んでくれるんで、ここまできたら手軽に利用できますね。

<?xml version="1.0" encoding="utf-8"?>
<project name="Flex PMD example" default="flexPmd" >

    <description>
        Flex PMD
    </description>

    <property name="projecthome" value="${basedir}/.." />
    <property name="flexpmd.version" value="1.0-RC3" />
    <property name="flexpmd.dir" value="${basedir}/somedir" />
	<property name="src.dir" value="src/$(PackageSlash)" />
	<property name="bin.dir" value="./" />

    <!--****************************************************
                FlexPMD
        *****************************************************-->

        <taskdef name="flexPmd"
             classname="com.adobe.ac.pmd.ant.FlexPmdAntTask"
             classpath="${flexpmd.dir}/lib/flex-pmd-ant-task-${flexpmd.version}.jar">
        <classpath>
            <pathelement location="${flexpmd.dir}/lib/flex-pmd-ruleset-api-${flexpmd.version}.jar"/>
            <pathelement location="${flexpmd.dir}/lib/flex-pmd-ruleset-${flexpmd.version}.jar"/>
            <pathelement location="${flexpmd.dir}/lib/flex-pmd-core-${flexpmd.version}.jar"/>
            <pathelement location="${flexpmd.dir}/lib/as3-plugin-utils-${flexpmd.version}.jar"/>
            <pathelement location="${flexpmd.dir}/lib/as3-parser-${flexpmd.version}.jar"/>
            <pathelement location="${flexpmd.dir}/lib/pmd-4.2.2.jar"/>
            <pathelement location="${flexpmd.dir}/lib/commons-lang-2.4.jar"/>
            <pathelement location="${flexpmd.dir}/lib/flex-pmd-files-${flexpmd.version}.jar"/>
            <pathelement location="${flexpmd.dir}/lib/as3-parser-api-${flexpmd.version}.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>

Comments:0

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://blog.sncr.jp/249/trackback
Listed below are links to weblogs that reference
FlashDevelopにFlexPMDボタンを追加するメモ from blog.sncr.jp

Home > 未分類 > FlashDevelopにFlexPMDボタンを追加するメモ

Search
Feeds
Meta

Return to page top