http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/EmptyTestFunctionStatus.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/EmptyTestFunctionStatus.as b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/EmptyTestFunctionStatus.as new file mode 100644 index 0000000..68bd07e --- /dev/null +++ b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/EmptyTestFunctionStatus.as @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 flexunit.flexui.data.filter +{ + import flexunit.flexui.controls.FlexUnitLabels; + import flexunit.flexui.data.TestFunctionRowData; + + public class EmptyTestFunctionStatus implements ITestFunctionStatus + { + public function isTestFunctionVisible( test : TestFunctionRowData ) : Boolean + { + return test.assertionsMade == 0; + } + + public function get label() : String + { + return FlexUnitLabels.EMPTY; + } + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ErrorTestFunctionStatus.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ErrorTestFunctionStatus.as b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ErrorTestFunctionStatus.as new file mode 100644 index 0000000..4bacad6 --- /dev/null +++ b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ErrorTestFunctionStatus.as @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 flexunit.flexui.data.filter +{ + import flexunit.flexui.controls.FlexUnitLabels; + import flexunit.flexui.data.TestFunctionRowData; + + public class ErrorTestFunctionStatus implements ITestFunctionStatus + { + public function isTestFunctionVisible( test : TestFunctionRowData ) : Boolean + { + return ! test.testSuccessful; + } + + public function get label() : String + { + return FlexUnitLabels.FAILURES_AND_ERRORS; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ITestFunctionStatus.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ITestFunctionStatus.as b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ITestFunctionStatus.as new file mode 100644 index 0000000..a5d4256 --- /dev/null +++ b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/ITestFunctionStatus.as @@ -0,0 +1,28 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 flexunit.flexui.data.filter +{ + import flexunit.flexui.data.TestFunctionRowData; + + public interface ITestFunctionStatus + { + function isTestFunctionVisible( test : TestFunctionRowData ) : Boolean; + function get label() : String; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/TestfFunctionStatuses.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/TestfFunctionStatuses.as b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/TestfFunctionStatuses.as new file mode 100644 index 0000000..7a37483 --- /dev/null +++ b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/flexunit/filter/TestfFunctionStatuses.as @@ -0,0 +1,32 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 flexunit.flexui.data.filter +{ + public class TestfFunctionStatuses + { + public static const ALL : ITestFunctionStatus = new AllTestFunctionStatus(); + public static const EMPTY : ITestFunctionStatus = new EmptyTestFunctionStatus(); + public static const ERRORS_AND_FAILURES : ITestFunctionStatus = new ErrorTestFunctionStatus(); + + public static function toArray() : Array + { + return [ ALL, EMPTY, ERRORS_AND_FAILURES ]; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationView.mxml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationView.mxml b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationView.mxml new file mode 100644 index 0000000..04a064c --- /dev/null +++ b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationView.mxml @@ -0,0 +1,105 @@ +<?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:Panel + xmlns:mx="http://www.adobe.com/2006/mxml" + xmlns:ns1="com.adobe.ac.anthology.view.iteration.*" + xmlns:component="com.adobe.ac.anthology.utils.components.*" + title="MyIterations" + horizontalAlign="left" + visible="{ model.selectedRelease != null }"> + + <mx:Script> + <![CDATA[ + import com.adobe.ac.anthology.model.object.Iteration; + import com.adobe.ac.anthology.model.AnthologyModelLocator; + import com.adobe.ac.anthology.model.ProjectModel; + import com.adobe.cairngorm.business.ServiceLocator; + import com.adobe.ac.anthology.control.event.iteration.*; + import com.adobe.ac.anthology.utils.FormTools; + + [Bindable] + private var model : ProjectModel = AnthologyModelLocator.instance.projectModel; + + private function addIteration() : void + { + model.selectedRelease.addIteration( new Iteration() ); + } + + private function changeIteration() : void + { + model.selectedIteration = dg.selectedItem as Iteration; + } + + ]]> + </mx:Script> + <mx:HBox height="320"> + + <ns1:DetailedIterationWithControl + id="detailedIterationForm" + iteration="{ model.selectedIteration }" /> + + <mx:VRule + height="100%" + strokeColor="#DDDDDD"/> + + <mx:VBox + paddingTop="15" + paddingLeft="15" + paddingRight="15" + paddingBottom="15"> + + <mx:Text text="List of Iterations"/> + + <component:ScrawlGrid + id="dg" + dataProvider="{ model.selectedRelease.iterations }" + width="200" height="220" + change="changeIteration()"> + + <component:columns> + + <mx:DataGridColumn + dataField="iterationNumber" + headerText="#"/> + + <mx:DataGridColumn + dataField="startDate" + headerText="Start Date" + editable="false"/> + + <mx:DataGridColumn + dataField="endDate" + headerText="End Date"/> + + </component:columns> + + </component:ScrawlGrid> + + <mx:HBox width="200"> + + <mx:Button label="Add Iteration" + click="addIteration()"/> + + </mx:HBox> + + </mx:VBox> + + </mx:HBox> +</mx:Panel> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationsList.mxml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationsList.mxml b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationsList.mxml new file mode 100644 index 0000000..7718eb2 --- /dev/null +++ b/FlexPMD/flex-pmd-java/as3-plugin-utils/src/test/resources/com/adobe/ac/ncss/mxml/IterationsList.mxml @@ -0,0 +1,61 @@ +<?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. + +--> +<component:ScrawlGrid xmlns:mx="http://www.adobe.com/2006/mxml" + xmlns:component="com.adobe.ac.anthology.utils.components.*"> + <!-- + lalala + --> + <mx:Script> + <![CDATA[ + import com.adobe.ac.anthology.model.object.Iteration; + + import mx.collections.ArrayCollection; + + + private var _selectedIteration : Iteration; + + public function set selectedIteration(value : Iteration) : void + { + for (var i : uint = 0; i < (dataProvider as ArrayCollection).length; i++) { + var currentId : uint = dataProvider[i].id; + if (currentId == value.id) { + selectedItem = dataProvider[i]; + return; + } + } + } + + private function displayTitle(item : Object, column : DataGridColumn) : String + { + var i : Iteration = Iteration( item ); + + return "#" + i.iterationNumber.toString() + " " + i.status; + } + + ]]> + </mx:Script> + + <component:columns> + + <mx:DataGridColumn dataField="iterationNumber" headerText="Iterations" labelFunction="displayTitle"/> + + </component:columns> + +</component:ScrawlGrid> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ant-task/.pmd ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ant-task/.pmd b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/.pmd new file mode 100644 index 0000000..b5c19d9 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/.pmd @@ -0,0 +1,25 @@ +<?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. + +--> +<pmd> + <useProjectRuleSet>false</useProjectRuleSet> + <ruleSetFile>../flex-pmd-parent/pmd.xml</ruleSetFile> + <includeDerivedFiles>false</includeDerivedFiles> + <violationsAsErrors>true</violationsAsErrors> +</pmd> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ant-task/pom.xml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ant-task/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/pom.xml new file mode 100644 index 0000000..fb11720 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/pom.xml @@ -0,0 +1,190 @@ +<?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-ant-task</artifactId> + <packaging>jar</packaging> + + <name>Adobe Flex PMD Ant task</name> + + <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> + <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 PMD 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-core:jar}" + todir="${project.build.directory}/release" overwrite="true"/> + <copy file="${org.apache.flex.pmd:flex-pmd-ruleset: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:flex-pmd-ruleset-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:as3-parser-api:jar}" + todir="${project.build.directory}/release" overwrite="true"/> + <echo message="Copying Ant dependencies..."/> + <copy file="${org.apache.flex.pmd:as3-plugin-utils:jar}" + todir="${project.build.directory}/release" overwrite="true"/> + <copy file="${pmd:pmd:jar}" + todir="${project.build.directory}/release" overwrite="true"/> + <copy file="${org.apache.ant:ant:jar}" + todir="${project.build.directory}/release" overwrite="true"/> + <copy file="${commons-lang:commons-lang:jar}" + todir="${project.build.directory}/release" overwrite="true"/> + <copy file="${plexus:plexus-utils: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> + + + <dependencies> + <dependency> + <groupId>org.apache.flex.pmd</groupId> + <artifactId>flex-pmd-core</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant</artifactId> + <version>${ant.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 for packaging from ANT --> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>flex-pmd-ruleset</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>flex-pmd-ruleset-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>flex-pmd-files</artifactId> + <version>${project.version}</version> + </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>pmd</groupId> + <artifactId>pmd</artifactId> + <version>${pmd.version}</version> + </dependency> + <dependency> + <groupId>plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>${plexus-utils.version}</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>${commons-lang.version}</version> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/assemble/bin.xml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/assemble/bin.xml b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/assemble/bin.xml new file mode 100644 index 0000000..134549d --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/assemble/bin.xml @@ -0,0 +1,38 @@ +<!-- + +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. + +--> +<assembly> + <id>ant</id> + <formats> + <format>jar</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <dependencySets> + <dependencySet> + <includes> + <include>com.adobe.ac:flex-pmd-core</include> + <include>org.apache.ant:ant</include> + <include>com.adobe.ac:as3-parser</include> + <include>com.adobe.ac:as3-plugin-utils</include> + <include>com.adobe.ac:flex-pmd-ruleset</include> + <include>com.adobe.ac:flex-pmd-ruleset-api</include> + <include>pmd:pmd</include> + </includes> + </dependencySet> + </dependencySets> +</assembly> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/java/com/adobe/ac/pmd/ant/FlexPmdAntTask.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/java/com/adobe/ac/pmd/ant/FlexPmdAntTask.java b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/java/com/adobe/ac/pmd/ant/FlexPmdAntTask.java new file mode 100644 index 0000000..40e7167 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/main/java/com/adobe/ac/pmd/ant/FlexPmdAntTask.java @@ -0,0 +1,119 @@ +/* + * 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.ant; + +import java.io.File; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; + +import com.adobe.ac.pmd.FlexPmdParameters; +import com.adobe.ac.pmd.FlexPmdViolations; +import com.adobe.ac.pmd.LoggerUtils; +import com.adobe.ac.pmd.engines.FlexPmdXmlEngine; +import com.adobe.ac.pmd.engines.PmdEngineUtils; + +public class FlexPmdAntTask extends Task // NO_UCD +{ + private boolean failOnError; + private boolean failOnRuleViolation; + private File outputDirectory; + private String packageToExclude; + private File ruleSet; + private File sourceDirectory; + + @Override + public final void execute() + { + try + { + presetParameters(); + + new LoggerUtils().loadConfiguration(); + + final FlexPmdXmlEngine engine = new FlexPmdXmlEngine( new FlexPmdParameters( packageToExclude, + outputDirectory, + ruleSet, + sourceDirectory ) ); + final FlexPmdViolations violations = new FlexPmdViolations(); + + engine.executeReport( violations ); + + if ( failOnError ) + { + final String message = PmdEngineUtils.findFirstViolationError( violations ); + + if ( message.length() > 0 ) + { + throw new BuildException( message ); + } + } + if ( failOnRuleViolation + && !violations.getViolations().isEmpty() ) + { + throw new BuildException( "At least one violation has been found" ); + } + } + catch ( final Exception e ) + { + throw new BuildException( e ); + } + } + + public final String getPackageToExclude() + { + return packageToExclude; + } + + public final void setFailOnError( final boolean failOnErrorToBeSet ) + { + failOnError = failOnErrorToBeSet; + } + + public final void setFailOnRuleViolation( final boolean failOnRuleViolation ) + { + this.failOnRuleViolation = failOnRuleViolation; + } + + public final void setOutputDirectory( final File outputDirectoryToBeSet ) + { + outputDirectory = outputDirectoryToBeSet; + } + + public final void setPackageToExclude( final String packageToExcludeToBeSet ) + { + packageToExclude = packageToExcludeToBeSet; + } + + public final void setRuleSet( final File ruleSetToBeSet ) + { + ruleSet = ruleSetToBeSet; + } + + public final void setSourceDirectory( final File sourceDirectoryToBeSet ) + { + sourceDirectory = sourceDirectoryToBeSet; + } + + private void presetParameters() + { + if ( packageToExclude == null ) + { + packageToExclude = ""; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/test/java/com/adobe/ac/pmd/ant/FlexPmdAntTaskTest.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/test/java/com/adobe/ac/pmd/ant/FlexPmdAntTaskTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/test/java/com/adobe/ac/pmd/ant/FlexPmdAntTaskTest.java new file mode 100644 index 0000000..256e871 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-ant-task/src/test/java/com/adobe/ac/pmd/ant/FlexPmdAntTaskTest.java @@ -0,0 +1,82 @@ +/* + * 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.ant; + +import java.io.File; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.junit.Test; + +import com.adobe.ac.pmd.FlexPmdTestBase; + +public class FlexPmdAntTaskTest extends FlexPmdTestBase +{ + private static final String TARGET = "target"; + + @Test(expected = BuildException.class) + public void testExecuteWithFailOnError() + { + final FlexPmdAntTask task = new FlexPmdAntTask(); + final Project project = new Project(); + + task.setFailOnError( true ); + task.setSourceDirectory( getTestDirectory() ); + task.setOutputDirectory( new File( TARGET ) ); + task.setProject( project ); + task.execute(); + } + + @Test(expected = BuildException.class) + public void testExecuteWithFailOnViolation() + { + final FlexPmdAntTask task = new FlexPmdAntTask(); + final Project project = new Project(); + + task.setFailOnRuleViolation( true ); + task.setPackageToExclude( "" ); + task.setRuleSet( null ); + task.setSourceDirectory( getTestDirectory() ); + task.setOutputDirectory( new File( TARGET ) ); + task.setProject( project ); + task.execute(); + } + + @Test(expected = BuildException.class) + public void testExecuteWithoutSettingParameters() + { + final FlexPmdAntTask task = new FlexPmdAntTask(); + final Project project = new Project(); + + task.setProject( project ); + task.execute(); + } + + @Test + public void testExecuteWithParameters() + { + final FlexPmdAntTask task = new FlexPmdAntTask(); + final Project project = new Project(); + + task.setSourceDirectory( getTestDirectory() ); + task.setOutputDirectory( new File( TARGET ) ); + task.setProject( project ); + task.execute(); + new File( TARGET + + "/pmd.xml" ).delete(); + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/.pmd ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/.pmd b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/.pmd new file mode 100644 index 0000000..b5c19d9 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/.pmd @@ -0,0 +1,25 @@ +<?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. + +--> +<pmd> + <useProjectRuleSet>false</useProjectRuleSet> + <ruleSetFile>../flex-pmd-parent/pmd.xml</ruleSetFile> + <includeDerivedFiles>false</includeDerivedFiles> + <violationsAsErrors>true</violationsAsErrors> +</pmd> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/pom.xml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/pom.xml new file mode 100644 index 0000000..dcaad29 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/pom.xml @@ -0,0 +1,41 @@ +<!-- + +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-command-line-api</artifactId> + <packaging>jar</packaging> + + <name>Adobe Flex PMD Command line API</name> + + <dependencies> + <dependency> + <groupId>com.martiansoftware</groupId> + <artifactId>jsap</artifactId> + <version>${jsap.version}</version> + </dependency> + </dependencies> + +</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-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineOptions.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineOptions.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineOptions.java new file mode 100644 index 0000000..e8aa66e --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineOptions.java @@ -0,0 +1,39 @@ +/* + * 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; + +public enum CommandLineOptions implements ICommandLineOptions +{ + EXLUDE_PACKAGE("excludePackage"), + MXML_FACTOR("mxmlFactor"), + OUTPUT("outputDirectory"), + RULE_SET("ruleSet"), + SOURCE_DIRECTORY("sourceDirectory"); + + private String name; + + private CommandLineOptions( 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-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineUtils.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineUtils.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineUtils.java new file mode 100644 index 0000000..ba212a4 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/CommandLineUtils.java @@ -0,0 +1,58 @@ +/* + * 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.ArrayList; +import java.util.List; + +import com.martiansoftware.jsap.FlaggedOption; +import com.martiansoftware.jsap.JSAP; +import com.martiansoftware.jsap.JSAPException; + +public final class CommandLineUtils +{ + public static List< File > computeSourceList( final String source ) + { + if ( !source.contains( "," ) ) + { + return null; + } + final List< File > sourceList = new ArrayList< File >(); + for ( int i = 0; i < source.split( "," ).length; i++ ) + { + sourceList.add( new File( source.split( "," )[ i ] ) ); // NOPMD + } + return sourceList; + } + + public static void registerParameter( final JSAP jsap, + final ICommandLineOptions option, + final boolean required ) throws JSAPException + { + final String optionName = option.toString(); + + jsap.registerParameter( new FlaggedOption( optionName ).setStringParser( JSAP.STRING_PARSER ) + .setRequired( required ) + .setShortFlag( optionName.charAt( 0 ) ) + .setLongFlag( optionName ) ); + } + + private CommandLineUtils() + { + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/ICommandLineOptions.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/ICommandLineOptions.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/ICommandLineOptions.java new file mode 100644 index 0000000..8d0e250 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/main/java/com/adobe/ac/pmd/ICommandLineOptions.java @@ -0,0 +1,22 @@ +/* + * 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; + +public interface ICommandLineOptions +{ + +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineOptionsTest.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineOptionsTest.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineOptionsTest.java new file mode 100644 index 0000000..9ced093 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineOptionsTest.java @@ -0,0 +1,31 @@ +/* + * 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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CommandLineOptionsTest +{ + @Test + public void testToString() + { + assertEquals( "outputDirectory", + CommandLineOptions.OUTPUT.toString() ); + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java new file mode 100644 index 0000000..305315c --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java @@ -0,0 +1,58 @@ +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.martiansoftware.jsap.JSAP; +import com.martiansoftware.jsap.JSAPException; + +public class CommandLineUtilsTest +{ + @Test + public void testComputeSourceList() + { + assertEquals( 3, + CommandLineUtils.computeSourceList( "lala,toto,tyty" ).size() ); + assertNull( CommandLineUtils.computeSourceList( "lala" ) ); + } + + @Test + public void testRegisterParameter() throws JSAPException + { + final JSAP jsap = new JSAP(); + + CommandLineUtils.registerParameter( jsap, + new ICommandLineOptions() + { + @Override + public String toString() + { + return "name"; + } + }, + true ); + + assertTrue( jsap.getByShortFlag( 'n' ) != null ); + assertNull( jsap.getByShortFlag( 'm' ) ); + } + +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line/.pmd ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line/.pmd b/FlexPMD/flex-pmd-java/flex-pmd-command-line/.pmd new file mode 100644 index 0000000..b5c19d9 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line/.pmd @@ -0,0 +1,25 @@ +<?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. + +--> +<pmd> + <useProjectRuleSet>false</useProjectRuleSet> + <ruleSetFile>../flex-pmd-parent/pmd.xml</ruleSetFile> + <includeDerivedFiles>false</includeDerivedFiles> + <violationsAsErrors>true</violationsAsErrors> +</pmd> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line/pom.xml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-command-line/pom.xml new file mode 100644 index 0000000..5f425fa --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line/pom.xml @@ -0,0 +1,196 @@ +<?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-command-line</artifactId> + <packaging>jar</packaging> + + <name>Adobe Flex PMD 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> + <artifactId>flex-pmd-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>flex-pmd-ruleset</artifactId> + <version>${project.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 for packaging from ANT --> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>flex-pmd-files</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>flex-pmd-ruleset-api</artifactId> + <version>${project.version}</version> + </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>pmd</groupId> + <artifactId>pmd</artifactId> + <version>${pmd.version}</version> + </dependency> + <dependency> + <groupId>plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>${plexus-utils.version}</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>${commons-lang.version}</version> + </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.pmd.commandline.FlexPMD</mainClass> + <packageName>com.adobe.ac.pmd.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 PMD 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:flex-pmd-core:jar}" todir="${project.build.directory}/release" overwrite="true" /--> + <copy file="${org.apache.flex.pmd:flex-pmd-ruleset: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:flex-pmd-ruleset-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" /> + <echo message="Copying Command line dependencies..." /> + <copy file="${org.apache.flex.pmd:as3-plugin-utils:jar}" todir="${project.build.directory}/release" overwrite="true" /> + <copy file="${pmd:pmd:jar}" todir="${project.build.directory}/release" overwrite="true" /> + <copy file="${plexus:plexus-utils: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-command-line/src/main/assemble/bin.xml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/assemble/bin.xml b/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/assemble/bin.xml new file mode 100644 index 0000000..3f5dd15 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/assemble/bin.xml @@ -0,0 +1,41 @@ +<!-- + +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. + +--> +<assembly> + <id>command-line</id> + <formats> + <format>jar</format> + </formats> + <fileSets> + <fileSet> + + </fileSet> + </fileSets> + <dependencySets> + <dependencySet> + <includes> + <include>com.adobe.ac:flex-pmd-core</include> + <include>com.adobe.ac:as3-parser</include> + <include>com.adobe.ac:as3-plugin-utils</include> + <include>com.adobe.ac:flex-pmd-ruleset</include> + <include>com.adobe.ac:flex-pmd-ruleset-api</include> + <include>com.martiansoftware:jsap</include> + </includes> + </dependencySet> + </dependencySets> +</assembly> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java new file mode 100644 index 0000000..4b293fa --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java @@ -0,0 +1,134 @@ +/* + * 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.commandline; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.sourceforge.pmd.PMDException; + +import com.adobe.ac.pmd.CommandLineOptions; +import com.adobe.ac.pmd.CommandLineUtils; +import com.adobe.ac.pmd.FlexPmdParameters; +import com.adobe.ac.pmd.FlexPmdViolations; +import com.adobe.ac.pmd.LoggerUtils; +import com.adobe.ac.pmd.engines.FlexPmdXmlEngine; +import com.martiansoftware.jsap.JSAP; +import com.martiansoftware.jsap.JSAPException; +import com.martiansoftware.jsap.JSAPResult; + +public final class FlexPMD // NO_UCD +{ + private static JSAPResult config; + private static final Logger LOGGER = Logger.getLogger( FlexPMD.class.getName() ); + + /** + * @param args + * @throws JSAPException + * @throws PMDException + * @throws URISyntaxException + * @throws IOException + * @throws Exception + */ + public static void main( final String[] args ) throws JSAPException, + PMDException, + URISyntaxException, + IOException + { + new LoggerUtils().loadConfiguration(); + startFlexPMD( args ); + LOGGER.info( "FlexPMD 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 " + + FlexPMD.class.getName() + " " + jsap.getUsage() ); + } + + return config.success(); + } + + static String getParameterValue( final CommandLineOptions option ) + { + return config.getString( option.toString() ); + } + + static boolean startFlexPMD( final String[] args ) throws JSAPException, + PMDException, + URISyntaxException, + IOException + { + if ( areCommandLineOptionsCorrect( args ) ) + { + final String rulesetRef = getParameterValue( CommandLineOptions.RULE_SET ); + final String excludePackage = getParameterValue( CommandLineOptions.EXLUDE_PACKAGE ); + 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( CommandLineOptions.OUTPUT ) ); + final FlexPmdParameters parameters = new FlexPmdParameters( excludePackage == null ? "" + : excludePackage, + outputDirectory, + rulesetRef == null ? null + : new File( rulesetRef ), + sourceDirectory, + sourceList ); + final FlexPmdXmlEngine engine = new FlexPmdXmlEngine( parameters ); + + engine.executeReport( new FlexPmdViolations() ); + } + + return config.success(); + } + + private static JSAPResult parseCommandLineArguments( final String[] args, + final JSAP jsap ) throws JSAPException + { + CommandLineUtils.registerParameter( jsap, + CommandLineOptions.SOURCE_DIRECTORY, + true ); + CommandLineUtils.registerParameter( jsap, + CommandLineOptions.OUTPUT, + true ); + CommandLineUtils.registerParameter( jsap, + CommandLineOptions.RULE_SET, + false ); + CommandLineUtils.registerParameter( jsap, + CommandLineOptions.EXLUDE_PACKAGE, + false ); + + return jsap.parse( args ); + } + + private FlexPMD() + { + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java b/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java new file mode 100644 index 0000000..764b118 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java @@ -0,0 +1,187 @@ +/* + * 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.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 junit.framework.Assert; +import net.sourceforge.pmd.PMDException; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.io.SAXReader; +import org.junit.Test; + +import com.adobe.ac.pmd.CommandLineOptions; +import com.adobe.ac.pmd.FlexPmdTestBase; +import com.martiansoftware.jsap.JSAPException; + +public class FlexPMDTest extends FlexPmdTestBase +{ + @Test + public void testAreCommandLineOptionsCorrect() throws FileNotFoundException, + JSAPException, + PMDException, + URISyntaxException + { + assertFalse( FlexPMD.areCommandLineOptionsCorrect( new String[] + {} ) ); + + assertFalse( FlexPMD.areCommandLineOptionsCorrect( new String[] + { "-y", + "sourceDirectory", + "-p", + "outPutDirectory" } ) ); + + assertTrue( FlexPMD.areCommandLineOptionsCorrect( new String[] + { "-s", + "sourceDirectory", + "-o", + "target", + "-r", + "valid.xml" } ) ); + + assertTrue( FlexPMD.areCommandLineOptionsCorrect( new String[] + { "-s", + "sourceDirectory", + "-o", + "target" } ) ); + } + + @Test + public void testFlexPMD114() throws JSAPException, + PMDException, + URISyntaxException, + IOException, + DocumentException + { + final String[] args = new String[] + { "-s", + getTestDirectory().getAbsolutePath() + + File.separatorChar + "flexpmd114", + "-o", + new File( "target/test2" ).getAbsolutePath() }; + + FlexPMD.startFlexPMD( args ); + + assertEquals( 3, + loadDocument( new File( "target/test2/pmd.xml" ) ).selectNodes( "//pmd/file" ).size() ); + } + + @Test + public void testFlexPMD88() throws JSAPException, + PMDException, + URISyntaxException, + IOException, + DocumentException + { + final String[] args = new String[] + { "-s", + getTestDirectory().getAbsolutePath() + + File.separatorChar + "bug" + File.separatorChar + "FlexPMD88.as", + "-o", + new File( "target/test3" ).getAbsolutePath() }; + + FlexPMD.startFlexPMD( args ); + + Assert.assertTrue( loadDocument( new File( "target/test3/pmd.xml" ) ).selectNodes( "//pmd/file[1]/violation" ) + .size() > 0 ); + } + + @Test + public void testGetCommandLineValue() throws JSAPException + { + FlexPMD.areCommandLineOptionsCorrect( new String[] + { "-s", + "sourceDirectory", + "-o", + "target", + "-r", + "valid.xml" } ); + + assertEquals( "sourceDirectory", + FlexPMD.getParameterValue( CommandLineOptions.SOURCE_DIRECTORY ) ); + assertEquals( "target", + FlexPMD.getParameterValue( CommandLineOptions.OUTPUT ) ); + assertEquals( "valid.xml", + FlexPMD.getParameterValue( CommandLineOptions.RULE_SET ) ); + } + + @Test + public void testStartFlexPMD() throws JSAPException, + PMDException, + URISyntaxException, + IOException + { + final String[] args = new String[] + { "-s", + getTestDirectory().getAbsolutePath(), + "-o", + new File( "target/test" ).getAbsolutePath(), + "--excludePackage", + "cairngorm." }; + + FlexPMD.startFlexPMD( args ); + } + + @Test + public void testStartFlexPMDOnAFile() throws JSAPException, + PMDException, + URISyntaxException, + IOException + { + final String filePath = getTestFiles().get( "AbstractRowData.as" ).getFilePath(); + + final String[] args = new String[] + { "-s", + filePath, + "-o", + new File( "target/test" ).getAbsolutePath(), + "--excludePackage", + "cairngorm." }; + + FlexPMD.startFlexPMD( args ); + } + + @Test + public void testStartFlexPMDOnSeveralFolders() throws JSAPException, + PMDException, + URISyntaxException, + IOException + { + final String[] args = new String[] + { "-s", + new File( "target/test/bug" ).getAbsolutePath() + + "," + new File( "target/test/cairngorm" ).getAbsolutePath(), + "-o", + new File( "target/test" ).getAbsolutePath(), }; + + FlexPMD.startFlexPMD( args ); + } + + private Document loadDocument( final File outputFile ) throws DocumentException + { + return new SAXReader().read( outputFile ); + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-core/.p4ignore ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-core/.p4ignore b/FlexPMD/flex-pmd-java/flex-pmd-core/.p4ignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-core/.p4ignore @@ -0,0 +1 @@ +target http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-core/.pmd ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-core/.pmd b/FlexPMD/flex-pmd-java/flex-pmd-core/.pmd new file mode 100644 index 0000000..b5c19d9 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-core/.pmd @@ -0,0 +1,25 @@ +<?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. + +--> +<pmd> + <useProjectRuleSet>false</useProjectRuleSet> + <ruleSetFile>../flex-pmd-parent/pmd.xml</ruleSetFile> + <includeDerivedFiles>false</includeDerivedFiles> + <violationsAsErrors>true</violationsAsErrors> +</pmd> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-core/pom.xml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-core/pom.xml b/FlexPMD/flex-pmd-java/flex-pmd-core/pom.xml new file mode 100644 index 0000000..b24af26 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-core/pom.xml @@ -0,0 +1,105 @@ +<?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-core</artifactId> + <packaging>jar</packaging> + + <name>Adobe Flex PMD Core</name> + + <properties> + <doxia-core.version>1.0-alpha-4</doxia-core.version> + </properties> + + <dependencies> + <dependency> + <groupId>doxia</groupId> + <artifactId>doxia-core</artifactId> + <version>${doxia-core.version}</version> + </dependency> + <dependency> + <groupId>${project.parent.groupId}</groupId> + <artifactId>flex-pmd-ruleset-api</artifactId> + <version>${project.parent.version}</version> + </dependency> + <!-- Test dependencies --> + <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> + <dependency> + <groupId>${project.parent.groupId}</groupId> + <artifactId>flex-pmd-ruleset</artifactId> + <version>${project.parent.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <testResources> + <testResource> + <directory>${project.build.directory}/test/generated-resources</directory> + </testResource> + <testResource> + <directory>${basedir}/src/test/resources</directory> + </testResource> + </testResources> + <resources> + <resource> + <directory>${project.build.directory}/test/generated-resources</directory> + </resource> + </resources> + + <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,**/*.xml</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-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java b/FlexPMD/flex-pmd-java/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java new file mode 100644 index 0000000..5bab526 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java @@ -0,0 +1,123 @@ +/* + * 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.List; + +public class FlexPmdParameters +{ + private final String excludePackage; + private final boolean failOnError; + private final boolean failOnRuleViolation; + private final File outputDirectory; + private final File ruleSet; + private final File source; + private final List< File > sourceList; + + public FlexPmdParameters( final String excludePackageToBeSet, + final boolean failOnErrorToBeSet, + final boolean failOnRuleViolationToBeSet, + final File outputDirectoryToBeSet, + final File ruleSetToBeSet, + final File sourceToBeSet ) + { + this( excludePackageToBeSet, + failOnErrorToBeSet, + failOnRuleViolationToBeSet, + outputDirectoryToBeSet, + ruleSetToBeSet, + sourceToBeSet, + null ); + } + + public FlexPmdParameters( final String excludePackageToBeSet, + final boolean failOnErrorToBeSet, + final boolean failOnRuleViolationToBeSet, + final File outputDirectoryToBeSet, + final File ruleSetToBeSet, + final File sourceToBeSet, + final List< File > sourceListToBeSet ) + { + super(); + excludePackage = excludePackageToBeSet; + failOnError = failOnErrorToBeSet; + failOnRuleViolation = failOnRuleViolationToBeSet; + outputDirectory = outputDirectoryToBeSet; + ruleSet = ruleSetToBeSet; + source = sourceToBeSet; + sourceList = sourceListToBeSet; + } + + public FlexPmdParameters( final String excludePackageToBeSet, + final File outputDirectoryToBeSet, + final File ruleSetToBeSet, + final File sourceToBeSet ) + { + this( excludePackageToBeSet, false, false, outputDirectoryToBeSet, ruleSetToBeSet, sourceToBeSet, null ); + } + + public FlexPmdParameters( final String excludePackageToBeSet, + final File outputDirectoryToBeSet, + final File ruleSetToBeSet, + final File sourceToBeSet, + final List< File > sourceListToBeSet ) + { + this( excludePackageToBeSet, + false, + false, + outputDirectoryToBeSet, + ruleSetToBeSet, + sourceToBeSet, + sourceListToBeSet ); + } + + public final String getExcludePackage() + { + return excludePackage; + } + + public final File getOutputDirectory() + { + return outputDirectory; + } + + public final File getRuleSet() + { + return ruleSet; + } + + public final File getSource() + { + return source; + } + + public List< File > getSourceList() + { + return sourceList; + } + + public final boolean isFailOnError() + { + return failOnError; + } + + public boolean isFailOnRuleViolation() + { + return failOnRuleViolation; + } +}