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 2008/01/10 17:49:34 UTC

svn commit: r610851 - in /incubator/nmaven/trunk/plugins/maven-compiler-plugin: TestCompilerMojo.java src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java

Author: sisbell
Date: Thu Jan 10 09:49:32 2008
New Revision: 610851

URL: http://svn.apache.org/viewvc?rev=610851&view=rev
Log:
Missed file on commit

Added:
    incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java   (with props)
Removed:
    incubator/nmaven/trunk/plugins/maven-compiler-plugin/TestCompilerMojo.java

Added: incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java?rev=610851&view=auto
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java (added)
+++ incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java Thu Jan 10 09:49:32 2008
@@ -0,0 +1,203 @@
+/*
+ * 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 java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+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.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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Maven Mojo for compiling Class files to the .NET Intermediate Language.
+ *
+ * @goal test-compile
+ * @phase test-compile
+ * @requiresDependencyResolution test
+ * @description Maven Mojo for compiling class files to the .NET Intermediate Language
+ */
+public class TestCompilerMojo
+    extends AbstractMojo
+{
+    /**
+     * 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. (not currently supported)
+     *
+     * @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>. 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;
+
+    /**
+     * @component
+     */
+    private List<ArtifactHandler> artifactHandlers;
+
+    /**
+     * @component
+     */
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+
+        String skipTest = System.getProperty( "maven.test.skip" );
+        if ( "TRUE".equalsIgnoreCase( skipTest ) )
+        {
+            getLog().info( "Skipping Test compilation" );
+            return;
+        }
+
+        File sourceDir =
+            new File( project.getBuild().getDirectory(),
+                      BuildDirectories.TEST_SOURCES.getBuildDirectoryName() );
+
+        // No test source to process
+        if (!sourceDir.exists()) {
+            return;
+        }
+        this.getLog();
+        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.valueOf( project.getPackaging().split( "[:]" )[1].toUpperCase() ) );
+        compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) );
+
+        KeyInfo keyInfo = KeyInfo.Factory.createDefaultKeyInfo();
+        if ( keyfile != null )
+        {
+            try
+            {
+                keyInfo.setKeyFileUri( new URI( keyfile.getAbsolutePath() ) );
+            }
+            catch ( URISyntaxException e )
+            {
+                throw new MojoExecutionException( e.getMessage() );
+            }
+        }
+
+        keyInfo.setKeyContainerName( keycontainer );
+        compilerConfig.setKeyInfo( keyInfo );
+
+        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 );
+        }
+        catch ( InitializationException e )
+        {
+            throw new MojoExecutionException( e.getMessage() );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( e.getMessage() );
+        }
+        try
+        {
+            compilerContext.getClassCompiler().compile();
+        }
+        catch ( InvalidArtifactException e )
+        {
+            throw new MojoExecutionException( e.getMessage() );
+        }
+    }
+}

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