incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r632400 - in /incubator/nmaven/trunk: components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/ components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/ components/maven-dotnet-compiler/sr...
Date Fri, 29 Feb 2008 17:52:44 GMT
Author: sisbell
Date: Fri Feb 29 09:52:28 2008
New Revision: 632400

URL: http://svn.apache.org/viewvc?rev=632400&view=rev
Log:
Use of the toolchain within the compiler context and the csharp compiler.

Modified:
    incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java
    incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerContext.java
    incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
    incubator/nmaven/trunk/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
    incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java
    incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/toolchain/DotnetToolchain.java
    incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0000-CSharpCompileLibrary/pom.xml
    incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
    incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java

Modified: incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java
Fri Feb 29 09:52:28 2008
@@ -21,7 +21,6 @@
 import org.apache.maven.dotnet.ProgrammingLanguage;
 import org.apache.maven.dotnet.Vendor;
 import org.apache.maven.dotnet.ArtifactType;
-import org.apache.maven.toolchain.Toolchain;
 
 import java.io.File;
 
@@ -107,10 +106,6 @@
     String getArtifactFileName();
 
     void setArtifactFileName(String artifactFileName);
-
-    Toolchain getToolchain();
-
-    void setToolchain(Toolchain toolchain);
 
     /**
      * Verifies that the necessary parameters exist within the config exist and are valid.

Modified: incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerContext.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerContext.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerContext.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerContext.java
Fri Feb 29 09:52:28 2008
@@ -20,9 +20,12 @@
 
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.dotnet.InitializationException;
+import org.apache.maven.dotnet.ProgrammingLanguage;
+import org.apache.maven.toolchain.Toolchain;
 import org.codehaus.plexus.logging.Logger;
 
 import java.io.IOException;
+import java.io.File;
 
 /**
  * Interface defining compiler services.
@@ -45,24 +48,26 @@
      */
     ClassCompiler getClassCompiler();
 
+    File getCompilerExecutableFor( ProgrammingLanguage programmingLanguage ) throws CompilerException;
+
     /**
      * Returns the maven project used to initialize this context.
      *
      * @return the maven project used to initialize this context
      */
     MavenProject getMavenProject();
-    
+
     Logger getPlexusLogger();
 
     /**
      * Initializes the compiler context.
      *
-     * @param project the maven project
+     * @param project        the maven project
      * @param compilerConfig
      * @throws InitializationException
      * @throws IOException
      */
-    void init( MavenProject project, CompilerConfig compilerConfig )
+    void init( MavenProject project, CompilerConfig compilerConfig, Toolchain toolchain )
         throws InitializationException, IOException;
 
 }

Modified: incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
Fri Feb 29 09:52:28 2008
@@ -40,8 +40,11 @@
 import org.apache.maven.dotnet.BuildDirectories;
 import org.apache.maven.dotnet.ArtifactType;
 import org.apache.maven.dotnet.ArtifactScope;
+import org.apache.maven.dotnet.ProgrammingLanguage;
 import org.apache.maven.dotnet.compiler.CompilerAnnotation;
+import org.apache.maven.dotnet.compiler.CompilerException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.toolchain.Toolchain;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.LogEnabled;
 
@@ -79,6 +82,8 @@
 
     private boolean compilerExistsCheck = true;
 
+    private Toolchain toolchain;
+
     public Set<String> getCoreAssemblyNames()
     {
         return null;
@@ -124,6 +129,32 @@
         return classCompiler;
     }
 
+    public File getCompilerExecutableFor( ProgrammingLanguage programmingLanguage )
+        throws CompilerException
+    {
+        if ( programmingLanguage == null )
+        {
+            throw new IllegalArgumentException( "programmingLanguage" );
+        }
+
+        if ( toolchain == null )
+        {
+            throw new CompilerException( "No toolchain found." );
+        }
+
+        if ( programmingLanguage.equals( ProgrammingLanguage.C_SHARP ) )
+        {
+            File csharpExecutable = new File( toolchain.findTool( "csharpCompiler" ) );
+            if ( !csharpExecutable.exists() )
+            {
+                throw new CompilerException(
+                    "The compiler does not exist: File = " + csharpExecutable.getAbsolutePath()
);
+            }
+            return csharpExecutable;
+        }
+        throw new CompilerException( "Compiler could not be found: Language = " + programmingLanguage
);
+    }
+
     public MavenProject getMavenProject()
     {
         return project;
@@ -140,7 +171,7 @@
         logger.info( "Logging enabled." );
     }
 
