Author: sisbell
Date: Fri Nov 30 21:34:06 2007
New Revision: 600048

URL: http://svn.apache.org/viewvc?rev=600048&view=rev
Log:
Adding first stab at csharp compiler. Not complete.

Added:
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/CSharpCompiler.java
   (with props)
Modified:
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CommandExecutor.java
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/Compiler.java
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerAnnotation.java
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java

Added: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/CSharpCompiler.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/CSharpCompiler.java?rev=600048&view=auto
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/CSharpCompiler.java
 (added)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/CSharpCompiler.java
 Fri Nov 30 21:34:06 2007
@@ -0,0 +1,179 @@
+package org.apache.maven.dotnet.compiler.ext;
+
+import org.apache.maven.dotnet.compiler.InvalidArtifactException;
+import org.apache.maven.dotnet.compiler.CompilerContext;
+import org.apache.maven.dotnet.compiler.DotnetCompilerContext;
+import org.apache.maven.dotnet.compiler.CompilerAnnotation;
+import org.apache.maven.dotnet.compiler.ProgrammingLanguage;
+import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion;
+import org.apache.maven.dotnet.compiler.CommandExecutor;
+import org.apache.maven.dotnet.compiler.CompilerException;
+import org.apache.maven.dotnet.compiler.Vendor;
+import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
+
+import org.apache.maven.artifact.Artifact;
+
+import java.io.File;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.HashSet;
+
[EMAIL PROTECTED](programmingLanguage = ProgrammingLanguage.C_SHARP, vendor = 
Vendor.MICROSOFT, languageVersion,
+                    dotnetCompilerPlatformVersion = 
DotnetCompilerPlatformVersion.VERSION_2_0_50727)
+public class CSharpCompiler
+    implements org.apache.maven.dotnet.compiler.Compiler
+{
+    private DotnetCompilerContext compilerContext;
+
+    public File getCompiledArtifact()
+        throws InvalidArtifactException
+    {
+        return null;
+        //return compilerContext.
+    }
+
+    public boolean failOnErrorOutput()
+    {
+        return false;
+    }
+
+    public Set<String> getCommands()
+    {
+        DotnetCompilerConfig config = (DotnetCompilerConfig) 
compilerContext.getCompilerConfig();
+        Set<Artifact> references = compilerContext.getLibraryDependencies();
+        Set<Artifact> modules = compilerContext.getDirectModuleDependencies();
+
+        File sourceDirectory = config.getSourceDirectory();
+       // File artifactFilePath = new File(config.getTargetDirectory(), )
+        String targetArtifactType = 
config.getArtifactType().getTargetCompileType();
+
+
+        Set<String> commands = new HashSet<String>();
+   //    commands.add( "/out:" + artifactFilePath );
+        commands.add( "/target:" + targetArtifactType );
+        commands.add( "/recurse:" + sourceDirectory + File.separator + "**" );
+        if ( modules != null && !modules.isEmpty() )
+        {
+            StringBuffer sb = new StringBuffer();
+            for ( Iterator i = modules.iterator(); i.hasNext(); )
+            {
+                Artifact artifact = (Artifact) i.next();
+                String path = artifact.getFile().getAbsolutePath();
+                sb.append( path );
+                if ( i.hasNext() )
+                {
+                    sb.append( ";" );
+                }
+            }
+            commands.add( "/addmodule:" + sb.toString() );
+        }
+        if ( !references.isEmpty() )
+        {
+            for ( Artifact artifact : references )
+            {
+                String path = artifact.getFile().getAbsolutePath();
+                commands.add( "/reference:" + path );
+            }
+        }
+
+        for ( File file : compilerContext.getEmbeddedResources() )
+        {
+            commands.add( "/resource:" + file.getAbsolutePath() );
+        }
+        for ( File file : compilerContext.getLinkedResources() )
+        {
+            commands.add( "/linkresource:" + file.getAbsolutePath() );
+        }
+        for ( File file : compilerContext.getWin32Resources() )
+        {
+            commands.add( "/win32res:" + file.getAbsolutePath() );
+        }
+        if ( compilerContext.getWin32Icon() != null )
+        {
+            commands.add( "/win32icon:" + 
compilerContext.getWin32Icon().getAbsolutePath() );
+        }
+
+        if ( config.getVendor().equals( Vendor.MICROSOFT ) )
+        {
+            commands.add( "/nologo" );
+        }
+
+        if ( config.getVendor().equals( Vendor.MICROSOFT ) &&
+            config.getCompilerPlatformVersion().equals( 
DotnetCompilerPlatformVersion.VERSION_3_0) )
+        {
+            String wcfRef = "/reference:" + System.getenv( "SystemRoot" ) +
+                "\\Microsoft.NET\\Framework\\v3.0\\Windows Communication 
Foundation\\";
+            //TODO: This is a hard-coded path: Don't have a registry value 
either.
+            commands.add( wcfRef + "System.ServiceModel.dll" );
+            commands.add( wcfRef + "Microsoft.Transactions.Bridge.dll" );
+            commands.add( wcfRef + "Microsoft.Transactions.Bridge.Dtc.dll" );
+            commands.add( wcfRef + "System.ServiceModel.Install.dll" );
+            commands.add( wcfRef + "System.ServiceModel.WasHosting.dll" );
+            commands.add( wcfRef + "System.Runtime.Serialization.dll" );
+            commands.add( wcfRef + "SMDiagnostics.dll" );
+        }
+
+        if ( config.getKeyInfo().getKeyFileUri() != null )
+        {
+            commands.add( "/keyfile:" + config.getKeyInfo().getKeyFileUri() );
+        }
+        else if ( config.getKeyInfo().getKeyContainerName() != null )
+        {
+            commands.add( "/keycontainer:" + 
config.getKeyInfo().getKeyContainerName() );
+        }
+/*
+        if ( config.getCommands() != null )
+        {
+            commands.addAll( config.getCommands() );
+        }
+        */
+        commands.add( "/warnaserror-" );
+        if ( config.getVendor().equals( Vendor.NOVELL ) )
+        {
+            commands.add( "/reference:System.Drawing" );
+            commands.add( "/reference:System.Windows.Forms" );
+            commands.add( "/reference:System.Web.Services" );
+        }
+        if ( !config.isTestCompile() )
+        {
+            commands.add(
+                "/doc:" + new File( config.getTargetDirectory(), 
"comments.xml" ).getAbsolutePath() );
+        }
+        return commands;
+    }
+
+    public void resetCommands( Set<String> commands )
+    {
+
+    }
+
+    public void compile()
+    {
+        CommandExecutor commandExecutor = 
CommandExecutor.Factory.createDefaultCommmandExecutor();
+        //commandExecutor.setLogger( logger );
+        try
+        {
+            commandExecutor.executeCommand(getCompilerFileName(), 
getCommands() );
+        }
+        catch ( CompilerException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+    public String getCompilerFileName()
+    {
+        return "csc";
+    }
+
+    public void init( CompilerContext compilerContext )
+    {
+        if ( compilerContext == null || ! ( compilerContext instanceof 
DotnetCompilerContext ) )
+        {
+            throw new IllegalArgumentException( "compilerContext" );
+        }
+        this.compilerContext = (DotnetCompilerContext) compilerContext;
+    }
+}

Propchange: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler-ext/src/main/java/org/apache/maven/dotnet/compiler/ext/CSharpCompiler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CommandExecutor.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CommandExecutor.java?rev=600048&r1=600047&r2=600048&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CommandExecutor.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CommandExecutor.java
 Fri Nov 30 21:34:06 2007
@@ -7,8 +7,9 @@
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.DefaultConsumer;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
 import java.io.File;
 
 /**
@@ -34,7 +35,7 @@
      * @throws org.apache.maven.dotnet.executable.ExecutionException if 
compiler or executable writes anything to the standard error stream or if the 
process
      *                            returns a process result != 0.
      */
-    void executeCommand( String executable, List<String> commands )
+    void executeCommand( String executable, Set<String> commands )
         throws CompilerException;
 
     /**
@@ -47,7 +48,7 @@
      * @throws org.apache.maven.dotnet.executable.ExecutionException if 
compiler or executable writes anything to the standard error stream (provided 
the
      *                            failsOnErrorOutput is not false) or if the 
process returns a process result != 0.
      */
-    void executeCommand( String executable, List<String> commands, boolean 
failsOnErrorOutput )
+    void executeCommand( String executable, Set<String> commands, boolean 
failsOnErrorOutput )
         throws CompilerException;
 
     /**
@@ -61,7 +62,7 @@
      * @throws org.apache.maven.dotnet.executable.ExecutionException if 
compiler or executable writes anything to the standard error stream (provided 
the
      *                            failsOnErrorOutput is not false) or if the 
process returns a process result != 0.
      */
-    void executeCommand( String executable, List<String> commands, File 
workingDirectory, boolean failsOnErrorOutput )
+    void executeCommand( String executable, Set<String> commands, File 
workingDirectory, boolean failsOnErrorOutput )
         throws CompilerException;
 
     /**
@@ -134,25 +135,25 @@
                 }
 
 
-                public void executeCommand( String executable, List<String> 
commands )
+                public void executeCommand( String executable, Set<String> 
commands )
                     throws CompilerException
                 {
                     executeCommand( executable, commands, null, true );
                 }
 
-                public void executeCommand( String executable, List<String> 
commands, boolean failsOnErrorOutput )
+                public void executeCommand( String executable, Set<String> 
commands, boolean failsOnErrorOutput )
                     throws CompilerException
                 {
                     executeCommand( executable, commands, null, 
failsOnErrorOutput );
                 }
 
-                public void executeCommand( String executable, List<String> 
commands, File workingDirectory,
+                public void executeCommand( String executable, Set<String> 
commands, File workingDirectory,
                                             boolean failsOnErrorOutput )
                     throws CompilerException
                 {
                     if ( commands == null )
                     {
-                        commands = new ArrayList<String>();
+                        commands = new HashSet<String>();
                     }
                     stdOut = new StreamConsumerImpl();
                     stdErr = new ErrorStreamConsumer();

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/Compiler.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/Compiler.java?rev=600048&r1=600047&r2=600048&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/Compiler.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/Compiler.java
 Fri Nov 30 21:34:06 2007
@@ -48,4 +48,6 @@
      */
     String getCompilerFileName();
 
+    void init(CompilerContext compilerContext);
+
 }

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerAnnotation.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerAnnotation.java?rev=600048&r1=600047&r2=600048&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerAnnotation.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerAnnotation.java
 Fri Nov 30 21:34:06 2007
@@ -6,5 +6,5 @@
 
     Vendor getVendor();
 
-    String getLanguageVersion();
+    DotnetCompilerPlatformVersion getDotnetCompilerPlatformVersion();
 }

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java?rev=600048&r1=600047&r2=600048&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java
 Fri Nov 30 21:34:06 2007
