Index: src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java
===================================================================
--- src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java	(revision 0)
+++ src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java	(revision 0)
@@ -0,0 +1,198 @@
+/*
+ * 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 org.apache.maven.dotnet.plugin.compiler;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.dotnet.ArtifactType;
+import org.apache.maven.dotnet.InitializationException;
+import org.apache.maven.dotnet.ProgrammingLanguage;
+import org.apache.maven.dotnet.Vendor;
+import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
+import org.apache.maven.dotnet.compiler.DotnetCompilerContext;
+import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion;
+import org.apache.maven.dotnet.compiler.InvalidArtifactException;
+import org.apache.maven.dotnet.compiler.KeyInfo;
+import org.apache.maven.dotnet.toolchain.DotnetToolchain;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.toolchain.ToolchainManager;
+
+/**
+ * Abstract Maven Mojo for compiling Class files to the .NET Intermediate Language.
+ */
+public abstract class AbstractCompilerMojo
+    extends AbstractMojo
+{
+    /**
+     * The maven project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     */
+    protected MavenProject project;
+
+    /**
+     * The location of the local Maven repository.
+     *
+     * @parameter expression="${settings.localRepository}"
+     */
+    private File localRepository;
+
+    /**
+     * Specify a strong name key file.
+     *
+     * @parameter expression = "${keyfile}"
+     */
+    private File keyfile;
+
+    /**
+     * Specifies a strong name key container.
+     *
+     * @parameter expression = "${keycontainer}"
+     */
+    private String keycontainer;
+
+    /**
+     * The framework version to compile under: 1.1, 2.0, 3.0
+     *
+     * @parameter expression = "${frameworkVersion}" default-value="2.0.50727"
+     */
+    private String frameworkVersion;
+
+    /**
+     * The Vendor for the Compiler. Not case or white-space sensitive.
+     *
+     * @parameter expression="${vendor}"
+     */
+    private String vendorName;
+
+    /**
+     * @component
+     */
+    protected DotnetCompilerContext dotnetCompilerContext;
+
+    /**
+     * @component
+     */
+    private ToolchainManager toolchainManager;
+
+    /**
+     * @parameter expression="${session}"
+     */
+    private MavenSession mavenSession;
+
+    /**
+     * Compile sources in directory provided
+     * 
+     * @param sourceDir
+     * @return the compilation resulting assembly or null if nothing needed to be compiled (ie no sources available)
+     * @throws MojoExecutionException
+     * @throws MojoFailureException
+     */
+    protected File execute( File sourceDir )
+        throws MojoExecutionException, MojoFailureException
+    {
+        // No source to process
+        if ( !sourceDir.exists() )
+        {
+            return null;
+        }
+
+        DotnetToolchain toolchain = (DotnetToolchain) toolchainManager.getToolchainFromBuildContext( "dotnet", mavenSession );
+        
+        if ( toolchain == null )
+        {
+            this.getLog().info( "Could not find dotnet toolchain." );
+        }
+
+        Vendor vendor;
+        if ( vendorName != null )
+        {
+            vendor = Vendor.valueOf( vendorName.toUpperCase() );
+        }
+        else
+        {
+            vendor = Vendor.getDefaultVendorForOS();
+        }
+
+        getLog().info( ".NET Vendor: " + vendor );
+        DotnetCompilerConfig compilerConfig = getCompilerConfig();
+
+        String packaging = project.getPackaging();
+
+        // If this is a dotnet type, remove the "dotnet:" portion
+        if ( packaging.contains( ":" ) )
+        {
+            packaging = packaging.split( "[:]" )[1];
+        }
+
+        compilerConfig.setArtifactType( ArtifactType.valueOf( packaging.toUpperCase() ) );
+        compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) );
+
+        KeyInfo keyInfo = KeyInfo.Factory.createDefaultKeyInfo();
+        if ( keyfile != null )
+        {
+            keyInfo.setKeyFileUri( keyfile.toURI() );
+        }
+
+        keyInfo.setKeyContainerName( keycontainer );
+        compilerConfig.setKeyInfo( keyInfo );
+
+        compilerConfig.setLocalRepository( localRepository );
+        compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
+        compilerConfig.setCompilerSourceDirectory( sourceDir );
+        compilerConfig.setVendor( vendor );
+        compilerConfig.setTargetDirectory( new File( project.getBuild().getDirectory() ) );
+        compilerConfig.setArtifactFileName( getArtifactFileName( compilerConfig.getArtifactType() ) );
+
+        try
+        {
+            dotnetCompilerContext.init( project, compilerConfig, toolchain );
+        }
+        catch ( InitializationException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+        try
+        {
+            File assembly = dotnetCompilerContext.getClassCompiler().compile();
+            return assembly;
+        }
+        catch ( InvalidArtifactException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+    }
+
+    protected DotnetCompilerConfig getCompilerConfig()
+    {
+        return DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
+    }
+
+    protected abstract String getArtifactFileName( ArtifactType artifactType );
+}