-    public void init( MavenProject project, CompilerConfig compilerConfig )
+    public void init( MavenProject project, CompilerConfig compilerConfig, Toolchain toolchain
)
         throws InitializationException, IOException
     {
         if ( project == null )
@@ -159,7 +190,7 @@
 
         HashSet<Artifact> compileLibraryDependencies = new HashSet<Artifact>();
         HashSet<Artifact> systemLibraryDependencies = new HashSet<Artifact>();
-        HashSet<Artifact>  providedLibraryDependencies = new HashSet<Artifact>();
+        HashSet<Artifact> providedLibraryDependencies = new HashSet<Artifact>();
         HashSet<Artifact> testLibraryDependencies = new HashSet<Artifact>();
         HashSet<Artifact> runtimeLibraryDependencies = new HashSet<Artifact>();
 
@@ -277,7 +308,7 @@
             String type = artifact.getType();
             if ( ArtifactType.LIBRARY.isMatchByString( type ) || ArtifactType.EXE.isMatchByString(
type ) ||
                 ArtifactType.WINEXE.isMatchByString( type ) || type.startsWith( "dotnet:gac"
) ||
-                ArtifactType.LIBRARY_LEGACY.isMatchByString( type ))
+                ArtifactType.LIBRARY_LEGACY.isMatchByString( type ) )
             {
                 targetArtifacts.add( artifact );
             }

Modified: incubator/nmaven/trunk/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
Fri Feb 29 09:52:28 2008
@@ -54,7 +54,7 @@
         DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
         DotnetCompilerConfig compilerConfig = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
 
-        ctx.init( null, compilerConfig );
+        ctx.init( null, compilerConfig, null );
 
     }
 
@@ -63,7 +63,7 @@
         throws InitializationException, IOException
     {
         DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
-        ctx.init( new MavenProject(), null );
+        ctx.init( new MavenProject(), null, null );
     }
 
     @Test
@@ -85,7 +85,7 @@
         project.setBuild( build );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         Set<Artifact> modules = ctx.getDirectModuleDependencies();
         assertThat( modules.size(), equalTo( 1 ) );
@@ -111,7 +111,7 @@
         project.setBuild( build );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -137,7 +137,7 @@
         project.setBuild( build );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -163,7 +163,7 @@
         project.setBuild( build );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -189,7 +189,7 @@
         project.setBuild( build );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -216,7 +216,7 @@
         ctx.turnOffAssemblyExistsCheck();
         ctx.turnOffCompilerExistsCheck();
 
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -264,7 +264,7 @@
         compilerConfig.setVendor( Vendor.NOVELL );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, compilerConfig );
+        ctx.init( project, compilerConfig, null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -297,7 +297,7 @@
         compilerConfig.setVendor( Vendor.NOVELL );
 
         ctx.turnOffCompilerExistsCheck();
-        ctx.init( project, compilerConfig );
+        ctx.init( project, compilerConfig, null );
 
         Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE
);
         assertThat( libraries.size(), equalTo( 1 ) );
@@ -320,7 +320,7 @@
         System.setProperty( "java.class.path", new File( "src/test/resources",
                                                          "dotnet-compiler-ext-0.14-incubating-SNAPSHOT.jar"
).getAbsolutePath() );
 
-        ctx.init( project, getDefaultDotnetCompilerConfig() );
+        ctx.init( project, getDefaultDotnetCompilerConfig(), null );
 
         ClassCompiler compiler = ctx.getClassCompiler();
     }

Modified: incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java
Fri Feb 29 09:52:28 2008
@@ -137,7 +137,7 @@
             commands.add( wcfRef + "System.Runtime.Serialization.dll" );
             commands.add( wcfRef + "SMDiagnostics.dll" );
         }
