From nmaven-commits-return-688-apmail-incubator-nmaven-commits-archive=incubator.apache.org@incubator.apache.org Thu Jan 10 17:49:55 2008 Return-Path: Delivered-To: apmail-incubator-nmaven-commits-archive@locus.apache.org Received: (qmail 1995 invoked from network); 10 Jan 2008 17:49:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jan 2008 17:49:55 -0000 Received: (qmail 10704 invoked by uid 500); 10 Jan 2008 17:49:45 -0000 Delivered-To: apmail-incubator-nmaven-commits-archive@incubator.apache.org Received: (qmail 10679 invoked by uid 500); 10 Jan 2008 17:49:45 -0000 Mailing-List: contact nmaven-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: nmaven-dev@incubator.apache.org Delivered-To: mailing list nmaven-commits@incubator.apache.org Received: (qmail 10669 invoked by uid 99); 10 Jan 2008 17:49:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2008 09:49:45 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2008 17:49:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C4E071A9832; Thu, 10 Jan 2008 09:49:34 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r610851 - in /incubator/nmaven/trunk/plugins/maven-compiler-plugin: TestCompilerMojo.java src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java Date: Thu, 10 Jan 2008 17:49:34 -0000 To: nmaven-commits@incubator.apache.org From: sisbell@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080110174934.C4E071A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 C_SHARP. 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 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