Property changes on: src\main\java\org\apache\maven\dotnet\plugin\compiler\AbstractCompilerMojo.java
___________________________________________________________________
Added: svn:keywords
   + "Author Date Id Revision"
Added: svn:eol-style
   + native

Index: src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
===================================================================
--- src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java	(revision 685490)
+++ src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java	(working copy)
@@ -18,27 +18,13 @@
  */
 package org.apache.maven.dotnet.plugin.compiler;
 
-import org.apache.maven.plugin.AbstractMojo;
+import java.io.File;
+
+import org.apache.maven.dotnet.ArtifactType;
+import org.apache.maven.dotnet.BuildDirectories;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.dotnet.compiler.DotnetCompilerContext;
-import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
-import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion;
-import org.apache.maven.dotnet.compiler.KeyInfo;
-import org.apache.maven.dotnet.compiler.InvalidArtifactException;
-import org.apache.maven.dotnet.ProgrammingLanguage;
-import org.apache.maven.dotnet.Vendor;
-import org.apache.maven.dotnet.BuildDirectories;
-import org.apache.maven.dotnet.ArtifactType;
-import org.apache.maven.dotnet.InitializationException;
-import org.apache.maven.dotnet.toolchain.DotnetToolchain;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.toolchain.ToolchainManager;
 
-import java.io.File;
-import java.io.IOException;
-
 /**
  * Maven Mojo for compiling Class files to the .NET Intermediate Language.
  *
@@ -48,154 +34,21 @@
  * @description Maven Mojo for compiling class files to the .NET Intermediate Language
  */
 public class CompilerMojo
-    extends AbstractMojo
+    extends AbstractCompilerMojo
 {
-    /**
-     * The maven project.
-     *
-     * @parameter expression="${project}"
-     * @required
-     */
-    private MavenProject project;
-
-    /**
-     * The location of the local Maven repository.
-     *
-     * @parameter expression="${settings.localRepository}"
-     */
-    private File localRepository;
-
-    /**
-     * Specify a strong name key file.
-     *
-     * @parameter expression = "${keyfile}"
-     */
-    private File keyfile;
-
-    /**
-     * Specifies a strong name key container.
-     *
-     * @parameter expression = "${keycontainer}"
-     */
-    private String keycontainer;
-
-    /**
-     * The framework version to compile under: 1.1, 2.0, 3.0
-     *
-     * @parameter expression = "${frameworkVersion}" default-value="2.0.50727"
-     */
-    private String frameworkVersion;
-
-    /**
-     * .NET Language. The default value is <code>C_SHARP</code>.
-     *
-     * @parameter expression="${language}" default-value = "C_SHARP"
-     * @required
-     */
-    private String language;
-
-    /**
-     * The Vendor for the Compiler.
-     *
-     * @parameter expression="${vendor}"
-     */
-    private String vendorName;
-
-    /**
-     * @component
-     */
-    private DotnetCompilerContext dotnetCompilerContext;
-
-    /**
-     * @component
-     */
-    private ToolchainManager toolchainManager;
-
-    /**
-     * @parameter expression="${session}"
-     */
-    private MavenSession mavenSession;
-
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
 
-        DotnetToolchain toolchain = (DotnetToolchain) toolchainManager.getToolchainFromBuildContext( "dotnet", mavenSession );
-        
-        if ( toolchain == null )
-        {
-            this.getLog().info( "Could not find dotnet toolchain." );
-        }
-
         File sourceDir =
             new File( project.getBuild().getDirectory(), BuildDirectories.BUILD_SOURCES.getBuildDirectoryName() );
 
-        // No source to process
-        if ( !sourceDir.exists() )
-        {
-            return;
-        }
+        File assembly = super.execute( sourceDir );
+        project.getArtifact().setFile( assembly );
+    }
 