-        
+
         if ( config.getKeyInfo() != null )
         {
             if ( config.getKeyInfo().getKeyFileUri() != null )
@@ -194,7 +194,22 @@
 
     public String getCompilerFileName()
     {
-        if ( compilerContext.getCompilerConfig().getVendor().equals( Vendor.MICROSOFT ) )
+        File compilerExecutable = null;
+        try
+        {
+            compilerExecutable = compilerContext.getCompilerExecutableFor(
+                compilerContext.getCompilerConfig().getProgrammingLanguage() );
+        }
+        catch ( CompilerException e )
+        {
+            e.printStackTrace();
+        }
+
+        if ( compilerExecutable != null )
+        {
+            return compilerExecutable.getAbsolutePath();
+        }
+        else if ( compilerContext.getCompilerConfig().getVendor().equals( Vendor.MICROSOFT
) )
         {
             return "csc";
         }

Modified: incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/toolchain/DotnetToolchain.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/toolchain/DotnetToolchain.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/toolchain/DotnetToolchain.java
(original)
+++ incubator/nmaven/trunk/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/toolchain/DotnetToolchain.java
Fri Feb 29 09:52:28 2008
@@ -2,6 +2,8 @@
 
 import org.apache.maven.toolchain.DefaultToolchain;
 import org.apache.maven.toolchain.model.ToolchainModel;
+import org.apache.maven.dotnet.Vendor;
+import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
@@ -20,6 +22,16 @@
         this( model, null, logger );
     }
 
+    public Vendor getVendor()
+    {
+        return Vendor.MICROSOFT;
+    }
+
+    public DotnetCompilerPlatformVersion getDotnetCompilerPlatformVersion()
+    {
+        return DotnetCompilerPlatformVersion.VERSION_2_0_50727;        
+    }
+
     public DotnetToolchain( ToolchainModel model, String type, Logger logger )
     {
         super( model, type, logger );
@@ -56,6 +68,5 @@
             return nunitConsole;
         }
         return null;
-    }
-       
+    }      
 }

Modified: incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0000-CSharpCompileLibrary/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0000-CSharpCompileLibrary/pom.xml?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0000-CSharpCompileLibrary/pom.xml
(original)
+++ incubator/nmaven/trunk/core-integration-tests/src/test/resources/MavenITmng-0000-CSharpCompileLibrary/pom.xml
Fri Feb 29 09:52:28 2008
@@ -32,5 +32,6 @@
         <artifactId>maven-dotnet-compiler-plugin</artifactId>
         <extensions>true</extensions>
       </plugin>
+    </plugins>
   </build>
 </project>

Modified: incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java
Fri Feb 29 09:52:28 2008
@@ -31,10 +31,12 @@
 import org.apache.maven.dotnet.BuildDirectories;
 import org.apache.maven.dotnet.ArtifactType;
 import org.apache.maven.dotnet.InitializationException;
+import org.apache.maven.dotnet.extensions.toolchain.DotnetToolchain;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.DefaultToolchain;
 
 import java.io.File;
 import java.io.IOException;
@@ -119,14 +121,15 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        Toolchain dotnetToolchain =
-            toolchainManager.getToolchainFromBuildContext( "dotnet", mavenSession );
+        DotnetToolchain toolchain =
+            (DotnetToolchain) toolchainManager.getToolchainFromBuildContext( "dotnet", mavenSession
);
 
-        if ( dotnetToolchain == null )
+        if ( toolchain == null )
         {
             this.getLog().info( "Could not find dotnet toolchain." );
         }
 
+
         File sourceDir =
             new File( project.getBuild().getDirectory(), BuildDirectories.BUILD_SOURCES.getBuildDirectoryName()
);
 
@@ -176,11 +179,10 @@
         compilerConfig.setTargetDirectory( new File( project.getBuild().getDirectory() )
);
         compilerConfig.setArtifactFileName(
             project.getBuild().getFinalName() + "." + compilerConfig.getArtifactType().getExtension()
);
-        compilerConfig.setToolchain( dotnetToolchain );
-        
+
         try
         {
-            dotnetCompilerContext.init( project, compilerConfig );
+            dotnetCompilerContext.init( project, compilerConfig, toolchain );
         }
         catch ( InitializationException e )
         {

Modified: incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java?rev=632400&r1=632399&r2=632400&view=diff
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java
Fri Feb 29 09:52:28 2008
@@ -139,7 +139,7 @@
 
         try
         {
-            compilerContext.init( project, compilerConfig );
+            compilerContext.init( project, compilerConfig, null );
         }
         catch ( InitializationException e )
         {



Mime
View raw message