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 2007/03/23 16:28:42 UTC
svn commit: r521797 - in
/incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl:
BaseCompiler.java RubyCompiler.java
Author: sisbell
Date: Fri Mar 23 09:28:42 2007
New Revision: 521797
URL: http://svn.apache.org/viewvc?view=rev&rev=521797
Log:
Some compilers.
Added:
incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/BaseCompiler.java (with props)
incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/RubyCompiler.java (with props)
Added: incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/BaseCompiler.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/BaseCompiler.java?view=auto&rev=521797
==============================================================================
--- incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/BaseCompiler.java (added)
+++ incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/BaseCompiler.java Fri Mar 23 09:28:42 2007
@@ -0,0 +1,97 @@
+package org.apache.maven.dotnet.executable.compiler.impl;
+
+import org.apache.maven.dotnet.executable.compiler.CompilerContext;
+import org.apache.maven.dotnet.executable.compiler.InvalidArtifactException;
+import org.apache.maven.dotnet.executable.compiler.CompilerExecutable;
+import org.apache.maven.dotnet.executable.ExecutionException;
+import org.apache.maven.dotnet.executable.CommandExecutor;
+import org.apache.maven.dotnet.NMavenContext;
+import org.codehaus.plexus.logging.Logger;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ *
+ */
+abstract class BaseCompiler implements CompilerExecutable
+{
+ protected CompilerContext compilerContext;
+
+ protected Logger logger;
+
+ /**
+ * This method may be overridden if the developer needs to create a profile of one of the other compilers.
+ */
+ public void init( NMavenContext nmavenContext )
+ {
+ this.compilerContext = (CompilerContext) nmavenContext;
+ this.logger = nmavenContext.getLogger();
+ }
+
+ public File getCompiledArtifact()
+ throws InvalidArtifactException
+ {
+ File file = compilerContext.getArtifact();
+ if ( !file.exists() )
+ {
+ throw new InvalidArtifactException(
+ "NMAVEN-068-004: Artifact does not exist: Artifact = " + file.getAbsolutePath() );
+ }
+ return file;
+ }
+
+ public String getExecutable()
+ throws ExecutionException
+ {
+ if ( compilerContext == null )
+ {
+ throw new ExecutionException( "NMAVEN-068-001: Compiler has not been initialized with a context" );
+ }
+ return compilerContext.getCompilerCapability().getExecutable();
+ }
+
+ public File getExecutionPath()
+ {
+ String executable;
+ try
+ {
+ executable = getExecutable();
+ }
+ catch ( ExecutionException e )
+ {
+ return null;
+ }
+ List<String> executablePaths = compilerContext.getNetCompilerConfig().getExecutionPaths();
+ if ( executablePaths != null )
+ {
+ for ( String executablePath : executablePaths )
+ {
+ File exe = new File( executablePath + File.separator + executable);
+ if ( exe.exists() )
+ {
+ return new File(executablePath);
+ }
+ }
+ }
+ return null;
+ }
+
+ public void execute()
+ throws ExecutionException
+ {
+ if ( !( new File( compilerContext.getSourceDirectoryName() ).exists() ) )
+ {
+ logger.info( "NMAVEN-068-002: No source files to compile." );
+ return;
+ }
+ logger.info( "NMAVEN-068-003: Compiling Artifact: Vendor = " +
+ compilerContext.getCompilerRequirement().getVendor() + ", Language = " +
+ compilerContext.getCompilerRequirement().getVendor() + ", Assembly Name = " +
+ compilerContext.getArtifact().getAbsolutePath() );
+
+ CommandExecutor commandExecutor = CommandExecutor.Factory.createDefaultCommmandExecutor();
+ commandExecutor.setLogger( logger );
+ commandExecutor.executeCommand( getExecutable(), getCommands(), getExecutionPath(), failOnErrorOutput() );
+ }
+}
Propchange: incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/BaseCompiler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/RubyCompiler.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/RubyCompiler.java?view=auto&rev=521797
==============================================================================
--- incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/RubyCompiler.java (added)
+++ incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/RubyCompiler.java Fri Mar 23 09:28:42 2007
@@ -0,0 +1,50 @@
+package org.apache.maven.dotnet.executable.compiler.impl;
+
+import org.apache.maven.dotnet.executable.ExecutionException;
+import org.apache.maven.dotnet.executable.compiler.CompilerConfig;
+import org.apache.maven.dotnet.vendor.Vendor;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.File;
+
+public final class RubyCompiler
+ extends BaseCompiler
+{
+ public boolean failOnErrorOutput()
+ {
+ //MONO writes warnings to standard error: this turns off failing builds on warnings for MONO
+ return !compilerContext.getCompilerRequirement().getVendor().equals( Vendor.MONO );
+ }
+
+ public List<String> getCommands()
+ throws ExecutionException
+ {
+ if ( compilerContext == null )
+ {
+ throw new ExecutionException( "NMAVEN-068-000: Compiler has not been initialized with a context" );
+ }
+ List<String> commands = new ArrayList<String>();
+
+ CompilerConfig config = compilerContext.getNetCompilerConfig();
+ String sourceDirectory = compilerContext.getSourceDirectoryName();
+ File srcDir = new File( sourceDirectory );
+ commands.add( "--" + config.getArtifactType().getExtension() );
+ for ( String command : config.getCommands() )
+ {
+ if ( command.startsWith( "main:" ) )
+ { String className = command.split( "[:]" )[1];
+ File classFile = new File("target/build-sources/" + className);
+ commands.add( "'" + classFile.getAbsolutePath() + "'");
+ }
+ else
+ {
+ commands.add( command );
+ }
+ }
+ // commands.add("-Cdirectory");
+ // commands.add();
+ //commands.addAll( config.getCommands() );
+ return commands;
+ }
+}
Propchange: incubator/nmaven/branches/SI_RUBY/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/RubyCompiler.java
------------------------------------------------------------------------------
svn:eol-style = native