-        Vendor vendor;
-        if ( vendorName != null )
-        {
-            vendor = Vendor.valueOf( vendorName.toUpperCase() );
-        }
-        else
-        {
-            vendor = Vendor.getDefaultVendorForOS();
-        }
-
-        getLog().info( ".NET Vendor: " + vendor );
-        DotnetCompilerConfig compilerConfig = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
-
-        String packaging = project.getPackaging();
-
-        // If this is a dotnet type, remove the "dotnet:" portion
-        if ( packaging.contains( ":" ) )
-        {
-            packaging = packaging.split( "[:]" )[1];
-        }
-
-        compilerConfig.setArtifactType( ArtifactType.valueOf( packaging.toUpperCase() ) );
-        compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) );
-
-        KeyInfo keyInfo = KeyInfo.Factory.createDefaultKeyInfo();
-        if ( keyfile != null )
-        {
-            keyInfo.setKeyFileUri( keyfile.toURI() );
-        }
-
-        keyInfo.setKeyContainerName( keycontainer );
-        compilerConfig.setKeyInfo( keyInfo );
-
-        compilerConfig.setLocalRepository( localRepository );
-        compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
-        compilerConfig.setCompilerSourceDirectory( sourceDir );
-        compilerConfig.setVendor( vendor );
-        compilerConfig.setTargetDirectory( new File( project.getBuild().getDirectory() ) );
-        compilerConfig.setArtifactFileName(
-            project.getBuild().getFinalName() + "." + compilerConfig.getArtifactType().getExtension() );
-
-        try
-        {
-            dotnetCompilerContext.init( project, compilerConfig, toolchain );
-        }
-        catch ( InitializationException e )
-        {
-            throw new MojoExecutionException( e.getMessage() );
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( e.getMessage() );
-        }
-        try
-        {
-            project.getArtifact().setFile( dotnetCompilerContext.getClassCompiler().compile() );
-        }
-        catch ( InvalidArtifactException e )
-        {
-            throw new MojoExecutionException( e.getMessage() );
-        }
+    protected String getArtifactFileName( ArtifactType artifactType )
+    {
+        return project.getBuild().getFinalName() + "." + artifactType.getExtension();
     }
 }
Index: src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
===================================================================
--- src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java	(revision 685490)
+++ src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java	(working copy)
@@ -22,21 +22,13 @@
 import java.io.IOException;
 import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.dotnet.ArtifactScope;
 import org.apache.maven.dotnet.ArtifactType;
 import org.apache.maven.dotnet.BuildDirectories;
-import org.apache.maven.dotnet.InitializationException;
-import org.apache.maven.dotnet.ProgrammingLanguage;
-import org.apache.maven.dotnet.Vendor;
-import org.apache.maven.dotnet.ArtifactScope;
 import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
-import org.apache.maven.dotnet.compiler.DotnetCompilerContext;
-import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion;
-import org.apache.maven.dotnet.compiler.InvalidArtifactException;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.artifact.Artifact;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -48,51 +40,8 @@
  * @description Maven Mojo for compiling class files to the .NET Intermediate Language
  */
 public class TestCompilerMojo
