You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by lc...@apache.org on 2011/12/15 17:07:13 UTC
svn commit: r1214869 [2/11] - in /incubator/npanday/trunk: ./
archetypes/maven-archetype-netexecutable/src/main/resources/archetype-resources/src/main/java/
components/ components/dotnet-artifact/
components/dotnet-artifact/src/main/java/npanday/artifa...
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java Thu Dec 15 17:07:06 2011
@@ -19,34 +19,22 @@
package npanday.executable;
import npanday.PathUtil;
-
import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.cli.*;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.DefaultConsumer;
+import org.codehaus.plexus.util.cli.StreamConsumer;
-import org.codehaus.plexus.util.Os;
-import org.codehaus.plexus.util.StringUtils;
-//import org.codehaus.plexus.util.cli.shell.BourneShell;
-//import org.codehaus.plexus.util.cli.shell.CmdShell;
-//import org.codehaus.plexus.util.cli.shell.CommandShell;
-import org.codehaus.plexus.util.cli.shell.Shell;
+import java.io.File;
import java.io.IOException;
-
-
-
-import java.util.List;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
-import java.io.File;
-
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Vector;
-
-
-import java.lang.reflect.*;
/**
@@ -197,109 +185,112 @@ public interface CommandExecutor
Commandline commandline = new Commandline()
{
- protected Map envVars = Collections.synchronizedMap( new LinkedHashMap() );
+ protected Map envVars = Collections.synchronizedMap( new LinkedHashMap() );
+
+
+ public Process execute()
+ throws CommandLineException
+ {
+ // TODO: Provided only for backward compat. with <= 1.4
+ //verifyShellState();
+
+ Process process;
+
+ //addEnvironment( "MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE" );
+
+ String[] environment = getEnvironmentVariables();
+
+ File workingDir = getWorkingDirectory();
+
+ try
+ {
+ String[] cmd = getEscapedShellCommandline();
+
+ if ( workingDir == null )
+ {
+ process = Runtime.getRuntime().exec( cmd, environment );
+ }
+ else
+ {
+ if ( !workingDir.exists() )
+ {
+ throw new CommandLineException(
+ "NPANDAY-040-010: Working directory \"" + workingDir.getPath()
+ + "\" does not exist!" );
+ }
+ else if ( !workingDir.isDirectory() )
+ {
+ throw new CommandLineException(
+ "NPANDAY-040-009: Path \"" + workingDir.getPath()
+ + "\" does not specify a directory." );
+ }
+
+ process = Runtime.getRuntime().exec( cmd, environment, workingDir );
+ }
+ }
+ catch ( IOException ex )
+ {
+ throw new CommandLineException( "NPANDAY-040-008: Error while executing process.", ex );
+ }
+
+ return process;
+ }
+ public String[] getEnvironmentVariables()
+ throws CommandLineException
+ {
+ try
+ {
+ addSystemEnvironment();
+ }
+ catch ( Exception e )
+ {
+ throw new CommandLineException(
+ "NPANDAY-040-007: Error setting up environmental variables", e );
+ }
+ String[] environmentVars = new String[envVars.size()];
+ int i = 0;
+ for ( Iterator iterator = envVars.keySet().iterator(); iterator.hasNext(); )
+ {
+ String name = (String) iterator.next();
+ String value = (String) envVars.get( name );
+ environmentVars[i] = name + "=" + value;
+ i++;
+ }
+ return environmentVars;
+ }
- public Process execute()
- throws CommandLineException
- {
- // TODO: Provided only for backward compat. with <= 1.4
- //verifyShellState();
-
- Process process;
-
- //addEnvironment( "MAVEN_TEST_ENVAR", "MAVEN_TEST_ENVAR_VALUE" );
-
- String[] environment = getEnvironmentVariables();
-
- File workingDir = getWorkingDirectory();
-
- try
- {
- String[] cmd = getEscapedShellCommandline();
-
- if ( workingDir == null )
- {
- process = Runtime.getRuntime().exec( cmd, environment );
- }
- else
- {
- if ( !workingDir.exists() )
- {
- throw new CommandLineException( "Working directory \"" + workingDir.getPath()
- + "\" does not exist!" );
- }
- else if ( !workingDir.isDirectory() )
- {
- throw new CommandLineException( "Path \"" + workingDir.getPath()
- + "\" does not specify a directory." );
- }
-
- process = Runtime.getRuntime().exec( cmd, environment, workingDir );
- }
- }
- catch ( IOException ex )
- {
- throw new CommandLineException( "Error while executing process.", ex );
- }
-
- return process;
- }
-
- public String[] getEnvironmentVariables()
- throws CommandLineException
- {
- try
- {
- addSystemEnvironment();
- }
- catch ( Exception e )
- {
- throw new CommandLineException( "Error setting up environmental variables", e );
- }
- String[] environmentVars = new String[envVars.size()];
- int i = 0;
- for ( Iterator iterator = envVars.keySet().iterator(); iterator.hasNext(); )
- {
- String name = (String) iterator.next();
- String value = (String) envVars.get( name );
- environmentVars[i] = name + "=" + value;
- i++;
- }
- return environmentVars;
- }
-
- public void addEnvironment( String name, String value )
- {
- //envVars.add( name + "=" + value );
- envVars.put( name, value );
- }
-
- /**
- * Add system environment variables
- */
- public void addSystemEnvironment()
- throws Exception
- {
- Properties systemEnvVars = CommandLineUtils.getSystemEnvVars();
-
- for ( Iterator i = systemEnvVars.keySet().iterator(); i.hasNext(); )
- {
- String key = (String) i.next();
- if ( !envVars.containsKey( key ) )
- {
- addEnvironment( key, systemEnvVars.getProperty( key ) );
- }
- }
+ public void addEnvironment( String name, String value )
+ {
+ //envVars.add( name + "=" + value );
+ envVars.put( name, value );
+ }
+
+ /**
+ * Add system environment variables
+ */
+ public void addSystemEnvironment()
+ throws Exception
+ {
+ Properties systemEnvVars = CommandLineUtils.getSystemEnvVars();
+
+ for ( Iterator i = systemEnvVars.keySet().iterator(); i.hasNext(); )
+ {
+ String key = (String) i.next();
+ if ( !envVars.containsKey( key ) )
+ {
+ addEnvironment( key, systemEnvVars.getProperty( key ) );
+ }
+ }
}
public String toString()
{
- StringBuffer strBuff = new StringBuffer("");
- for(String command : getEscapedShellCommandline())
+ StringBuffer strBuff = new StringBuffer( "" );
+ for ( String command : getEscapedShellCommandline() )
{
- strBuff.append(" ");
- strBuff.append(command);
+ strBuff.append( " " );
+ strBuff.append( command );
}
return strBuff.toString();
}
@@ -307,7 +298,8 @@ public interface CommandExecutor
public String[] getEscapedShellCommandline()
{
String[] scl = getShellCommandline();
- for ( int i = 0; i < scl.length; i++ ) {
+ for ( int i = 0; i < scl.length; i++ )
+ {
scl[i] = escapeCmdParams( scl[i] );
}
return scl;
@@ -315,26 +307,28 @@ public interface CommandExecutor
// escaped to make use of dotnet style of command escapes .
// Eg. /define:"CONFIG=\"Debug\",DEBUG=-1,TRACE=-1,_MyType=\"Windows\",PLATFORM=\"AnyCPU\""
- private String escapeCmdParams(String param)
+ private String escapeCmdParams( String param )
{
- if(param == null)
+ if ( param == null )
+ {
return null;
+ }
String str = param;
- if(param.startsWith("/") && param.indexOf(":") > 0)
+ if ( param.startsWith( "/" ) && param.indexOf( ":" ) > 0 )
{
- int delem = param.indexOf(":") + 1;
- String command = param.substring(0, delem);
- String value = param.substring(delem);
+ int delem = param.indexOf( ":" ) + 1;
+ String command = param.substring( 0, delem );
+ String value = param.substring( delem );
- if(value.indexOf(" ") > 0 || value.indexOf("\"") > 0)
+ if ( value.indexOf( " " ) > 0 || value.indexOf( "\"" ) > 0 )
{
- value = "\"" + value.replaceAll("\"", "\\\\\"") + "\"";
+ value = "\"" + value.replaceAll( "\"", "\\\\\"" ) + "\"";
}
str = command + value;
}
- else if(param.startsWith("@"))
+ else if ( param.startsWith( "@" ) )
{
str = param;
}
@@ -347,41 +341,50 @@ public interface CommandExecutor
// On non-Windows platforms, such as Linux, "gmcs" not resolved
// to gmcs.exe in working directory due to /usr/bin/gmcs
// but "./gmcs.exe" resolved as desired in working directory
- String osName = System.getProperty("os.name");
- if (!osName.toLowerCase().contains("win"))
+ String osName = System.getProperty( "os.name" );
+ if ( !osName.toLowerCase().contains( "win" ) )
{
- File executableFile = PathUtil.getExecutable(workingDirectory, executable);
+ File executableFile = PathUtil.getExecutable( workingDirectory, executable );
// do not prefix for internal commands, such as mkdir
- if (executableFile != null && workingDirectory.equals(executableFile.getParentFile()))
+ if ( executableFile != null && workingDirectory.equals( executableFile.getParentFile() ) )
{
- executable = new File("./", executableFile.getName()).toString();
+ executable = new File( "./", executableFile.getName() ).toString();
}
}
commandline.setExecutable( executable );
- commandline.addArguments( commands.toArray( new String[commands.size()]));
+ commandline.addArguments( commands.toArray( new String[commands.size()] ) );
if ( workingDirectory != null && workingDirectory.exists() )
{
+ // TODO: Wrong use of working directory! $(basedir) should be the working dir, and the executable paths should be absolute
commandline.setWorkingDirectory( workingDirectory.getAbsolutePath() );
}
+ else
+ {
+ logger.info( "NPANDAY-040-006: Did not find executable path, will try system path" );
+ }
+
try
{
result = CommandLineUtils.executeCommandLine( commandline, stdOut, stdErr );
if ( logger != null )
{
- logger.debug( "NPANDAY-040-000: Executed command: Commandline = " + commandline +
- ", Result = " + result );
+ logger.debug(
+ "NPANDAY-040-005: Executed command: Commandline = " + commandline + ", Result = "
+ + result );
}
else
{
- System.out.println( "NPANDAY-040-000: Executed command: Commandline = " + commandline +
- ", Result = " + result );
+ System.out.println(
+ "NPANDAY-040-004: Executed command: Commandline = " + commandline + ", Result = "
+ + result );
}
if ( ( failsOnErrorOutput && stdErr.hasError() ) || result != 0 )
{
- throw new ExecutionException( "NPANDAY-040-001: Could not execute: Command = " +
- commandline.toString() + ", Result = " + result );
+ throw new ExecutionException(
+ "NPANDAY-040-001: Could not execute: Command = " + commandline.toString()
+ + ", Result = " + result );
}
}
catch ( CommandLineException e )
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandFilter.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandFilter.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandFilter.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandFilter.java Thu Dec 15 17:07:06 2011
@@ -20,12 +20,11 @@ package npanday.executable;
import org.codehaus.plexus.logging.Logger;
+import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import java.io.File;
-import npanday.executable.CommandCapability;
-
/**
* Provides services for filtering command options. A <code>NetExecutable</code> or
* <code>CompilerExecutable</code> implementation can use the services of this interface for filtering out commands that
@@ -40,11 +39,12 @@ public interface CommandFilter
/**
* Filters the commands.
*
+ *
* @param commands the commands to filter. This parameter should not be null and will throw a
* <code>NullPointerException</code> if it is.
* @return a list of filtered commands.
*/
- List<String> filter( List<String> commands );
+ List<String> filter( Collection<String> commands );
/**
* Provides factory methods for creating command filters.
@@ -73,7 +73,7 @@ public interface CommandFilter
{
return new CommandFilter()
{
- public List<String> filter( List<String> commands )
+ public List<String> filter( Collection<String> commands )
{
List<String> includes = ( capability != null && capability.getIncludes() != null )
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java Thu Dec 15 17:07:06 2011
@@ -18,8 +18,7 @@
*/
package npanday.executable;
-import npanday.vendor.Vendor;
-import npanday.executable.compiler.CompilerCapability;
+import npanday.vendor.VendorInfo;
import java.util.List;
@@ -47,14 +46,6 @@ public interface ExecutableCapability
CommandCapability getCommandCapability();
/**
- * Sets the command options that the executable is capable of supporting.
- *
- * @param commandCapability the command capability, which is used to determine the command line parameters that
- * the executable supports.
- */
- void setCommandCapability( CommandCapability commandCapability );
-
- /**
* Returns the ID for this capability.
*
* @return the ID for this capability
@@ -62,25 +53,11 @@ public interface ExecutableCapability
String getIdentifier();
/**
- * Sets the ID for this capability.
- *
- * @param identifier the ID of the capability
- */
- void setIdentifier( String identifier );
-
- /**
- * Returns the vendor capability of the executable: currently only - MS, MONO, DotGNU
+ * Returns the vendor capability of the executable
*
* @return the vendor capability of the executable
*/
- Vendor getVendor();
-
- /**
- * Sets the vendor capability of the executable: currently only - MS, MONO, DotGNU
- *
- * @param vendor
- */
- void setVendor( Vendor vendor );
+ VendorInfo getVendorInfo();
/**
* Returns the supported profile. A profile is used to differentiate a capability beyond the standard
@@ -91,14 +68,6 @@ public interface ExecutableCapability
String getProfile();
/**
- * Sets the supported profile. A profile is used to differentiate a capability beyond the standard
- * vendor/OS/profile/frameworkVersion parameters.
- *
- * @param profile the profile of the executable.
- */
- void setProfile( String profile );
-
- /**
* Returns the operating system that the executable is capable of supporting.
*
* @return the operating system that the executable is capable of supporting
@@ -106,13 +75,6 @@ public interface ExecutableCapability
String getOperatingSystem();
/**
- * Sets the operating system that the executable is capable of supporting.
- *
- * @param operatingSystem
- */
- void setOperatingSystem( String operatingSystem );
-
- /**
* Returns the architecture that the executable is capable of supporting.
*
* @return the architecture that the executable is capable of supporting
@@ -120,13 +82,6 @@ public interface ExecutableCapability
String getArchitecture();
/**
- * Sets the architecture that the executable is capable of supporting.
- *
- * @param architecture the architecture that the executable is capable of supporting
- */
- void setArchitecture( String architecture );
-
- /**
* Returns a list of all .NET frameworks versions that the executable is capable of supporting.
*
* @return a list of all .NET frameworks versions that the executable is capable of supporting
@@ -134,25 +89,11 @@ public interface ExecutableCapability
List<String> getFrameworkVersions();
/**
- * Sets a list of all .NET frameworks versions that the executable is capable of supporting.
- *
- * @param frameworkVersions a list of all .NET frameworks versions that the executable is capable of supporting
- */
- void setFrameworkVersions( List<String> frameworkVersions );
-
- /**
* Returns the executable as it is given on the commandline.
*
* @return the executable as it is given on the commandline
*/
- String getExecutable();
-
- /**
- * Sets the executable as it is given on the commandline.
- *
- * @param executable the executable as it is given on the commandline
- */
- void setExecutable( String executable );
+ String getExecutableName();
/**
* Returns the class name of the executable plugin that knows how to handle the execution request.
@@ -162,13 +103,6 @@ public interface ExecutableCapability
String getPluginClassName();
/**
- * Sets the class name of the executable plugin that knows how to handle the execution request.
- *
- * @param pluginClassName the class name of the executable plugin that knows how to handle the execution request
- */
- void setPluginClassName( String pluginClassName );
-
- /**
* Returns the net dependency id (within the net-dependencies.xml file).
*
* @return the net dependency id
@@ -176,223 +110,8 @@ public interface ExecutableCapability
String getNetDependencyId();
/**
- * Sets the net dependency id.
- *
- * @param netDependencyId
- */
- void setNetDependencyId(String netDependencyId);
-
- /**
- * Provides factory services for creating a default instance of the executable capability.
+ * Retrieves the paths, the executable is most likely to be found on.
*/
- public static class Factory
- {
- /**
- * Default constructor
- */
- private Factory()
- {
- }
-
- /**
- * Returns a default instance of the executable capability.
- *
- * @return a default instance of the executable capability
- */
- public static ExecutableCapability createDefaultExecutableCapability()
- {
- return new CompilerCapability()
- {
-
- private Vendor vendor;
-
- private String language;
-
- private String operatingSystem;
-
- private String architecture;
-
- private boolean hasJustInTime;
-
- private String pluginClassName;
-
- private String executable;
-
- private String identifier;
-
- private CommandCapability commandCapability;
-
- private List<String> frameworkVersions;
-
- private List<String> coreAssemblies;
-
- private String profile;
-
- private String assemblyPath;
-
- private String netDependencyId;
-
- private String targetFramework;
-
- public String getAssemblyPath()
- {
- return assemblyPath;
- }
-
- public void setAssemblyPath( String assemblyPath )
- {
- this.assemblyPath = assemblyPath;
- }
-
- public String getProfile()
- {
- return profile;
- }
-
- public void setProfile( String profile )
- {
- this.profile = profile;
- }
-
- public List<String> getCoreAssemblies()
- {
- return coreAssemblies;
- }
-
- public void setCoreAssemblies( List<String> coreAssemblies )
- {
- this.coreAssemblies = coreAssemblies;
- }
-
- public List<String> getFrameworkVersions()
- {
- return frameworkVersions;
- }
-
- public void setFrameworkVersions( List<String> frameworkVersions )
- {
- this.frameworkVersions = frameworkVersions;
- }
-
- public String getIdentifier()
- {
- return identifier;
- }
-
- public void setIdentifier( String identifier )
- {
- this.identifier = identifier;
- }
-
- public String getExecutable()
- {
- return executable;
- }
-
- public void setExecutable( String executable )
- {
- this.executable = executable;
- }
-
- public Vendor getVendor()
- {
- return vendor;
- }
-
- public void setVendor( Vendor vendor )
- {
- this.vendor = vendor;
- }
-
- public String getLanguage()
- {
- return language;
- }
-
- public void setLanguage( String language )
- {
- this.language = language;
- }
-
- public String getTargetFramework()
- {
- return targetFramework;
- }
-
- public void setTargetFramework( String targetFramework )
- {
- this.targetFramework = targetFramework;
- }
-
- public String getOperatingSystem()
- {
- return operatingSystem;
- }
-
- public void setOperatingSystem( String operatingSystem )
- {
- this.operatingSystem = operatingSystem;
- }
-
- public String getArchitecture()
- {
- return architecture;
- }
-
- public void setArchitecture( String architecture )
- {
- this.architecture = architecture;
- }
-
- public boolean isHasJustInTime()
- {
- return hasJustInTime;
- }
-
- public void setHasJustInTime( boolean hasJustInTime )
- {
- this.hasJustInTime = hasJustInTime;
- }
-
-
- public String getPluginClassName()
- {
- return pluginClassName;
- }
-
- public void setPluginClassName( String pluginClassName )
- {
- this.pluginClassName = pluginClassName;
- }
-
- public CommandCapability getCommandCapability()
- {
- return commandCapability;
- }
-
-
- public void setCommandCapability( CommandCapability commandCapability )
- {
- this.commandCapability = commandCapability;
- }
-
- public String getNetDependencyId()
- {
- return netDependencyId;
- }
-
- public void setNetDependencyId( String executableLocation )
- {
- this.netDependencyId = executableLocation;
- }
-
- public String toString()
- {
- return "ID = " + identifier + ", Plugin Class: " + pluginClassName + ", OS = " + operatingSystem +
- ", Language = " + language + ", Vendor = " + vendor;
- }
- };
- }
- }
-
+ List<String> getProbingPaths();
}
+
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableConfig.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableConfig.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableConfig.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableConfig.java Thu Dec 15 17:07:06 2011
@@ -18,12 +18,7 @@
*/
package npanday.executable;
-import npanday.executable.compiler.CompilerConfig;
-import npanday.ArtifactType;
-import npanday.executable.compiler.KeyInfo;
-
import java.util.List;
-import java.io.File;
/**
* User-defined configuration information for an executable or compiler.
@@ -31,22 +26,31 @@ import java.io.File;
* @author Shane Isbell
* @see RepositoryExecutableContext
*/
-public interface ExecutableConfig
+public class ExecutableConfig
{
+ private List<String> commands;
+
+ private List<String> executionPaths;
/**
* The commands to pass to the executable plugin.
*
* @return the commands to pass to the executable plugin
*/
- List<String> getCommands();
+ public List<String> getCommands()
+ {
+ return commands;
+ }
/**
* Sets commands to pass to the executable plugin.
*
* @param commands the user-defined commands to pass to the executable plugin
*/
- void setCommands( List<String> commands );
+ public void setCommands( List<String> commands )
+ {
+ this.commands = commands;
+ }
/**
* The execution path of the executable. This can be an absolute path to the executable or just the name of the
@@ -54,132 +58,18 @@ public interface ExecutableConfig
*
* @return the execution path of the executable
*/
- List<String> getExecutionPaths();
+ public List<String> getExecutionPaths()
+ {
+ return executionPaths;
+ }
/**
* Sets the executation path of the executable.
*
* @param executionPaths the execution paths
*/
- void setExecutionPaths( List<String> executionPaths );
-
- public static class Factory
+ public void setExecutionPaths( List<String> executionPaths )
{
- /**
- * Constructor
- */
- private Factory()
- {
- }
-
- /**
- * Returns a default instance of the executable config.
- *
- * @return a default instance of the executable config
- */
- public static ExecutableConfig createDefaultExecutableConfig()
- {
- return new CompilerConfig()
- {
- private KeyInfo keyInfo;
-
- private List<String> commands;
-
- private List<String> executionPaths;
-
- private ArtifactType artifactType;
-
- private boolean isTestCompile = false;
-
- private File localRepository;
-
- private List<String> includeSources;
-
-
- private File outputDirectory;
-
-
- public File getOutputDirectory()
- {
- return outputDirectory;
- }
-
- public void setOutputDirectory(File outputDirectory)
- {
- this.outputDirectory = outputDirectory;
- }
-
-
- public void setIncludeSources(List<String> includeSources)
- {
- this.includeSources = includeSources;
- }
-
- public List<String> getIncludeSources()
- {
- return this.includeSources;
- }
-
- public List<String> getCommands()
- {
- return commands;
- }
-
- public void setCommands( List<String> commands )
- {
- this.commands = commands;
- }
-
- public List<String> getExecutionPaths()
- {
- return executionPaths;
- }
-
- public void setExecutionPaths( List<String> executionPaths )
- {
- this.executionPaths = executionPaths;
- }
-
- public ArtifactType getArtifactType()
- {
- return artifactType;
- }
-
- public void setArtifactType( ArtifactType artifactType )
- {
- this.artifactType = artifactType;
- }
-
- public boolean isTestCompile()
- {
- return isTestCompile;
- }
-
- public void setTestCompile( boolean testCompile )
- {
- isTestCompile = testCompile;
- }
-
- public File getLocalRepository()
- {
- return localRepository;
- }
-
- public void setLocalRepository( File localRepository )
- {
- this.localRepository = localRepository;
- }
-
- public KeyInfo getKeyInfo()
- {
- return keyInfo;
- }
-
- public void setKeyInfo(KeyInfo keyInfo) {
- this.keyInfo = keyInfo;
- }
- };
- }
+ this.executionPaths = executionPaths;
}
-
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableContext.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableContext.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableContext.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableContext.java Thu Dec 15 17:07:06 2011
@@ -20,6 +20,9 @@ package npanday.executable;
import npanday.NPandayContext;
import npanday.PlatformUnsupportedException;
+import npanday.vendor.Vendor;
+
+import java.util.Collection;
/**
* Provides services for executables.
@@ -40,46 +43,47 @@ public interface ExecutableContext
throws ExecutionException;
/**
- * Creates a command filter. If the includes parameter is null, then the filter will return all commands that are
- * not in the exlude filters. If the excludes parameter is null, then the filter will only return what is in the
- * includes list. If both parameters are null...
- *
- * @return the command filter associated with this context
+ * The vendor the executable runs for.
*/
- CommandFilter getCommandFilter();
+ Vendor getVendor();
/**
- * Returns the capabilities of the executable associated with this context.
+ * Returns the exectuable name to be run.
*
- * @return the capabilities of the executable associated with this context
+ * @return
*/
- ExecutableCapability getExecutableCapability();
+ String getExecutableName();
/**
- * Returns the user-defined requirements associated with this context.
- *
- * @return the user-defined requirements associated with this context
+ * The commands that instruct the executable to be run.
+ * @return
+ */
+ Collection<String> getCommands();
+
+ /**
+ * The paths the executable is most likely to be found on. First matching path wins.
+ * @return
*/
- ExecutableRequirement getExecutableRequirement();
+ Collection<String> getProbingPaths();
/**
- * Returns user-defined configuration used to initialize this context.
+ * Creates a command filter. If the includes parameter is null, then the filter will return all commands that are
+ * not in the exlude filters. If the excludes parameter is null, then the filter will only return what is in the
+ * includes list. If both parameters are null...
*
- * @return user-defined configuration used to initialize this context
+ * @return the command filter associated with this context
*/
- ExecutableConfig getExecutableConfig();
+ CommandFilter getCommandFilter();
+
/**
* Initializes the context
*
- * @param executableRequirement
- * @param executableConfig
- * @param capabilityMatcher
+ * @param capability
+ * @param config
* @throws npanday.PlatformUnsupportedException
*
*/
- void init( ExecutableRequirement executableRequirement, ExecutableConfig executableConfig,
- CapabilityMatcher capabilityMatcher )
+ void init( ExecutableCapability capability, ExecutableConfig config )
throws PlatformUnsupportedException;
-
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java Thu Dec 15 17:07:06 2011
@@ -19,133 +19,42 @@
package npanday.executable;
import npanday.vendor.Vendor;
+import npanday.vendor.VendorRequirement;
/**
* Requirements that the executable plugin must satisfy to be used in the build.
*
* @author Shane Isbell
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ *
* @see ExecutableCapability
* @see CapabilityMatcher
*/
-public interface ExecutableRequirement
+public class ExecutableRequirement
+ extends VendorRequirement
{
- /**
- * Returns required framework version under which the executable runs.
- *
- * @return required framework version under which the executable runs
- */
- String getFrameworkVersion();
-
- /**
- * Sets required framework version.
- *
- * @param frameworkVersion
- */
- void setFrameworkVersion( String frameworkVersion );
-
- /**
- * Returns required profile of the executable.
- *
- * @return required profile of the executable
- */
- String getProfile();
-
- /**
- * Sets required profile of the executable
- *
- * @param profile
- */
- void setProfile( String profile );
-
- /**
- * Returns required vendor of executable
- *
- * @return required vendor of executable
- */
- Vendor getVendor();
-
- /**
- * Sets required vendor of executable
- *
- * @param vendor
- */
- void setVendor( Vendor vendor );
-
- void setVendorVersion( String vendorVersion );
-
- String getVendorVersion();
-
- /**
- * Provides factory services for creating a default instance of the executable requirement.
- */
- public static class Factory
+
+ private String profile;
+
+ public ExecutableRequirement( String vendorName, String vendorVersion, String frameworkVersion, String profile )
+ {
+ super( vendorName, vendorVersion, frameworkVersion );
+ this.profile = profile;
+ }
+
+ public ExecutableRequirement( Vendor vendor, String vendorVersion, String frameworkVersion, String profile )
{
+ super( vendor, vendorVersion, frameworkVersion );
+ this.profile = profile;
+ }
- /**
- * Default constructor
- */
- private Factory()
- {
- }
-
- /**
- * Creates a default implementation of an executable requirements.
- *
- * @return a default implementation of an executable requirements
- */
- public static ExecutableRequirement createDefaultExecutableRequirement()
- {
- return new ExecutableRequirement()
- {
- private String frameworkVersion;
-
- private Vendor vendor;
-
- private String profile;
-
- private String vendorVersion;
-
- public String getVendorVersion()
- {
- return vendorVersion;
- }
-
- public void setVendorVersion( String vendorVersion )
- {
- this.vendorVersion = vendorVersion;
- }
-
- public String getFrameworkVersion()
- {
- return frameworkVersion;
- }
-
- public void setFrameworkVersion( String frameworkVersion )
- {
- this.frameworkVersion = frameworkVersion;
- }
-
- public Vendor getVendor()
- {
- return vendor;
- }
-
- public void setVendor( Vendor vendor )
- {
- this.vendor = vendor;
- }
-
- public String getProfile()
- {
- return profile;
- }
-
- public void setProfile( String profile )
- {
- this.profile = profile;
- }
- };
+ public String getProfile()
+ {
+ return profile;
+ }
- }
+ public void setProfile( String profile )
+ {
+ this.profile = profile;
}
}
Added: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java?rev=1214869&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java (added)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java Thu Dec 15 17:07:06 2011
@@ -0,0 +1,147 @@
+package npanday.executable;
+
+import npanday.vendor.VendorInfo;
+
+import java.util.List;
+
+/**
+ * Holds the configured executable capability.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+// TODO: Refactor to be based on the configured plugins
+public class MutableExecutableCapability
+ implements ExecutableCapability
+{
+ protected VendorInfo vendorInfo;
+
+ protected String operatingSystem;
+
+ private String architecture;
+
+ protected String pluginClassName;
+
+ private String executable;
+
+ protected String identifier;
+
+ private CommandCapability commandCapability;
+
+ private List<String> frameworkVersions;
+
+ private String profile;
+
+ private String netDependencyId;
+
+ private List<String> probingPaths;
+
+ public String getProfile()
+ {
+ return profile;
+ }
+
+ public void setProfile( String profile )
+ {
+ this.profile = profile;
+ }
+
+ public List<String> getFrameworkVersions()
+ {
+ return frameworkVersions;
+ }
+
+ public void setFrameworkVersions( List<String> frameworkVersions )
+ {
+ this.frameworkVersions = frameworkVersions;
+ }
+
+ public String getIdentifier()
+ {
+ return identifier;
+ }
+
+ public void setIdentifier( String identifier )
+ {
+ this.identifier = identifier;
+ }
+
+ public String getExecutableName()
+ {
+ return executable;
+ }
+
+ public void setExecutableName( String executableName )
+ {
+ this.executable = executableName;
+ }
+
+ public VendorInfo getVendorInfo()
+ {
+ return vendorInfo;
+ }
+
+ public void setVendorInfo( VendorInfo vendorInfo )
+ {
+ this.vendorInfo = vendorInfo;
+ }
+
+ public String getOperatingSystem()
+ {
+ return operatingSystem;
+ }
+
+ public void setOperatingSystem( String operatingSystem )
+ {
+ this.operatingSystem = operatingSystem;
+ }
+
+ public String getArchitecture()
+ {
+ return architecture;
+ }
+
+ public void setArchitecture( String architecture )
+ {
+ this.architecture = architecture;
+ }
+
+ public String getPluginClassName()
+ {
+ return pluginClassName;
+ }
+
+ public void setPluginClassName( String pluginClassName )
+ {
+ this.pluginClassName = pluginClassName;
+ }
+
+ public CommandCapability getCommandCapability()
+ {
+ return commandCapability;
+ }
+
+ public void setCommandCapability( CommandCapability commandCapability )
+ {
+ this.commandCapability = commandCapability;
+ }
+
+ public String getNetDependencyId()
+ {
+ return netDependencyId;
+ }
+
+ public void setNetDependencyId( String executableLocation )
+ {
+ this.netDependencyId = executableLocation;
+ }
+
+ public List<String> getProbingPaths()
+ {
+ return probingPaths;
+ }
+
+ public void setProbingPaths( List<String> probingPaths )
+ {
+ this.probingPaths = probingPaths;
+ }
+}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutable.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutable.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutable.java Thu Dec 15 17:07:06 2011
@@ -78,7 +78,7 @@ public interface NetExecutable
File getExecutionPath();
/**
- * Initialize this compiler.
+ * Initialize this executable.
*
* @param npandayContext
*/
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java Thu Dec 15 17:07:06 2011
@@ -18,17 +18,16 @@
*/
package npanday.executable;
-import org.apache.maven.project.MavenProject;
-
-import java.util.List;
-import java.io.File;
-
-import npanday.vendor.VendorInfo;
-import npanday.executable.compiler.CompilerRequirement;
+import npanday.PlatformUnsupportedException;
import npanday.executable.compiler.CompilerConfig;
import npanday.executable.compiler.CompilerExecutable;
-import npanday.PlatformUnsupportedException;
+import npanday.executable.compiler.CompilerRequirement;
+import npanday.vendor.VendorRequirement;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.util.List;
/**
* Provides services to obtain executables. This interface is intended to be used by <code>AbstractMojo</code>
@@ -48,18 +47,15 @@ public interface NetExecutableFactory
* Returns an executable that matches the vendor, framework version and profile. These are typically framework-vendor
* executables.
*
- * @param vendor the vendor of the executable
- * @param frameworkVersion the version of the .NET framework that the executable works under
- * @param profile the profile of the executable plugin. This is used to differentiate an executable that
- * matches the same platform and framework version.
+ *
+ * @param executableRequirement
* @param commands the user-defined command options to use with the executable
* @param netHome the install root of the .NET framework
* @return the executable that matches the vendor, framework version and profile
* @throws npanday.PlatformUnsupportedException
* if no executable is found
*/
- NetExecutable getNetExecutableFor( String vendor, String frameworkVersion, String profile, List<String> commands,
- File netHome )
+ NetExecutable getNetExecutableFor( ExecutableRequirement executableRequirement, List<String> commands, File netHome )
throws PlatformUnsupportedException;
/**
@@ -68,7 +64,7 @@ public interface NetExecutableFactory
*
* @param groupId the group ID of the executable artifact (as specified within the maven repo)
* @param artifactId the artifact ID of the executable artifact (as specified within the maven repo)
- * @param vendorInfo the additional vendor information used to decide how to execute the net executable
+ * @param vendorRequirement
* @param localRepository the local maven repository where the executable resides.
* @param isIsolatedAppDomain the executable can load up assemblies into an isolated application domain. This should
* be set to true if the application needs to load up assemblies into another app domain
@@ -78,19 +74,9 @@ public interface NetExecutableFactory
* @return the executable that resides within a maven repository.
* @throws PlatformUnsupportedException if no executable is found
*/
- NetExecutable getNetExecutableFromRepository( String groupId, String artifactId, VendorInfo vendorInfo,
- File localRepository, List<String> commands,
- boolean isIsolatedAppDomain, File targetDir )
- throws PlatformUnsupportedException;
-
- /**
- *
- * @param vendorInfo
- * @param commands
- * @return
- * @throws PlatformUnsupportedException
- */
- NetExecutable getJavaExecutableFromRepository( VendorInfo vendorInfo, List<String> commands )
+ NetExecutable getNetExecutableFromRepository( String groupId, String artifactId,
+ VendorRequirement vendorRequirement, File localRepository,
+ List<String> commands, boolean isIsolatedAppDomain, File targetDir )
throws PlatformUnsupportedException;
/**
@@ -99,36 +85,30 @@ public interface NetExecutableFactory
* @param compilerRequirement the requirements for the compiler
* @param compilerConfig the configuration for the compiler
* @param project the maven project
- * @param assemblyPath an optional parameter for replacing the system assemblies
* @return the executable for compiling .NET applications
* @throws npanday.PlatformUnsupportedException
* if no executable is found
*/
CompilerExecutable getCompilerExecutableFor( CompilerRequirement compilerRequirement, CompilerConfig compilerConfig,
- MavenProject project, File assemblyPath )
+ MavenProject project )
throws PlatformUnsupportedException;
/**
* Returns a plugin loader for loading and executing a .NET plugin.
*
- *
- * @param groupId the group ID of the executable artifact (as specified within the maven repo)
- * @param artifactId the artifact ID of the executable artifact (as specified within the maven repo)
- * @param vendorInfo the additional vendor information used to decide how to execute the net executable
- * @param localRepository the local maven repository where the executable resides.
- * @param parameterFile the file containing parameter information to inject into the .NET plugin
- * @param mojoName the name of the .NET Mojo implementation
+ * @param artifact the executable artifact
+ * @param vendorRequirement
+ * @param localRepository the local maven repository where the executable resides.
+ * @param parameterFile the file containing parameter information to inject into the .NET plugin
+ * @param mojoName the name of the .NET Mojo implementation
* @param targetDir
* @return the plugin loader for executing a .NET plugin
* @throws PlatformUnsupportedException if no executable is found
*/
- NetExecutable getPluginLoaderFor( String groupId, String artifactId, VendorInfo vendorInfo, String localRepository,
- File parameterFile, String mojoName, File targetDir )
- throws PlatformUnsupportedException;
-
- NetExecutable getPluginLoaderFor( Artifact artifact, VendorInfo vendorInfo, String localRepository, File parameterFile, String mojoName,
- File targetDir ) throws PlatformUnsupportedException;
+ NetExecutable getPluginLoaderFor(
+ Artifact artifact, VendorRequirement vendorRequirement, String localRepository, File parameterFile,
+ String mojoName, File targetDir ) throws PlatformUnsupportedException;
Artifact getArtifactFor(String groupId, String artifactId) throws PlatformUnsupportedException;
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java Thu Dec 15 17:07:06 2011
@@ -20,6 +20,7 @@ package npanday.executable.compiler;
import npanday.executable.ExecutableCapability;
+import java.io.File;
import java.util.List;
/**
@@ -42,7 +43,7 @@ public interface CompilerCapability
*
* @return assemblyPath
*/
- String getAssemblyPath();
+ File getAssemblyPath();
/**
* Returns a list of core assemblies names. These assemblies do not contain the artifact extension (.dll), but may contain
@@ -78,7 +79,7 @@ public interface CompilerCapability
*
* @param assemblyPath
*/
- void setAssemblyPath( String assemblyPath );
+ void setAssemblyPath( File assemblyPath );
/**
* Sets the core assemblies. You may specify a path with the core assembly name, but do not give the extension (.dll),
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerConfig.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerConfig.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerConfig.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerConfig.java Thu Dec 15 17:07:06 2011
@@ -29,92 +29,155 @@ import java.util.List;
*
* @author Shane Isbell
*/
-public interface CompilerConfig
+public class CompilerConfig
extends ExecutableConfig
{
+ private KeyInfo keyInfo;
+
+ private ArtifactType artifactType;
+
+ private boolean isTestCompile = false;
+
+ private File localRepository;
+
+ private List<String> includeSources;
+
+ private File outputDirectory;
+
+ private File assemblyPath;
+
+
/**
* The target artifact for the compile: library, module, exe, winexe or nar.
*
* @return target artifact for the compile
*/
- ArtifactType getArtifactType();
+ public ArtifactType getArtifactType()
+ {
+ return artifactType;
+ }
/**
* Returns true if the compiler plugin should compile the test classes, otherwise returns false.
*
* @return true if the compiler plugin should compile the test classes, otherwise returns false.
*/
- boolean isTestCompile();
+ public boolean isTestCompile()
+ {
+ return isTestCompile;
+ }
/**
* Returns key info used for signing assemblies.
*
* @return key info used for signing assemblies
*/
- KeyInfo getKeyInfo();
+ public KeyInfo getKeyInfo()
+ {
+ return keyInfo;
+ }
/**
* Returns local repository
*
* @return local repository
*/
- File getLocalRepository();
+ public File getLocalRepository()
+ {
+ return localRepository;
+ }
/**
* Sets the artifact type for the compiler plugin: library, module, exe, winexe or nar
*
* @param artifactType
*/
- void setArtifactType( ArtifactType artifactType );
+ public void setArtifactType( ArtifactType artifactType )
+ {
+ this.artifactType = artifactType;
+ }
/**
* If true, tells the compiler to compile the test classes, otherwise tells the compiler to compile the main classes.
*
* @param testCompile
*/
- void setTestCompile( boolean testCompile );
+ public void setTestCompile( boolean testCompile )
+ {
+ this.isTestCompile = testCompile;
+ }
/**
* Sets local repository
*
* @param localRepository
*/
- void setLocalRepository( File localRepository );
+ public void setLocalRepository( File localRepository )
+ {
+ this.localRepository = localRepository;
+ }
/**
* Sets key info used for signing assemblies.
*
* @param keyInfo key info used for signing assemblies
*/
- void setKeyInfo(KeyInfo keyInfo);
-
-
+ public void setKeyInfo( KeyInfo keyInfo )
+ {
+ this.keyInfo = keyInfo;
+ }
+
+
/**
* Sets Include Sources
*
- * @param inlcude sources file List
+ * @param includeSources sources file List
*/
- void setIncludeSources(List<String> includeSources);
-
-
+ public void setIncludeSources( List<String> includeSources )
+ {
+ this.includeSources = includeSources;
+ }
+
/**
* Gets Include Sources
*/
- List<String> getIncludeSources();
-
-
+ public List<String> getIncludeSources()
+ {
+ return includeSources;
+ }
/**
* Gets Output Directory
*/
- File getOutputDirectory();
+ public File getOutputDirectory()
+ {
+ return outputDirectory;
+ }
/**
* Sets OutputDirectory
*
- * @param output directory
+ * @param outputDirectory output directory
*/
- void setOutputDirectory(File outputDirectory);
+ public void setOutputDirectory( File outputDirectory )
+ {
+ this.outputDirectory = outputDirectory;
+ }
+ /**
+ * Sets the path to find the default reference assemblies on.
+ */
+ public void setAssemblyPath( File assemblyPath )
+ {
+ this.assemblyPath = assemblyPath;
+ }
+
+ /**
+ * The path to find the default reference assemblies on.
+ */
+ public File getAssemblyPath()
+ {
+ return assemblyPath;
+ }
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerContext.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerContext.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerContext.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerContext.java Thu Dec 15 17:07:06 2011
@@ -18,15 +18,16 @@
*/
package npanday.executable.compiler;
+import npanday.ArtifactType;
+import npanday.PlatformUnsupportedException;
+import npanday.executable.CommandFilter;
+import npanday.executable.ExecutableContext;
+import npanday.executable.ExecutionException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
-import java.util.List;
import java.io.File;
-
-import npanday.executable.*;
-import npanday.NPandayContext;
-import npanday.PlatformUnsupportedException;
+import java.util.List;
/**
* Interface defining compiler services.
@@ -34,7 +35,7 @@ import npanday.PlatformUnsupportedExcept
* @author Shane Isbell
*/
public interface CompilerContext
- extends NPandayContext
+ extends ExecutableContext
{
/**
@@ -54,13 +55,6 @@ public interface CompilerContext
File getArtifact()
throws InvalidArtifactException;
- /**
- * Return the <code>CompilerCapability</code> associated with this context.
- *
- * @return the <code>CompilerCapability</code> associated with this context.
- */
- CompilerCapability getCompilerCapability();
-
/**
* Returns assembly names that should be referenced by the compiler. If the List is emtpy, then all core assemblies
@@ -103,21 +97,6 @@ public interface CompilerContext
List<Artifact> getModuleDependencies();
/**
- * Returns the user provided configuration associated to this context. This is a live copy, so any changes to the
- * config will be reflected during compilation.
- *
- * @return the user provided configuration associated to this context
- */
- CompilerConfig getNetCompilerConfig();
-
- /**
- * Requirements used to match the compiler plugin associated with this context.
- *
- * @return Requirements used to match the compiler plugin associated with this context.
- */
- CompilerRequirement getCompilerRequirement();
-
- /**
* Returns the source directory (or test source directory) path of the class files. These are defined in the pom.xml
* by the properties ${build.sourceDirectory} or ${build.testSourceDirectory}.
*
@@ -156,9 +135,12 @@ public interface CompilerContext
* or it may be a generated .resource file.
*
* @return a list of resources that the compiler should embed in the compiled assembly.
+ *
*/
List<File> getEmbeddedResources();
+ List<String> getEmbeddedResourceArgs();
+
/**
* Returns the icon that the assembly should display when viewed. Should not be used in conjunction with win32res.
*
@@ -174,17 +156,54 @@ public interface CompilerContext
List<File> getWin32Resources();
/**
+ * Gets the framework version of the current vendor used.
+ */
+ String getFrameworkVersion();
+
+ /**
+ * Returns the path to the core assemblies.
+ */
+ File getAssemblyPath();
+
+ /**
+ * Returns the framework to compile for.
+ */
+ String getTargetFramework();
+
+ /**
+ * Gets the profile the compiler runs with.
+ */
+ String getTargetProfile();
+
+ /**
+ * Gets the resulting artifacts type
+ */
+ ArtifactType getTargetArtifactType();
+
+ /**
+ * Gets, if the current compile is a test compile.
+ */
+ boolean isTestCompile();
+
+ /**
+ * The list of sources to be included in the compilation.
+ */
+ List<String> getIncludeSources();
+
+ /**
+ * The directory to store the compile output too.
+ */
+ File getOutputDirectory();
+
+ /**
* Initializes the context
*
- * @param compilerRequirement
+ *
+ * @param capability
* @param config
* @param project
- * @param capabilityMatcher
* @throws PlatformUnsupportedException
*/
- void init( CompilerRequirement compilerRequirement, CompilerConfig config, MavenProject project,
- CapabilityMatcher capabilityMatcher )
+ void init( CompilerCapability capability, CompilerConfig config, MavenProject project )
throws PlatformUnsupportedException;
-
- List<String> getEmbeddedResourceArgs();
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java Thu Dec 15 17:07:06 2011
@@ -37,7 +37,7 @@ public interface CompilerExecutable
*
* @return the assembly path for this executable
*/
- String getAssemblyPath();
+ File getAssemblyPath();
/**
* Returns the target framework for this compiler executable.
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerRequirement.java Thu Dec 15 17:07:06 2011
@@ -18,8 +18,8 @@
*/
package npanday.executable.compiler;
-import npanday.vendor.Vendor;
import npanday.executable.ExecutableRequirement;
+import npanday.vendor.Vendor;
/**
* Requirements that the compiler plugin must satisfy to be used in the build.
@@ -27,96 +27,38 @@ import npanday.executable.ExecutableRequ
* @author Shane Isbell
* @see CompilerCapability
*/
-public interface CompilerRequirement
+public class CompilerRequirement
extends ExecutableRequirement
{
+ String language;
+
+ public CompilerRequirement( Vendor vendor, String vendorVersion, String frameworkVersion, String profile, String language )
+ {
+ super( vendor, vendorVersion, frameworkVersion, profile );
+ this.language = language;
+ }
+
+ public CompilerRequirement( String vendorName, String vendorVersion, String frameworkVersion, String profile, String language )
+ {
+ super( vendorName, vendorVersion, frameworkVersion, profile );
+ this.language = language;
+ }
/**
* Returns the required language for the compiler
*
* @return the required language for the compiler
*/
- String getLanguage();
+ public String getLanguage(){
+ return language;
+ }
/**
* Sets required language for the compiler
*
* @param language the required language for the compiler
*/
- void setLanguage( String language );
-
- public static class Factory
- {
-
- private Factory()
- {
- }
-
- public static CompilerRequirement createDefaultCompilerRequirement()
- {
- return new CompilerRequirement()
- {
- private String language;
-
- private String frameworkVersion;
-
- private Vendor vendor;
-
- private String profile;
-
- private String vendorVersion;
-
- public String getVendorVersion()
- {
- return vendorVersion;
- }
-
- public void setVendorVersion( String vendorVersion )
- {
- this.vendorVersion = vendorVersion;
- }
-
- public String getLanguage()
- {
- return language;
- }
-
- public void setLanguage( String language )
- {
- this.language = language;
- }
-
- public String getFrameworkVersion()
- {
- return frameworkVersion;
- }
-
- public void setFrameworkVersion( String frameworkVersion )
- {
- this.frameworkVersion = frameworkVersion;
- }
-
- public Vendor getVendor()
- {
- return vendor;
- }
-
- public void setVendor( Vendor vendor )
- {
- this.vendor = vendor;
- }
-
- public String getProfile()
- {
- return profile;
- }
-
- public void setProfile( String profile )
- {
- this.profile = profile;
- }
- };
-
- }
+ public void setLanguage( String language ){
+ this.language = language;
}
}
Added: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/MutableCompilerCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/MutableCompilerCapability.java?rev=1214869&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/MutableCompilerCapability.java (added)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/MutableCompilerCapability.java Thu Dec 15 17:07:06 2011
@@ -0,0 +1,84 @@
+package npanday.executable.compiler;
+
+import npanday.executable.MutableExecutableCapability;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Holds the configured compiler capability.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+// TODO: Refactor to be based on the configured plugins
+public class MutableCompilerCapability
+ extends MutableExecutableCapability
+ implements CompilerCapability
+{
+ private String language;
+
+ private boolean hasJustInTime;
+
+ private List<String> coreAssemblies;
+
+ private File assemblyPath;
+
+ private String targetFramework;
+
+ public File getAssemblyPath()
+ {
+ return assemblyPath;
+ }
+
+ public void setAssemblyPath( File assemblyPath )
+ {
+ this.assemblyPath = assemblyPath;
+ }
+
+ public List<String> getCoreAssemblies()
+ {
+ return coreAssemblies;
+ }
+
+ public void setCoreAssemblies( List<String> coreAssemblies )
+ {
+ this.coreAssemblies = coreAssemblies;
+ }
+
+ public String getLanguage()
+ {
+ return language;
+ }
+
+ public void setLanguage( String language )
+ {
+ this.language = language;
+ }
+
+ public String getTargetFramework()
+ {
+ return targetFramework;
+ }
+
+ public void setTargetFramework( String targetFramework )
+ {
+ this.targetFramework = targetFramework;
+ }
+
+ public boolean isHasJustInTime()
+ {
+ return hasJustInTime;
+ }
+
+ public void setHasJustInTime( boolean hasJustInTime )
+ {
+ this.hasJustInTime = hasJustInTime;
+ }
+
+
+ public String toString()
+ {
+ return "ID = " + identifier + ", Plugin Class: " + pluginClassName + ", OS = " + operatingSystem
+ + ", Language = " + language + ", Vendor = " + vendorInfo;
+ }
+}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/AspxCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/AspxCompiler.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/AspxCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/AspxCompiler.java Thu Dec 15 17:07:06 2011
@@ -42,16 +42,15 @@ public class AspxCompiler
{
throw new ExecutionException( "NPANDAY-068-000: Compiler has not been initialized with a context" );
}
- CompilerConfig config = compilerContext.getNetCompilerConfig();
-
- compilerContext.getCompilerRequirement().getFrameworkVersion();
+
+ compilerContext.getFrameworkVersion();
List<String> commands = new ArrayList<String>();
- if ( config.getCommands() != null )
+ if ( compilerContext.getCommands() != null )
{
- commands.addAll( config.getCommands() );
+ commands.addAll( compilerContext.getCommands() );
}
CommandFilter filter = compilerContext.getCommandFilter();
@@ -65,8 +64,7 @@ public class AspxCompiler
throws ExecutionException
{
logger.info( "NPANDAY-068-003: Compiling Artifact: Vendor = "
- + compilerContext.getCompilerRequirement().getVendor() + ", Language = "
- + compilerContext.getCompilerRequirement().getLanguage() + ", Assembly Name = "
+ + compilerContext.getVendor() + ", Language = "
+ compilerContext.getArtifact().getAbsolutePath() );
CommandExecutor commandExecutor = CommandExecutor.Factory.createDefaultCommmandExecutor();
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java Thu Dec 15 17:07:06 2011
@@ -18,18 +18,18 @@
*/
package npanday.executable.compiler.impl;
+import npanday.NPandayContext;
import npanday.PathUtil;
+import npanday.executable.CommandExecutor;
+import npanday.executable.ExecutionException;
import npanday.executable.compiler.CompilerContext;
-import npanday.executable.compiler.InvalidArtifactException;
import npanday.executable.compiler.CompilerExecutable;
-import npanday.executable.ExecutionException;
-import npanday.executable.CommandExecutor;
-import npanday.NPandayContext;
+import npanday.executable.compiler.InvalidArtifactException;
import npanday.vendor.Vendor;
import org.codehaus.plexus.logging.Logger;
import java.io.File;
-import java.util.List;
+import java.util.Collection;
/**
* Provides an implementation of the compiler executable.
@@ -63,15 +63,15 @@ abstract class BaseCompiler implements C
*/
public String getTargetFramework()
{
- return compilerContext.getCompilerCapability().getTargetFramework();
+ return compilerContext.getTargetFramework();
}
/**
* @see npanday.executable.compiler.CompilerExecutable#getCompiledArtifact()
*/
- public String getAssemblyPath()
+ public File getAssemblyPath()
{
- return compilerContext.getCompilerCapability().getAssemblyPath();
+ return compilerContext.getAssemblyPath();
}
/**
@@ -93,7 +93,7 @@ abstract class BaseCompiler implements C
{
throw new ExecutionException( "NPANDAY-068-001: Compiler has not been initialized with a context" );
}
- return compilerContext.getCompilerCapability().getExecutable();
+ return compilerContext.getExecutableName();
}
/**
@@ -110,7 +110,7 @@ abstract class BaseCompiler implements C
{
return null;
}
- List<String> executablePaths = compilerContext.getNetCompilerConfig().getExecutionPaths();
+ Collection<String> executablePaths = compilerContext.getProbingPaths();
if ( executablePaths != null )
{
for ( String executablePath : executablePaths )
@@ -132,14 +132,14 @@ abstract class BaseCompiler implements C
public void execute()
throws ExecutionException
{
- if (compilerContext.getNetCompilerConfig().getIncludeSources() ==null && !( new File( compilerContext.getSourceDirectoryName() ).exists() ) )
+ if (compilerContext.getIncludeSources() ==null && !( new File( compilerContext.getSourceDirectoryName() ).exists() ) )
{
logger.info( "NPANDAY-068-002: No source files to compile." );
return;
}
logger.info( "NPANDAY-068-003: Compiling Artifact: Vendor = " +
- compilerContext.getCompilerRequirement().getVendor() + ", Language = " +
- compilerContext.getCompilerRequirement().getVendor() + ", Assembly Name = " +
+ compilerContext.getVendor() + ", Language = " +
+ compilerContext.getVendor() + ", Assembly Name = " +
compilerContext.getArtifact().getAbsolutePath() );
// commands are executed relative to working directory in Windows, but not all platforms
@@ -153,6 +153,6 @@ abstract class BaseCompiler implements C
public Vendor getVendor()
{
- return compilerContext.getCompilerCapability().getVendor();
+ return compilerContext.getVendor();
}
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/CSharpCompilerForProfile.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/CSharpCompilerForProfile.java?rev=1214869&r1=1214868&r2=1214869&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/CSharpCompilerForProfile.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/CSharpCompilerForProfile.java Thu Dec 15 17:07:06 2011
@@ -57,18 +57,17 @@ public final class CSharpCompilerForProf
public List<String> getCommands()
throws ExecutionException
{
- String assemblyPath = compilerContext.getCompilerCapability().getAssemblyPath();
+ File assemblyPath = compilerContext.getAssemblyPath();
if ( assemblyPath == null )
{
throw new ExecutionException(
"NPANDAY-067-003: The assembly path is not specified" );
}
- File path = new File( assemblyPath );
- if ( !path.exists() )
+ if ( !assemblyPath.exists() )
{
throw new ExecutionException(
- "NPANDAY-067-002: The assembly path does not exist: Path = " + path.getAbsolutePath() );
+ "NPANDAY-067-002: The assembly path does not exist: Path = " + assemblyPath.getAbsolutePath() );
}
List<String> commands = netCompiler.getCommands();
@@ -76,7 +75,7 @@ public final class CSharpCompilerForProf
commands.add( "/noconfig" );
for ( String coreAssembly : compilerContext.getCoreAssemblyNames() )
{
- commands.add( "/reference:" + path.getAbsolutePath() + File.separator + coreAssembly + ".dll" );
+ commands.add( "/reference:" + assemblyPath.getAbsolutePath() + File.separator + coreAssembly + ".dll" );
}
return commands;
}