Author: sisbell
Date: Thu Jan 10 09:45:06 2008
New Revision: 610850
URL: http://svn.apache.org/viewvc?rev=610850&view=rev
Log:
Reverted back the abstract compiler mojo.
Added:
incubator/nmaven/trunk/plugins/maven-compiler-plugin/TestCompilerMojo.java
(with props)
Removed:
incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/AbstractCompilerMojo.java
incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
Modified:
incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/pom.xml
incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
Modified:
incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/pom.xml?rev=610850&r1=610849&r2=610850&view=diff
==============================================================================
---
incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/pom.xml
(original)
+++
incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/pom.xml
Thu Jan 10 09:45:06 2008
@@ -33,7 +33,7 @@
<dependency>
<groupId>NUnit</groupId>
<artifactId>NUnit.Framework</artifactId>
- <version>2.4.3</version>
+ <version>2.4.6</version>
<type>dotnet:library</type>
<scope>test</scope>
</dependency>
Added:
incubator/nmaven/trunk/plugins/maven-compiler-plugin/TestCompilerMojo.java
URL:
http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-compiler-plugin/TestCompilerMojo.java?rev=610850&view=auto
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-compiler-plugin/TestCompilerMojo.java
(added)
+++ incubator/nmaven/trunk/plugins/maven-compiler-plugin/TestCompilerMojo.java
Thu Jan 10 09:45:06 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/TestCompilerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
URL:
http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java?rev=610850&r1=610849&r2=610850&view=diff
==============================================================================
---
incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
(original)
+++
incubator/nmaven/trunk/plugins/maven-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
Thu Jan 10 09:45:06 2008
@@ -18,12 +18,28 @@
*/
package org.apache.maven.dotnet.plugin.compiler;
-import java.io.File;
-
-import org.apache.maven.dotnet.BuildDirectories;
-import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
+import org.apache.maven.plugin.AbstractMojo;
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.project.MavenProject;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
/**
* Maven Mojo for compiling Class files to the .NET Intermediate Language.
@@ -34,20 +50,130 @@
* @description Maven Mojo for compiling class files to the .NET Intermediate
Language
*/
public class CompilerMojo
- extends AbstractCompilerMojo
+ extends AbstractMojo
{
- @Override
- protected String getSourceDirectoryName()
- {
- return BuildDirectories.BUILD_SOURCES.getBuildDirectoryName();
- }
+ /**
+ * 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;
public void execute()
throws MojoExecutionException, MojoFailureException
{
+
+ File sourceDir =
+ new File( project.getBuild().getDirectory(),
BuildDirectories.BUILD_SOURCES.getBuildDirectoryName() );
+
+ // No source to process
+ if ( !sourceDir.exists() )
+ {
+ 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();
-
- File assembly = compile( compilerConfig );
- project.getArtifact().setFile( assembly );
+
+ compilerConfig.setArtifactType(
+ ArtifactType.valueOf( project.getPackaging().split( "[:]"
)[1].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 );
+ }
+ 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() );
+ }
}
}