You are viewing a plain text version of this content. The canonical link for it is here.
Posted to nmaven-commits@incubator.apache.org by si...@apache.org on 2007/05/21 21:21:42 UTC

svn commit: r540304 - in /incubator/nmaven/trunk/plugins/maven-fxcop-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/dotnet/ src/main/java/org/apache/m...

Author: sisbell
Date: Mon May 21 14:21:41 2007
New Revision: 540304

URL: http://svn.apache.org/viewvc?view=rev&rev=540304
Log:
Initial import of FxCop plugin.

Added:
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/Output.xml   (with props)
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/pom.xml   (with props)
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/
    incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java   (with props)

Added: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/Output.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-fxcop-plugin/Output.xml?view=auto&rev=540304
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-fxcop-plugin/Output.xml (added)
+++ incubator/nmaven/trunk/plugins/maven-fxcop-plugin/Output.xml Mon May 21 14:21:41 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="http://www.gotdotnet.com/team/fxcop//xsl/1.35/FxCopReport.xsl"?>
+<FxCopReport Version="1.35">
+ <Localized>
+  <String Key="Category">Category</String>
+  <String Key="CollapseAll">Collapse All</String>
+  <String Key="CheckId">Check Id</String>
+  <String Key="Error">Error</String>
+  <String Key="Errors">error(s)</String>
+  <String Key="Line">Line</String>
+  <String Key="LocationNotStoredInPdb">[Location not stored in Pdb]</String>
+  <String Key="Project">Project</String>
+  <String Key="Rule">Rule</String>
+  <String Key="RuleDescription">Rule Description</String>
+  <String Key="Source">Source</String>
+  <String Key="Target">Target</String>
+  <String Key="Warning">Warning</String>
+  <String Key="Warnings">warning(s)</String>
+  <String Key="ReportTitle">Code Analysis Report</String>
+ </Localized>
+ <Exceptions>
+  <Exception Keyword="CA0055" Kind="AssemblyLoad">
+   <Type>Microsoft.FxCop.Common.AssemblyLoadException</Type>
+   <ExceptionMessage>* Could not load file: 'target\NMaven.Logging.dll'.</ExceptionMessage>
+  </Exception>
+  <Exception Keyword="CA0052" Kind="Engine">
+   <Type>Microsoft.FxCop.Sdk.FxCopException</Type>
+   <ExceptionMessage>No targets were selected.</ExceptionMessage>
+  </Exception>
+ </Exceptions>
+</FxCopReport>

Propchange: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/Output.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-fxcop-plugin/pom.xml?view=auto&rev=540304
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-fxcop-plugin/pom.xml (added)
+++ incubator/nmaven/trunk/plugins/maven-fxcop-plugin/pom.xml Mon May 21 14:21:41 2007
@@ -0,0 +1,20 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>maven-dotnet-plugins</artifactId>
+    <groupId>org.apache.maven.dotnet.plugins</groupId>
+    <version>0.14-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.dotnet.plugins</groupId>
+  <artifactId>maven-fxcop-plugin</artifactId>
+  <version>0.14-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java?view=auto&rev=540304
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java (added)
+++ incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java Mon May 21 14:21:41 2007
@@ -0,0 +1,147 @@
+package org.apache.maven.dotnet.plugin.fxcop;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.dotnet.executable.ExecutionException;
+import org.apache.maven.dotnet.PlatformUnsupportedException;
+import org.apache.maven.dotnet.artifact.AssemblyRepositoryLayout;
+import org.apache.maven.dotnet.artifact.AssemblyResolver;
+import org.apache.maven.dotnet.artifact.ArtifactType;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Shane Isbell
+ * @goal fxcop
+ */
+public class FxCopMojo
+    extends AbstractMojo
+{
+    /**
+     * @component
+     */
+    private org.apache.maven.dotnet.executable.NetExecutableFactory netExecutableFactory;
+
+    /**
+     * The maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     */
+    private MavenProject project;
+
+    /**
+     * The Vendor for the executable.
+     *
+     * @parameter expression="${vendor}"
+     */
+    private String vendor;
+
+    /**
+     * @parameter expression = "${frameworkVersion}"
+     */
+    private String frameworkVersion;
+
+    /**
+     * The profile that the executable should use.
+     *
+     * @parameter expression = "${profile}" default-value = "DEFAULT"
+     */
+    private String profile;
+
+    /**
+     * @component
+     */
+    private AssemblyResolver assemblyResolver;
+
+    /**
+     * @parameter expression="${settings.localRepository}"
+     * @readonly
+     */
+    private String localRepository;
+
+    /**
+     * @parameter expression = "${project.build.directory}"
+     */
+    private File targetDirectory;
+
+
+    public void execute()
+        throws MojoExecutionException
+    {
+
+        ArtifactRepository localArtifactRepository =
+            new DefaultArtifactRepository( "local", "file://" + localRepository, new AssemblyRepositoryLayout() );
+        try
+        {
+            assemblyResolver.resolveTransitivelyFor( project, project.getArtifact(), project.getDependencies(),
+                                                     project.getRemoteArtifactRepositories(), localArtifactRepository,
+                                                     true );
+        }
+        catch ( ArtifactResolutionException e )
+        {
+            throw new MojoExecutionException( "NMAVEN-901-000: Unable to resolve assemblies", e );
+        }
+        catch ( ArtifactNotFoundException e )
+        {
+            throw new MojoExecutionException( "NMAVEN-901-001: Unable to resolve assemblies", e );
+        }
+
+        Set<Artifact> artifacts = project.getDependencyArtifacts();
+        for ( Artifact artifact : artifacts )
+        {
+            if ( artifact.getType().startsWith( "gac" ) )
+            {
+                continue;
+            }
+            else
+            {
+                try
+                {
+                    FileUtils.copyFileToDirectory( artifact.getFile(), targetDirectory );
+                }
+                catch ( IOException e )
+                {
+                    throw new MojoExecutionException( "NMAVEN-1100-002: Artifact = " + artifact.toString(), e );
+                }
+            }
+        }
+
+        try
+        {
+            netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, profile, getCommands(),
+                                                      null ).execute();
+        }
+        catch ( ExecutionException e )
+        {
+            throw new MojoExecutionException( "NMAVEN-xxx-000: Unable to execute: Vendor " + vendor +
+                ", frameworkVersion = " + frameworkVersion + ", Profile = " + profile, e );
+        }
+        catch ( PlatformUnsupportedException e )
+        {
+            throw new MojoExecutionException( "NMAVEN-xxx-001: Platform Unsupported: Vendor " + vendor +
+                ", frameworkVersion = " + frameworkVersion + ", Profile = " + profile, e );
+        }
+    }
+
+    public List<String> getCommands()
+        throws MojoExecutionException
+    {
+        List<String> commands = new ArrayList<String>();
+        commands.add( "/f:target" + File.separator + project.getArtifactId() + "." +
+            ArtifactType.getArtifactTypeForPackagingName( project.getPackaging() ).getExtension() );
+        commands.add( "/o:target" + File.separator + "Output.xml" );
+        return commands;
+    }
+}

Propchange: incubator/nmaven/trunk/plugins/maven-fxcop-plugin/src/main/java/org/apache/maven/dotnet/plugin/fxcop/FxCopMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native