@@ -38,7 +38,7 @@
          *
          * @return a default instance of the executable config
          */
-        public static DotnetCompilerConfig createDefaultExecutableConfig()
+        public static DotnetCompilerConfig createDefaultCompilerConfig()
         {
             return new DotnetCompilerConfig()
             {

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java?rev=600048&r1=600047&r2=600048&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java
 Fri Nov 30 21:34:06 2007
@@ -105,7 +105,7 @@
 
     private static DotnetCompilerConfig getDefaultDotnetCompilerConfig()
     {
-        DotnetCompilerConfig config = 
DotnetCompilerConfig.Factory.createDefaultExecutableConfig();
+        DotnetCompilerConfig config = 
DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
         config.setArtifactType( ArtifactType.LIBRARY );
         config.setCompilerPlatformVersion( 
DotnetCompilerPlatformVersion.VERSION_2_0_50727 );
         config.setLocalRepository( new File( "." ) );

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java?rev=600048&r1=600047&r2=600048&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
 Fri Nov 30 21:34:06 2007
@@ -20,8 +20,6 @@
 
 import org.junit.Test;
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.*;
-import org.hamcrest.Matcher;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.CoreMatchers;
 import static org.junit.Assert.*;
@@ -33,7 +31,7 @@
         throws PlatformUnsupportedException
     {
         DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
-        DotnetCompilerConfig compilerConfig = 
DotnetCompilerConfig.Factory.createDefaultExecutableConfig();
+        DotnetCompilerConfig compilerConfig = 
DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
 
         ctx.init( null, compilerConfig );
 
@@ -192,9 +190,40 @@
             "C:\\Program 
Files\\Mono\\lib\\mono\\gac\\artifactId\\1.0__dsfajkdsfajdfs\\artifactId.dll" ) 
);
     }
 
+    @Test
+    public void testInit_WithGacGenericAndNovellAndMonoRoot()
+        throws PlatformUnsupportedException
+    {
+        System.setProperty( "MONO_ROOT", "C:\\Program Files\\Mono\\bin" );
+        DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
+        MavenProject project = new MavenProject();
+
+        Set<Artifact> dependencyArtifacts = new HashSet<Artifact>();
+        project.setDependencyArtifacts( dependencyArtifacts );
+        Artifact artifact = new DefaultArtifact( "groupId", "artifactId", 
VersionRange.createFromVersion( "1.0" ),
+                                                 "compile", "gac_generic", 
"dsfajkdsfajdfs",
+                                                 new DefaultArtifactHandler( 
"library" ), false );
+        dependencyArtifacts.add( artifact );
+
+        Build build = new Build();
+        build.setDirectory( "" );
+        project.setBuild( build );
+
+        ctx.turnOffAssemblyExistsCheck();
+        DotnetCompilerConfig compilerConfig = getDefaultDotnetCompilerConfig();
+        compilerConfig.setVendor( Vendor.NOVELL );
+
+        ctx.init( project, compilerConfig );
+
+        Set<Artifact> libraries = ctx.getLibraryDependencies();
+        assertThat( libraries.size(), equalTo( 1 ) );
+        assertThat( ( (Artifact) libraries.toArray()[0] 
).getFile().getAbsolutePath(), equalTo(
+            "C:\\Program 
Files\\Mono\\lib\\mono\\gac\\artifactId\\1.0__dsfajkdsfajdfs\\artifactId.dll" ) 
);
+    }
+
     private static DotnetCompilerConfig getDefaultDotnetCompilerConfig()
     {
-        DotnetCompilerConfig config = 
DotnetCompilerConfig.Factory.createDefaultExecutableConfig();
+        DotnetCompilerConfig config = 
DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
         config.setArtifactType( ArtifactType.LIBRARY );
         config.setCompilerPlatformVersion( 
DotnetCompilerPlatformVersion.VERSION_2_0_50727 );
         config.setLocalRepository( new File( "." ) );


Reply via email to