You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/08/27 00:43:55 UTC

[24/51] [partial] Refactored the PMD Maven build - Adjusted the directory structure - Fixed a lot of compile problems - Fixed the maven setup - Made PMD build with Flexmojos 7.1.0 and Apache Flex 4.13.0 - Fixed a few UnitTests

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/pom.xml
new file mode 100644
index 0000000..32e8a44
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/pom.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.flex.pmd</groupId>
+        <artifactId>flex-pmd-java</artifactId>
+        <version>1.3-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>flex-pmd-cpd-command-line</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Adobe Flex CPD Command line</name>
+
+    <properties>
+        <maven.jar.plugin.version>2.2</maven.jar.plugin.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.martiansoftware</groupId>
+            <artifactId>jsap</artifactId>
+            <version>${jsap.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <version>${project.version}</version>
+            <artifactId>flex-pmd-command-line-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>pmd</groupId>
+            <artifactId>pmd</artifactId>
+            <version>${pmd.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <version>${project.parent.version}</version>
+            <artifactId>flex-pmd-cpd</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <version>${project.version}</version>
+            <artifactId>flex-pmd-files</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>as3-plugin-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>as3-parser</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>as3-parser-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>${commons-lang.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>flex-pmd-test-resources</artifactId>
+            <version>${project.parent.version}</version>
+            <classifier>resources</classifier>
+            <type>zip</type>
+            <scope>provided</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+
+        <testResources>
+            <testResource>
+                <directory>${project.build.directory}/test/generated-resources</directory>
+            </testResource>
+        </testResources>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>unpack-test-resources</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <includeGroupIds>${project.groupId}</includeGroupIds>
+                            <includes>**/*.as,**/*.mxml</includes>
+                            <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
+                            <excludeTransitive>true</excludeTransitive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>${maven.jar.plugin.version}</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>com.adobe.ac.cpd.commandline.FlexCPD</mainClass>
+                            <packageName>com.adobe.ac.cpd.commandline</packageName>
+                            <addClasspath>true</addClasspath>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <version>${maven-antrun-plugin.version}</version>
+                <executions>
+                    <execution>
+                        <id>package-ant-task</id>
+                        <phase>install</phase>
+                        <configuration>
+                            <tasks>
+                                <echo message="Building ant-task"/>
+                                <mkdir dir="${project.build.directory}/release"/>
+                                <echo message=""/>
+                                <echo message="Copying Flex CPD dependencies..."/>
+                                <copy file="${project.build.directory}/${project.build.finalName}.jar"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${org.apache.flex.pmd:flex-pmd-command-line-api:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${org.apache.flex.pmd:as3-parser-api:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${org.apache.flex.pmd:as3-parser:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${org.apache.flex.pmd:flex-pmd-cpd:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${org.apache.flex.pmd:flex-pmd-files:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${org.apache.flex.pmd:as3-plugin-utils:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <echo message="Copying Command line dependencies..."/>
+                                <copy file="${pmd:pmd:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${commons-lang:commons-lang:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <copy file="${com.martiansoftware:jsap:jar}"
+                                      todir="${project.build.directory}/release" overwrite="true"/>
+                                <echo message="Extracting license..."/>
+                                <copy file="../../src/etc/header.txt"
+                                      tofile="${project.build.directory}/release/LICENSE.txt" overwrite="true"/>
+                                <echo message="Compressing zip..."/>
+                                <zip destfile="${project.build.directory}/${project.build.finalName}.zip"
+                                     basedir="${project.build.directory}/release" excludes="*.zip"/>
+                            </tasks>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java
new file mode 100644
index 0000000..a359eb4
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.commandline;
+
+import com.adobe.ac.pmd.ICommandLineOptions;
+
+public enum CpdCommandLineOptions implements ICommandLineOptions
+{
+   MINIMUM_TOKENS("minimumTokens"), OUTPUT_FILE("outputFile");
+
+   private String name;
+
+   private CpdCommandLineOptions( final String nameToBeSet )
+   {
+      name = nameToBeSet;
+   }
+
+   @Override
+   public String toString()
+   {
+      return name;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java
new file mode 100644
index 0000000..c43042f
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.commandline;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.sourceforge.pmd.PMDException;
+import net.sourceforge.pmd.cpd.CPD;
+import net.sourceforge.pmd.cpd.FileReporter;
+import net.sourceforge.pmd.cpd.Renderer;
+import net.sourceforge.pmd.cpd.ReportException;
+import net.sourceforge.pmd.cpd.XMLRenderer;
+
+import com.adobe.ac.cpd.FlexLanguage;
+import com.adobe.ac.cpd.FlexTokenizer;
+import com.adobe.ac.pmd.CommandLineOptions;
+import com.adobe.ac.pmd.CommandLineUtils;
+import com.adobe.ac.pmd.ICommandLineOptions;
+import com.adobe.ac.pmd.LoggerUtils;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+import com.martiansoftware.jsap.JSAP;
+import com.martiansoftware.jsap.JSAPException;
+import com.martiansoftware.jsap.JSAPResult;
+
+public final class FlexCPD
+{
+   private static JSAPResult        config;
+   private static final String      ENCODING = System.getProperty( "file.encoding" );
+   private static final Logger      LOGGER   = Logger.getLogger( FlexCPD.class.getName() );
+   private static FlexCpdParameters parameters;
+
+   public static void main( final String[] args ) throws JSAPException,
+                                                 URISyntaxException,
+                                                 IOException,
+                                                 ReportException,
+                                                 PMDException
+   {
+      new LoggerUtils().loadConfiguration();
+      startFlexCPD( args );
+      LOGGER.info( "FlexCPD terminated" );
+      System.exit( 0 ); // NOPMD
+   }
+
+   static boolean areCommandLineOptionsCorrect( final String[] args ) throws JSAPException
+   {
+      final JSAP jsap = new JSAP();
+      config = parseCommandLineArguments( args,
+                                          jsap );
+
+      if ( !config.success() )
+      {
+         LOGGER.log( Level.SEVERE,
+                     "Usage: java "
+                           + FlexCPD.class.getName() + " " + jsap.getUsage() );
+      }
+
+      return config.success();
+   }
+
+   static String getParameterValue( final ICommandLineOptions option )
+   {
+      return config.getString( option.toString() );
+   }
+
+   static boolean startFlexCPD( final String[] args ) throws JSAPException,
+                                                     URISyntaxException,
+                                                     IOException,
+                                                     ReportException,
+                                                     PMDException
+   {
+      if ( areCommandLineOptionsCorrect( args ) )
+      {
+         final String minimumTokens = getParameterValue( CpdCommandLineOptions.MINIMUM_TOKENS );
+         final String source = getParameterValue( CommandLineOptions.SOURCE_DIRECTORY );
+         final File sourceDirectory = source.contains( "," ) ? null
+                                                            : new File( source );
+         final List< File > sourceList = CommandLineUtils.computeSourceList( source );
+         final File outputDirectory = new File( getParameterValue( CpdCommandLineOptions.OUTPUT_FILE ) );
+
+         parameters = new FlexCpdParameters( outputDirectory,
+                                             minimumTokens == null ? FlexTokenizer.DEFAULT_MINIMUM_TOKENS
+                                                                  : Integer.valueOf( minimumTokens ),
+                                             sourceDirectory,
+                                             sourceList );
+         LOGGER.info( "Starting run, minimumTokenCount is "
+               + parameters.getMinimumTokenCount() );
+
+         LOGGER.info( "Tokenizing files" );
+         final CPD cpd = new CPD( parameters.getMinimumTokenCount(), new FlexLanguage() );
+
+         cpd.setEncoding( ENCODING );
+         tokenizeFiles( cpd );
+
+         LOGGER.info( "Starting to analyze code" );
+         final long timeTaken = analyzeCode( cpd );
+         LOGGER.info( "Done analyzing code; that took "
+               + timeTaken + " milliseconds" );
+
+         LOGGER.info( "Generating report" );
+         report( cpd );
+      }
+
+      return config.success();
+   }
+
+   private static long analyzeCode( final CPD cpd )
+   {
+      final long start = System.currentTimeMillis();
+      cpd.go();
+      final long stop = System.currentTimeMillis();
+      return stop
+            - start;
+   }
+
+   private static JSAPResult parseCommandLineArguments( final String[] args,
+                                                        final JSAP jsap ) throws JSAPException
+   {
+      CommandLineUtils.registerParameter( jsap,
+                                          CommandLineOptions.SOURCE_DIRECTORY,
+                                          true );
+      CommandLineUtils.registerParameter( jsap,
+                                          CpdCommandLineOptions.OUTPUT_FILE,
+                                          true );
+      CommandLineUtils.registerParameter( jsap,
+                                          CpdCommandLineOptions.MINIMUM_TOKENS,
+                                          false );
+      CommandLineUtils.registerParameter( jsap,
+                                          CommandLineOptions.EXLUDE_PACKAGE,
+                                          false );
+
+      return jsap.parse( args );
+   }
+
+   private static void report( final CPD cpd ) throws ReportException,
+                                              IOException
+   {
+      if ( !cpd.getMatches().hasNext() )
+      {
+         LOGGER.info( "No duplicates over "
+               + parameters.getMinimumTokenCount() + " tokens found" );
+      }
+      final Renderer renderer = new XMLRenderer( ENCODING );
+
+      if ( !parameters.getOutputFile().exists() )
+      {
+         if ( parameters.getOutputFile().createNewFile() == false )
+         {
+            LOGGER.warning( "Could not create a new output file" );
+         }
+      }
+
+      final FileReporter reporter = new FileReporter( parameters.getOutputFile(), ENCODING );
+      reporter.report( renderer.render( cpd.getMatches() ) );
+   }
+
+   private static void tokenizeFiles( final CPD cpd ) throws IOException,
+                                                     PMDException
+   {
+      final Map< String, IFlexFile > files = FileUtils.computeFilesList( parameters.getSourceDirectory(),
+                                                                         parameters.getSourceList(),
+                                                                         "",
+                                                                         null );
+
+      for ( final Entry< String, IFlexFile > fileEntry : files.entrySet() )
+      {
+         cpd.add( new File( fileEntry.getValue().getFilePath() ) ); // NOPMD
+      }
+   }
+
+   private FlexCPD()
+   {
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java
new file mode 100644
index 0000000..dfdd0b3
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.commandline;
+
+import java.io.File;
+import java.util.List;
+
+public class FlexCpdParameters
+{
+   private final Integer      minimumTokenCount;
+   private final File         outputFile;
+   private final File         sourceDirectory;
+   private final List< File > sourceList;
+
+   public FlexCpdParameters( final File outputFileToBeSet,
+                             final Integer minimumTokenCountToBeSet,
+                             final File sourceDirectoryToBeSet,
+                             final List< File > sourceListToBeSet )
+   {
+      super();
+      minimumTokenCount = minimumTokenCountToBeSet;
+      outputFile = outputFileToBeSet;
+      sourceDirectory = sourceDirectoryToBeSet;
+      sourceList = sourceListToBeSet;
+   }
+
+   public final Integer getMinimumTokenCount()
+   {
+      return minimumTokenCount;
+   }
+
+   public final File getOutputFile()
+   {
+      return outputFile;
+   }
+
+   public final File getSourceDirectory()
+   {
+      return sourceDirectory;
+   }
+
+   public List< File > getSourceList()
+   {
+      return sourceList;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java
new file mode 100644
index 0000000..9526b0a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.commandline;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import net.sourceforge.pmd.PMDException;
+import net.sourceforge.pmd.cpd.ReportException;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.CommandLineOptions;
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.martiansoftware.jsap.JSAPException;
+
+public class FlexCPDTest extends FlexPmdTestBase
+{
+   @Test
+   public void testAreCommandLineOptionsCorrect() throws FileNotFoundException,
+                                                 JSAPException,
+                                                 PMDException,
+                                                 URISyntaxException
+   {
+      assertFalse( FlexCPD.areCommandLineOptionsCorrect( new String[]
+      {} ) );
+
+      assertFalse( FlexCPD.areCommandLineOptionsCorrect( new String[]
+      { "-y",
+                  "sourceDirectory",
+                  "-p",
+                  "outPutDirectory" } ) );
+
+      assertTrue( FlexCPD.areCommandLineOptionsCorrect( new String[]
+      { "-s",
+                  "sourceDirectory",
+                  "-o",
+                  "target",
+                  "-m",
+                  "50" } ) );
+
+      assertTrue( FlexCPD.areCommandLineOptionsCorrect( new String[]
+      { "-s",
+                  "sourceDirectory",
+                  "-o",
+                  "target" } ) );
+   }
+
+   @Test
+   public void testGetCommandLineValue() throws JSAPException
+   {
+      FlexCPD.areCommandLineOptionsCorrect( new String[]
+      { "-s",
+                  "sourceDirectory",
+                  "-o",
+                  "target",
+                  "-m",
+                  "25" } );
+
+      assertEquals( "sourceDirectory",
+                    FlexCPD.getParameterValue( CommandLineOptions.SOURCE_DIRECTORY ) );
+      assertEquals( "target",
+                    FlexCPD.getParameterValue( CpdCommandLineOptions.OUTPUT_FILE ) );
+      assertEquals( "25",
+                    FlexCPD.getParameterValue( CpdCommandLineOptions.MINIMUM_TOKENS ) );
+   }
+
+   @Test
+   public void testStartFlexCPD() throws JSAPException,
+                                 PMDException,
+                                 URISyntaxException,
+                                 IOException,
+                                 ReportException
+   {
+      final String[] args = new String[]
+      { "-s",
+                  getTestDirectory().getAbsolutePath(),
+                  "-o",
+                  new File( "target/cpd.xml" ).getAbsolutePath(),
+                  "--excludePackage",
+                  "cairngorm." };
+
+      FlexCPD.startFlexCPD( args );
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/pom.xml
new file mode 100644
index 0000000..7089f25
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/pom.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.flex.pmd</groupId>
+        <artifactId>flex-pmd-java</artifactId>
+        <version>1.3-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>flex-pmd-cpd-maven-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+
+    <name>Adobe Flex CPD Maven plugin</name>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>pmd</groupId>
+            <artifactId>pmd</artifactId>
+            <version>${pmd.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>${maven-plugin-api.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.reporting</groupId>
+            <artifactId>maven-reporting-impl</artifactId>
+            <version>${maven-reporting-impl.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-pmd-plugin</artifactId>
+            <version>${maven-pmd-plugin.version}</version>
+            <type>maven-plugin</type>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>flex-pmd-core</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>flex-pmd-cpd</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>flex-pmd-files</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>flex-pmd-test-resources</artifactId>
+            <version>${project.parent.version}</version>
+            <classifier>resources</classifier>
+            <type>zip</type>
+            <scope>provided</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+
+        <testResources>
+            <testResource>
+                <directory>${project.build.directory}/test/generated-resources</directory>
+            </testResource>
+        </testResources>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>unpack-test-resources</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <includeGroupIds>${project.groupId}</includeGroupIds>
+                            <includes>**/*.as,**/*.mxml</includes>
+                            <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
+                            <excludeTransitive>true</excludeTransitive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
new file mode 100644
index 0000000..e7481e5
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Map.Entry;
+
+import net.sourceforge.pmd.PMDException;
+import net.sourceforge.pmd.cpd.CPD;
+import net.sourceforge.pmd.cpd.FileReporter;
+import net.sourceforge.pmd.cpd.Renderer;
+import net.sourceforge.pmd.cpd.ReportException;
+import net.sourceforge.pmd.cpd.XMLRenderer;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.doxia.site.renderer.SiteRenderer;
+
+import com.adobe.ac.cpd.FlexLanguage;
+import com.adobe.ac.pmd.LoggerUtils;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+
+/**
+ * @author xagnetti
+ * @goal check
+ * @phase verify
+ */
+public class FlexCpdMojo extends AbstractMavenReport
+{
+   private static final String OUTPUT_NAME = "cpd";
+
+   protected static ResourceBundle getBundle( final Locale locale )
+   {
+      return ResourceBundle.getBundle( "flexPmd",
+                                       locale,
+                                       FlexCpdMojo.class.getClassLoader() ); // NOPMD
+   }
+
+   private final String encoding = System.getProperty( "file.encoding" );
+
+   /**
+    * Location of the file.
+    * 
+    * @parameter expression="25"
+    * @required
+    */
+   private int          minimumTokenCount;
+
+   /**
+    * Location of the file.
+    * 
+    * @parameter expression="${project.build.directory}"
+    * @required
+    */
+   private File         outputDirectory;
+
+   /**
+    * @parameter expression="${project}"
+    * @required
+    * @readonly
+    */
+   private MavenProject project;
+
+   /**
+    * @parameter 
+    *            expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
+    * @required
+    * @readonly
+    */
+   private SiteRenderer siteRenderer;
+
+   /**
+    * Specifies the location of the source files to be used.
+    * 
+    * @parameter expression="${project.build.sourceDirectory}"
+    * @required
+    * @readonly
+    */
+   private File         sourceDirectory;
+
+   public FlexCpdMojo()
+   {
+      super();
+   }
+
+   public FlexCpdMojo( final File outputDirectoryToBeSet,
+                       final File sourceDirectoryToBeSet,
+                       final MavenProject projectToBeSet )
+   {
+      super();
+      outputDirectory = outputDirectoryToBeSet;
+      sourceDirectory = sourceDirectoryToBeSet;
+      project = projectToBeSet;
+      minimumTokenCount = 25;
+   }
+
+   public String getDescription( final Locale locale )
+   {
+      return getBundle( locale ).getString( "report.flexCpd.description" );
+   }
+
+   public final String getName( final Locale locale )
+   {
+      return getBundle( locale ).getString( "report.flexCpd.name" );
+   }
+
+   public final String getOutputName()
+   {
+      return OUTPUT_NAME;
+   }
+
+   void setSiteRenderer( final SiteRenderer site )
+   {
+      siteRenderer = site;
+   }
+
+   @Override
+   protected void executeReport( final Locale locale ) throws MavenReportException
+   {
+      new LoggerUtils().loadConfiguration();
+
+      final CPD cpd = new CPD( minimumTokenCount, new FlexLanguage() );
+
+      try
+      {
+         final Map< String, IFlexFile > files = FileUtils.computeFilesList( sourceDirectory,
+                                                                            null,
+                                                                            "",
+                                                                            null );
+
+         for ( final Entry< String, IFlexFile > fileEntry : files.entrySet() )
+         {
+            cpd.add( new File( fileEntry.getValue().getFilePath() ) ); // NOPMD
+         }
+
+         cpd.go();
+
+         report( cpd );
+      }
+      catch ( final PMDException e )
+      {
+         throw new MavenReportException( "", e );
+      }
+      catch ( final IOException e )
+      {
+         throw new MavenReportException( "", e );
+      }
+      catch ( final ReportException e )
+      {
+         throw new MavenReportException( "", e );
+      }
+   }
+
+   @Override
+   protected String getOutputDirectory()
+   {
+      return outputDirectory.getAbsolutePath();
+   }
+
+   @Override
+   protected MavenProject getProject()
+   {
+      return project;
+   }
+
+   @Override
+   protected SiteRenderer getSiteRenderer()
+   {
+      return siteRenderer;
+   }
+
+   private void report( final CPD cpd ) throws ReportException
+   {
+      final Renderer renderer = new XMLRenderer( encoding );
+      final FileReporter reporter = new FileReporter( new File( outputDirectory.getAbsolutePath(),
+                                                                OUTPUT_NAME
+                                                                      + ".xml" ), encoding );
+      reporter.report( renderer.render( cpd.getMatches() ) );
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
new file mode 100644
index 0000000..238be18
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+report.flexCpd.name=

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
new file mode 100644
index 0000000..93d09cb
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd.maven;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.codehaus.doxia.site.renderer.DefaultSiteRenderer;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+
+public class FlexCpdMojoTest extends FlexPmdTestBase
+{
+   @Test
+   public void testExecute() throws MojoExecutionException,
+                            IOException
+   {
+      final FlexCpdMojo mojo = new FlexCpdMojo( new File( "target" ),
+                                                getTestDirectory(),
+                                                new MavenProjectStub() );
+
+      mojo.setSiteRenderer( new DefaultSiteRenderer() );
+      mojo.execute();
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-cpd/pom.xml
new file mode 100644
index 0000000..3e02e2c
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd/pom.xml
@@ -0,0 +1,93 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.flex.pmd</groupId>
+        <artifactId>flex-pmd-java</artifactId>
+        <version>1.3-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>flex-pmd-cpd</artifactId>
+    <packaging>jar</packaging>
+
+	<name>Adobe Flex CPD (Copy and Past Detector)</name>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>pmd</groupId>
+			<artifactId>pmd</artifactId>
+			<version>${pmd.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<version>${project.parent.version}</version>
+			<artifactId>as3-parser</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.parent.groupId}</groupId>
+			<artifactId>flex-pmd-test-resources</artifactId>
+			<version>${project.parent.version}</version>
+			<classifier>resources</classifier>
+			<type>zip</type>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<version>${project.version}</version>
+			<artifactId>flex-pmd-files</artifactId>
+		</dependency>
+
+	</dependencies>
+
+	<build>
+		<testResources>
+			<testResource>
+				<directory>${project.build.directory}/test/generated-resources</directory>
+			</testResource>
+		</testResources>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-dependency-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>unpack-test-resources</id>
+						<phase>generate-resources</phase>
+						<goals>
+							<goal>unpack-dependencies</goal>
+						</goals>
+						<configuration>
+							<includeGroupIds>${project.groupId}</includeGroupIds>
+							<includes>**/*.as,**/*.mxml</includes>
+							<outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
+							<excludeTransitive>true</excludeTransitive>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+	
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
new file mode 100644
index 0000000..b71ce3f
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd;
+
+import net.sourceforge.pmd.cpd.AbstractLanguage;
+
+public class FlexLanguage extends AbstractLanguage
+{
+   public FlexLanguage()
+   {
+      super( new FlexTokenizer(), "as", "mxml" );
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
new file mode 100644
index 0000000..252009d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sourceforge.pmd.cpd.SourceCode;
+import net.sourceforge.pmd.cpd.TokenEntry;
+import net.sourceforge.pmd.cpd.Tokenizer;
+import net.sourceforge.pmd.cpd.Tokens;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.IMxmlFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+import com.adobe.ac.pmd.parser.KeyWords;
+import com.adobe.ac.pmd.parser.Operators;
+
+import de.bokelberg.flex.parser.AS3Parser;
+import de.bokelberg.flex.parser.AS3Scanner;
+import de.bokelberg.flex.parser.AS3Scanner.Token;
+
+public class FlexTokenizer implements Tokenizer
+{
+   public static final int            DEFAULT_MINIMUM_TOKENS = 25;
+   private static final Set< String > IGNORED_TOKENS;
+   private static final Set< String > IGNORING_LINE_TOKENS;
+
+   static
+   {
+      IGNORED_TOKENS = new HashSet< String >();
+      IGNORED_TOKENS.add( Operators.SEMI_COLUMN.toString() );
+      IGNORED_TOKENS.add( Operators.LEFT_CURLY_BRACKET.toString() );
+      IGNORED_TOKENS.add( Operators.RIGHT_CURLY_BRACKET.toString() );
+      IGNORED_TOKENS.add( AS3Parser.NEW_LINE );
+      IGNORING_LINE_TOKENS = new HashSet< String >();
+      IGNORING_LINE_TOKENS.add( KeyWords.IMPORT.toString() );
+      IGNORING_LINE_TOKENS.add( KeyWords.PACKAGE.toString() );
+   }
+
+   private static boolean isTokenIgnored( final String tokenText )
+   {
+      return IGNORED_TOKENS.contains( tokenText )
+            || tokenText.startsWith( AS3Parser.MULTIPLE_LINES_COMMENT )
+            || tokenText.startsWith( AS3Parser.SINGLE_LINE_COMMENT );
+   }
+
+   private static boolean isTokenIgnoringLine( final String tokenText )
+   {
+      return IGNORING_LINE_TOKENS.contains( tokenText );
+   }
+
+   public void tokenize( final SourceCode tokens,
+                         final Tokens tokenEntries )
+   {
+      try
+      {
+         final AS3Scanner scanner = initializeScanner( tokens );
+         Token currentToken = scanner.moveToNextToken();
+         int inImportLine = 0;
+
+         while ( currentToken != null
+               && currentToken.getText().compareTo( KeyWords.EOF.toString() ) != 0 )
+         {
+            final String currentTokenText = currentToken.getText();
+            final int currentTokenLine = currentToken.getLine();
+
+            if ( !isTokenIgnored( currentTokenText ) )
+            {
+               if ( isTokenIgnoringLine( currentTokenText ) )
+               {
+                  inImportLine = currentTokenLine;
+               }
+               else
+               {
+                  if ( inImportLine == 0
+                        || inImportLine != currentTokenLine )
+                  {
+                     inImportLine = 0;
+                     tokenEntries.add( new TokenEntry( currentTokenText, // NOPMD
+                                                       tokens.getFileName(),
+                                                       currentTokenLine ) );
+                  }
+               }
+            }
+            currentToken = scanner.moveToNextToken();
+         }
+      }
+      catch ( final Exception e )
+      {
+      }
+      finally
+      {
+         tokenEntries.add( TokenEntry.getEOF() );
+      }
+   }
+
+   private AS3Scanner initializeScanner( final SourceCode tokens )
+   {
+      final AS3Scanner scanner = new AS3Scanner();
+
+      final IFlexFile flexFile = FileUtils.create( new File( tokens.getFileName() ),
+                                                   new File( "" ) );
+
+      if ( flexFile instanceof IMxmlFile )
+      {
+         final IMxmlFile mxml = ( IMxmlFile ) flexFile;
+
+         scanner.setLines( mxml.getScriptBlock() );
+      }
+      else
+      {
+         scanner.setLines( tokens.getCode().toArray( new String[ tokens.getCode().size() ] ) );
+      }
+      return scanner;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
new file mode 100644
index 0000000..09b7a75
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.cpd;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import net.sourceforge.pmd.cpd.CPD;
+import net.sourceforge.pmd.cpd.Match;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.IFlexFile;
+
+public class FlexCpdTest extends FlexPmdTestBase
+{
+   private class ExpectedMatchInformation
+   {
+      private final int lineCount;
+      private final int markCount;
+      private final int tokenCount;
+
+      public ExpectedMatchInformation( final int tokenCountToBeSet,
+                                       final int markCountToBeSet,
+                                       final int lineCountToBeSet )
+      {
+         lineCount = lineCountToBeSet;
+         tokenCount = tokenCountToBeSet;
+         markCount = markCountToBeSet;
+      }
+   }
+   final ExpectedMatchInformation[] EXPECTED = new ExpectedMatchInformation[]
+                                             { new ExpectedMatchInformation( 107, 2, 7 ),
+               new ExpectedMatchInformation( 79, 2, 17 ),
+               new ExpectedMatchInformation( 77, 2, 6 ),
+               new ExpectedMatchInformation( 76, 2, 18 ),
+               new ExpectedMatchInformation( 64, 2, 7 ),
+               new ExpectedMatchInformation( 60, 3, 14 ),
+               new ExpectedMatchInformation( 57, 2, 7 ),
+               new ExpectedMatchInformation( 54, 2, 9 ),
+               new ExpectedMatchInformation( 53, 2, 8 ),
+               new ExpectedMatchInformation( 48, 2, 18 ) };
+
+   @Test
+   public void test119() throws IOException
+   {
+      final CPD cpd = new CPD( 25, new FlexLanguage() );
+
+      cpd.add( new File( "src/test/resources/test/FlexPMD119.mxml" ) );
+      cpd.go();
+
+      final Iterator< Match > matchIterator = cpd.getMatches();
+      final Match match = matchIterator.next();
+
+      assertEquals( "The first mark is not correct",
+                    41,
+                    match.getFirstMark().getBeginLine() );
+      assertEquals( "The second mark is not correct",
+                    81,
+                    match.getSecondMark().getBeginLine() );
+   }
+
+   @Test
+   public void tokenize() throws IOException
+   {
+      final Iterator< Match > matchIterator = getMatchIterator();
+
+      for ( int currentIndex = 0; matchIterator.hasNext()
+            && currentIndex < EXPECTED.length; currentIndex++ )
+      {
+         final Match currentMatch = matchIterator.next();
+
+         assertEquals( "The token count is not correct on the "
+                             + currentIndex + "th index",
+                       EXPECTED[ currentIndex ].tokenCount,
+                       currentMatch.getTokenCount() );
+
+         assertEquals( "The mark count is not correct on the "
+                             + currentIndex + "th index",
+                       EXPECTED[ currentIndex ].markCount,
+                       currentMatch.getMarkCount() );
+
+         assertEquals( "The line count is not correct on the "
+                             + currentIndex + "th index",
+                       EXPECTED[ currentIndex ].lineCount,
+                       currentMatch.getLineCount() );
+      }
+   }
+
+   private Iterator< Match > getMatchIterator() throws IOException
+   {
+      final CPD cpd = new CPD( 25, new FlexLanguage() );
+
+      for ( final Entry< String, IFlexFile > includedFile : getTestFiles().entrySet() )
+      {
+         cpd.add( new File( includedFile.getValue().getFilePath() ) );
+      }
+      cpd.go();
+
+      return cpd.getMatches();
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
new file mode 100644
index 0000000..1519ac1
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<mx:Canvas> 
+	
+	<mx:Script>
+		<![CDATA[
+		
+		// Handle the mouseDown event generated 
+		// by clicking in the application.
+		private function handleMouseDown(event:MouseEvent):void {
+		
+		// Convert the mouse position to global coordinates.
+		// The localX and localY properties of the mouse event contain
+		// the coordinates at which the event occurred relative to the
+		// event target, typically one of the 
+		// colored internal Canvas controls.
+		// A production version of this example could use the stageX 
+		// and stageY properties, which use the global coordinates, 
+		// and avoid this step.
+		// This example uses the localX and localY properties only to
+		// illustrate conversion between different frames of reference.
+		var pt:Point = new Point(event.localX, event.localY);
+		pt = event.target.localToGlobal(pt);
+		
+		// Convert the global coordinates to the content coordinates 
+		// inside the outer c1 Canvas control.
+		pt = c1.globalToContent(pt);
+		
+		// Figure out which quadrant was clicked.
+		var whichColor:String = "border area";
+		
+		if (pt.x < 150) {
+		if (pt.y < 150)
+		whichColor = "red";
+		else
+		whichColor = "blue";
+		}
+		else {
+		if (pt.y < 150)
+		whichColor = "green";
+		else
+		whichColor = "magenta";
+		}
+		
+		Alert.show("You clicked on the " + whichColor);
+		}
+		
+		// Handle the mouseDown event generated 
+		// by clicking in the application.
+		private function handleMouseDown(event:MouseEvent):void {
+		
+		// Convert the mouse position to global coordinates.
+		// The localX and localY properties of the mouse event contain
+		// the coordinates at which the event occurred relative to the
+		// event target, typically one of the 
+		// colored internal Canvas controls.
+		// A production version of this example could use the stageX 
+		// and stageY properties, which use the global coordinates, 
+		// and avoid this step.
+		// This example uses the localX and localY properties only to
+		// illustrate conversion between different frames of reference.
+		var pt:Point = new Point(event.localX, event.localY);
+		pt = event.target.localToGlobal(pt);
+		
+		// Convert the global coordinates to the content coordinates 
+		// inside the outer c1 Canvas control.
+		pt = c1.globalToContent(pt);
+		
+		// Figure out which quadrant was clicked.
+		var whichColor:String = "border area";
+		
+		if (pt.x < 150) {
+		if (pt.y < 150)
+		whichColor = "red";
+		else
+		whichColor = "blue";
+		}
+		else {
+		if (pt.y < 150)
+		whichColor = "green";
+		else
+		whichColor = "magenta";
+		}
+		
+		Alert.show("You clicked on the " + whichColor);
+		}
+		]]>
+	</mx:Script>
+	
+</mx:Canvas>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-files/pom.xml
new file mode 100644
index 0000000..9796310
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/pom.xml
@@ -0,0 +1,84 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.flex.pmd</groupId>
+        <artifactId>flex-pmd-java</artifactId>
+        <version>1.3-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>flex-pmd-files</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Adobe Flex PMD Files</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>${commons-lang.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>as3-plugin-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>flex-pmd-test-resources</artifactId>
+            <version>${project.version}</version>
+            <classifier>resources</classifier>
+            <type>zip</type>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <testResources>
+            <testResource>
+                <directory>${project.build.directory}/test/generated-resources</directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>unpack-test-resources</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <includeGroupIds>${project.groupId}</includeGroupIds>
+                            <includes>**/*.as,**/*.mxml</includes>
+                            <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
+                            <excludeTransitive>true</excludeTransitive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java
new file mode 100644
index 0000000..c3e3b5d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/FlexPmdTestBase.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd;
+
+import java.io.File;
+import java.util.Map;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+
+/**
+ * This is a base class for any FlexPMD rule test case.
+ * 
+ * @author xagnetti
+ */
+public class FlexPmdTestBase // NO_UCD
+{
+   protected static final String    BEGIN_LINE_NOT_CORRECT        = "Begining line is not correct";     // NO_UCD
+   protected static final String    END_LINE_NOT_CORRECT          = "Ending line is not correct";       // NO_UCD
+   protected static final String    VIOLATIONS_NUMBER_NOT_CORRECT = "Violations number is not correct"; // NO_UCD
+
+   /**
+    * Test files placeholder. The key is the qualified file name
+    */
+   private Map< String, IFlexFile > testFiles                     = ResourcesManagerTest.getInstance()
+                                                                                        .getTestFiles();
+
+   /**
+    * 
+    */
+   protected FlexPmdTestBase()
+   {
+   }
+
+   /**
+    * @return
+    */
+   protected File getTestDirectory() // NO_UCD
+   {
+      return ResourcesManagerTest.getInstance().getTestRootDirectory();
+   }
+
+   /**
+    * @return
+    */
+   protected final Map< String, IFlexFile > getTestFiles() // NO_UCD
+   {
+      return testFiles;
+   }
+
+   /**
+    * @param testFilesToBeSet
+    */
+   protected final void setTestFiles( final Map< String, IFlexFile > testFilesToBeSet )
+   {
+      testFiles = testFilesToBeSet;
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java
new file mode 100644
index 0000000..5986888
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/ResourcesManagerTest.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import net.sourceforge.pmd.PMDException;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.impl.FileUtils;
+import com.adobe.ac.utils.StackTraceUtils;
+
+/**
+ * Internal utility which finds out the test resources, and map them to their
+ * qualified names.
+ * 
+ * @author xagnetti
+ */
+public final class ResourcesManagerTest
+{
+   private static ResourcesManagerTest instance = null;
+   private static final Logger         LOGGER   = Logger.getLogger( ResourcesManagerTest.class.getName() );
+
+   /**
+    * @return
+    */
+   public static synchronized ResourcesManagerTest getInstance() // NOPMD
+   {
+      if ( instance == null )
+      {
+         try
+         {
+            new LoggerUtils().loadConfiguration();
+            instance = new ResourcesManagerTest( "/test" );
+         }
+         catch ( final URISyntaxException e )
+         {
+            LOGGER.warning( StackTraceUtils.print( e ) );
+         }
+         catch ( final PMDException e )
+         {
+            LOGGER.warning( StackTraceUtils.print( e ) );
+         }
+      }
+      return instance;
+   }
+
+   private final Map< String, IFlexFile > testFiles;
+   private final File                     testRootDirectory;
+
+   private ResourcesManagerTest( final String directory ) throws URISyntaxException,
+                                                         PMDException
+   {
+      final URL resource = this.getClass().getResource( directory );
+
+      if ( resource == null )
+      {
+         LOGGER.severe( directory
+               + " folder is not found in the resource" );
+         testRootDirectory = null;
+         testFiles = new LinkedHashMap< String, IFlexFile >();
+      }
+      else
+      {
+         testRootDirectory = new File( resource.toURI().getPath() );
+         testFiles = FileUtils.computeFilesList( testRootDirectory,
+                                                 null,
+                                                 "",
+                                                 null );
+      }
+   }
+
+   /**
+    * @return
+    */
+   public Map< String, IFlexFile > getTestFiles()
+   {
+      return testFiles;
+   }
+
+   protected File getTestRootDirectory()
+   {
+      return testRootDirectory;
+   }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java
new file mode 100644
index 0000000..4997eeb
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IAs3File.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+/**
+ * @author xagnetti
+ */
+public interface IAs3File extends IFlexFile
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java
new file mode 100644
index 0000000..21adb01
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IFlexFile.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+import java.util.Set;
+
+/**
+ * @author xagnetti
+ */
+public interface IFlexFile
+{
+   /**
+    * @param stringToLookup
+    * @param linesToBeIgnored
+    * @return
+    */
+   boolean contains( final String stringToLookup,
+                     final Set< Integer > linesToBeIgnored );
+
+   /**
+    * @return
+    */
+   String getClassName();
+
+   /**
+    * @return the token for comment closing
+    */
+   String getCommentClosingTag();
+
+   /**
+    * @return the token for comment opening
+    */
+   String getCommentOpeningTag();
+
+   /**
+    * @return java.io.File name
+    */
+   String getFilename();
+
+   /**
+    * @return java.io.File absolute path
+    */
+   String getFilePath();
+
+   /**
+    * @return
+    */
+   String getFullyQualifiedName();
+
+   /**
+    * @param lineIndex
+    * @return
+    */
+   String getLineAt( int lineIndex );
+
+   /**
+    * @return
+    */
+   int getLinesNb();
+
+   /**
+    * @return
+    */
+   String getPackageName();
+
+   /**
+    * @return the token for one line comment
+    */
+   String getSingleLineComment();
+
+   /**
+    * @return true if the file is a main MXML file
+    */
+   boolean isMainApplication();
+
+   /**
+    * @return true if the file is a MXML file
+    */
+   boolean isMxml();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java
new file mode 100644
index 0000000..1d98c98
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/IMxmlFile.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+/**
+ * @author xagnetti
+ */
+public interface IMxmlFile extends IFlexFile
+{
+   /**
+    * @return
+    */
+   String[] getActualScriptBlock();
+
+   /**
+    * @return
+    */
+   int getBeginningScriptBlock();
+
+   /**
+    * @return
+    */
+   int getEndingScriptBlock();
+
+   /**
+    * @return
+    */
+   String[] getScriptBlock();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java
new file mode 100644
index 0000000..986f2a7
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/AbstractFlexFile.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.utils.StackTraceUtils;
+
+/**
+ * Abstract class representing a Flex File (either MXML or AS)
+ * 
+ * @author xagnetti
+ */
+abstract class AbstractFlexFile implements IFlexFile
+{
+   private static final Logger LOGGER = Logger.getLogger( AbstractFlexFile.class.getName() );
+
+   /**
+    * @param filePath
+    * @param rootPath
+    * @param className
+    * @param fileSeparator
+    * @return
+    */
+   protected static String computePackageName( final String filePath,
+                                               final CharSequence rootPath,
+                                               final String className,
+                                               final String fileSeparator )
+   {
+      String temporaryPackage;
+
+      temporaryPackage = filePath.replace( className,
+                                           "" ).replace( rootPath,
+                                                         "" ).replace( fileSeparator,
+                                                                       "." );
+      if ( temporaryPackage.endsWith( "." ) )
+      {
+         temporaryPackage = temporaryPackage.substring( 0,
+                                                        temporaryPackage.length() - 1 );
+      }
+      if ( temporaryPackage.length() > 0
+            && temporaryPackage.charAt( 0 ) == '.' )
+      {
+         temporaryPackage = temporaryPackage.substring( 1,
+                                                        temporaryPackage.length() );
+      }
+      return temporaryPackage;
+   }
+
+   private static boolean doesCurrentLineContain( final String line,
+                                                  final String search )
+   {
+      return line.contains( search );
+   }
+
+   private final String         className;
+   private final File           file;
+   private final List< String > lines;
+   private final String         packageName;
+
+   /**
+    * @param underlyingFile
+    * @param rootDirectory
+    */
+   protected AbstractFlexFile( final File underlyingFile,
+                               final File rootDirectory )
+   {
+      final String filePath = underlyingFile.getPath();
+      final CharSequence rootPath = rootDirectory == null ? ""
+                                                         : rootDirectory.getPath();
+
+      file = underlyingFile;
+      className = underlyingFile.getName();
+      packageName = computePackageName( filePath,
+                                        rootPath,
+                                        className,
+                                        System.getProperty( "file.separator" ) );
+      lines = new ArrayList< String >();
+      try
+      {
+         String[] linesArray;
+         linesArray = FileUtils.readLines( underlyingFile );
+         for ( final String string : linesArray )
+         {
+            lines.add( string );
+         }
+      }
+      catch ( final IOException e )
+      {
+         LOGGER.warning( StackTraceUtils.print( e ) );
+      }
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#contains(java.lang.String, int)
+    */
+   public final boolean contains( final String stringToLookup,
+                                  final Set< Integer > linesToBeIgnored )
+   {
+      int lineIndex = 1;
+      boolean found = false;
+
+      for ( final String line : lines )
+      {
+         if ( doesCurrentLineContain( line,
+                                      stringToLookup )
+               && !linesToBeIgnored.contains( lineIndex ) )
+         {
+            found = true;
+            break;
+         }
+         lineIndex++;
+      }
+      return found;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public final boolean equals( final Object obj )
+   {
+      return obj != null
+            && obj instanceof AbstractFlexFile && hashCode() == ( ( AbstractFlexFile ) obj ).hashCode();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getClassName()
+    */
+   public final String getClassName()
+   {
+      return className;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getCommentClosingTag()
+    */
+   public abstract String getCommentClosingTag();
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getCommentOpeningTag()
+    */
+   public abstract String getCommentOpeningTag();
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getFilename()
+    */
+   public final String getFilename()
+   {
+      return file.getName();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getFilePath()
+    */
+   public final String getFilePath()
+   {
+      return file.toURI().getPath();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getFullyQualifiedName()
+    */
+   public final String getFullyQualifiedName()
+   {
+      return ( StringUtils.isEmpty( packageName ) ? ""
+                                                 : packageName
+                                                       + "." )
+            + className;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getLineAt(int)
+    */
+   public String getLineAt( final int lineIndex )
+   {
+      return lines.get( lineIndex - 1 );
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getLines()
+    */
+   public final List< String > getLines()
+   {
+      return lines;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getLinesNb()
+    */
+   public int getLinesNb()
+   {
+      return lines.size();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getPackageName()
+    */
+   public final String getPackageName()
+   {
+      return packageName;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      return getFilePath().hashCode();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#isMainApplication()
+    */
+   public abstract boolean isMainApplication();
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#isMxml()
+    */
+   public abstract boolean isMxml();
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java
new file mode 100644
index 0000000..d4a3c93
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-files/src/main/java/com/adobe/ac/pmd/files/impl/As3File.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files.impl;
+
+import java.io.File;
+
+import com.adobe.ac.pmd.files.IAs3File;
+
+/**
+ * @author xagnetti
+ */
+class As3File extends AbstractFlexFile implements IAs3File
+{
+   /**
+    * @param file
+    * @param rootDirectory
+    */
+   protected As3File( final File file,
+                      final File rootDirectory )
+   {
+      super( file, rootDirectory );
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#getCommentClosingTag()
+    */
+   @Override
+   public final String getCommentClosingTag()
+   {
+      return "*/";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#getCommentOpeningTag()
+    */
+   @Override
+   public final String getCommentOpeningTag()
+   {
+      return "/*";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.IFlexFile#getSingleLineComment()
+    */
+   public String getSingleLineComment()
+   {
+      return "//";
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#isMainApplication()
+    */
+   @Override
+   public final boolean isMainApplication()
+   {
+      return false;
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see com.adobe.ac.pmd.files.impl.AbstractFlexFile#isMxml()
+    */
+   @Override
+   public final boolean isMxml()
+   {
+      return false;
+   }
+}