-    extends AbstractMojo
+    extends AbstractCompilerMojo
 {
-    /**
-     * The maven project.
-     *
-     * @parameter expression="${project}"
-     * @required
-     */
-    private MavenProject project;
-
-    /**
-     * The location of the local Maven repository.
-     *
-     * @parameter expression="${settings.localRepository}"
-     */
-    private File localRepository;
-
-    /**
-     * The framework version to compile under: 1.1, 2.0, 3.0
-     *
-     * @parameter expression = "${frameworkVersion}" default-value="2.0.50727"
-     */
-    private String frameworkVersion;
-
-    /**
-     * .NET Language. The default value is <code>C_SHARP</code>. Not case or white-space sensitive.
-     *
-     * @parameter expression="${language}" default-value = "C_SHARP"
-     * @required
-     */
-    private String language;
-
-    /**
-     * The Vendor for the Compiler. Not case or white-space sensitive.
-     *
-     * @parameter expression="${vendor}"
-     */
-    private String vendorName;
-
-    /**
-     * @component
-     */
-    private DotnetCompilerContext compilerContext;
-
-
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -107,59 +56,14 @@
         File sourceDir =
             new File( project.getBuild().getDirectory(), BuildDirectories.TEST_BUILD_SOURCES.getBuildDirectoryName() );
 
-        // No test source to process
-        if ( !sourceDir.exists() )
+        File testAssembly = super.execute( sourceDir );
+
+        if ( testAssembly == null )
         {
+            /* nothing was compiled */
             return;
         }
 
-        Vendor vendor;
-        if ( vendorName != null )
-        {
-            vendor = Vendor.valueOf( vendorName.toUpperCase() );
-        }
-        else
-        {
-            vendor = Vendor.getDefaultVendorForOS();
-        }
-
-        getLog().info( ".NET Vendor: " + vendor );
-        DotnetCompilerConfig compilerConfig = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
-        compilerConfig.setArtifactType( ArtifactType.LIBRARY );
-        compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) );
-
-        compilerConfig.setLocalRepository( localRepository );
-        compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
-        compilerConfig.setTestCompile( true );
-        compilerConfig.setCompilerSourceDirectory( sourceDir );
-        compilerConfig.setVendor( vendor );
-        compilerConfig.setTargetDirectory( new File( project.getBuild().getDirectory() ) );
-        compilerConfig.setArtifactFileName(
-            project.getBuild().getFinalName() + "-test" + "." + compilerConfig.getArtifactType().getExtension() );
-
-        try
-        {
-            compilerContext.init( project, compilerConfig, null );
-        }
-        catch ( InitializationException e )
-        {
-            throw new MojoExecutionException( e.getMessage() );
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( e.getMessage() );
-        }
-
-        File testAssembly;
-        try
-        {
-            testAssembly = compilerContext.getClassCompiler().compile();
-        }
-        catch ( InvalidArtifactException e )
-        {
-            throw new MojoExecutionException( e.getMessage() );
-        }
-
         //Copy test references to target
         File testAssemblies =
             new File( project.getBuild().getDirectory(), BuildDirectories.TEST_ASSEMBLIES.getBuildDirectoryName() );
@@ -169,7 +73,7 @@
             throw new MojoExecutionException( "Unable to create test assemblies directory: " + testAssemblies );
         }
 
-       Set<Artifact> testDependencies = compilerContext.getLibraryDependenciesFor( ArtifactScope.TEST );
+       Set<Artifact> testDependencies = dotnetCompilerContext.getLibraryDependenciesFor( ArtifactScope.TEST );
 
         try
         {
@@ -188,4 +92,16 @@
             throw new MojoExecutionException( "Unable to copy all test assemblies to execution directory" );
         }
     }
+
+    protected DotnetCompilerConfig getCompilerConfig()
+    {
+        DotnetCompilerConfig compilerConfig = super.getCompilerConfig();
+        compilerConfig.setTestCompile( true );
+        return compilerConfig;
+    }
+
+    protected String getArtifactFileName( ArtifactType artifactType )
+    {
+        return project.getBuild().getFinalName() + "-test" + "." + artifactType.getExtension();
+    }
 }

