Author: lcorneliussen
Date: Sat Apr 28 14:06:33 2012
New Revision: 1331771
URL: http://svn.apache.org/viewvc?rev=1331771&view=rev
Log:
[NPANDAY-499] Make configuration for compiler-plugins and executable-plugins
more flexible
o Enhanced quoting configuration
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/CommandExecutor.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/AspxCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/quoting/CustomSwitchAwareQuotingStrategy.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
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=1331771&r1=1331770&r2=1331771&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
Sat Apr 28 14:06:33 2012
@@ -124,17 +124,40 @@ public interface CommandExecutor
* Returns a default instance of the command executor
*
* @return a default instance of the command executor
- * @param switchformats
+ * @param quotingConfiguration
*/
- public static CommandExecutor createDefaultCommmandExecutor( String
switchformats )
+ public static CommandExecutor createDefaultCommmandExecutor(
java.util.Properties quotingConfiguration )
{
- if (isNullOrEmpty(switchformats))
- return new UnifiedShellCommandExecutor( new
CustomSwitchAwareQuotingStrategy() );
- else
- return new UnifiedShellCommandExecutor( new
CustomSwitchAwareQuotingStrategy( parseSwitchFormats(switchformats)) );
+
+ CustomSwitchAwareQuotingStrategy quotingStrategy = new
CustomSwitchAwareQuotingStrategy();
+ if ( quotingConfiguration != null )
+ {
+ String switchformats = (String) quotingConfiguration.get(
"switchformats" );
+ String rawSwitches = (String) quotingConfiguration.get(
"rawswitches" );
+ boolean ignorePrequoted =
"true".equals(quotingConfiguration.get( "ignoreprequoted" ));
+
+ if ( !isNullOrEmpty( switchformats ) )
+ {
+ new CustomSwitchAwareQuotingStrategy( parseSwitchFormats(
switchformats ) );
+ }
+
+ if (ignorePrequoted) {
+ quotingStrategy.setIgnorePrequoted();
+ }
+
+ if ( !isNullOrEmpty( rawSwitches ) )
+ {
+ for ( String s : SPLIT_ON_COMMA_OR_SEMICOLON.split(
rawSwitches ) )
+ {
+ quotingStrategy.addIgnore( s );
+ }
+ }
+ }
+ return new UnifiedShellCommandExecutor( quotingStrategy );
}
static Splitter SPLIT_ON_PIPE =
Splitter.on('|').trimResults().omitEmptyStrings();
+ static Splitter SPLIT_ON_COMMA_OR_SEMICOLON =
Splitter.onPattern(",|;").trimResults().omitEmptyStrings();
private static SwitchFormat[] parseSwitchFormats( String switchformats
)
{
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=1331771&r1=1331770&r2=1331771&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
Sat Apr 28 14:06:33 2012
@@ -69,8 +69,8 @@ public class AspxCompiler
+ compilerContext.getArtifact().getAbsolutePath() );
CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor(
- (String)configuration.get( "switchformats" )
- );
+ configuration
+ );
commandExecutor.setLogger( logger );
String executable = PathUtil.getExecutable( getExecutable(),
compilerContext.getProbingPaths(), logger );
commandExecutor.executeCommand( executable, getCommands(), null,
failOnErrorOutput() );
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=1331771&r1=1331770&r2=1331771&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
Sat Apr 28 14:06:33 2012
@@ -123,7 +123,7 @@ abstract class BaseCompiler
Collection<String> executablePaths = compilerContext.getProbingPaths();
CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor(
- (String)configuration.get( "switchformats" )
+ configuration
);
commandExecutor.setLogger( logger );
commandExecutor.executeCommand(
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/quoting/CustomSwitchAwareQuotingStrategy.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/quoting/CustomSwitchAwareQuotingStrategy.java?rev=1331771&r1=1331770&r2=1331771&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/quoting/CustomSwitchAwareQuotingStrategy.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/execution/quoting/CustomSwitchAwareQuotingStrategy.java
Sat Apr 28 14:06:33 2012
@@ -48,6 +48,8 @@ public class CustomSwitchAwareQuotingStr
new SwitchFormat( '-', ':' )
};
+ private boolean ignorePrequoted = false;
+
public CustomSwitchAwareQuotingStrategy( )
{
@@ -61,6 +63,11 @@ public class CustomSwitchAwareQuotingStr
public String quoteAndEscape(
String source, char quoteChar, char[] escapedChars, char[]
quotingTriggers, char escapeChar, boolean force )
{
+ if (ignorePrequoted && (source.contains( "\"" ) || source.contains(
"'" )))
+ {
+ return source;
+ }
+
for ( SwitchFormat format : supportedSwitchFormats )
{
if ( format.isMatchingSwitch( source ) )
@@ -144,5 +151,10 @@ public class CustomSwitchAwareQuotingStr
{
quoteNormally.add( switchName );
}
+
+ public void setIgnorePrequoted( )
+ {
+ ignorePrequoted = true;
+ }
}
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java?rev=1331771&r1=1331770&r2=1331771&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultNetExecutable.java
Sat Apr 28 14:06:33 2012
@@ -72,7 +72,8 @@ public class DefaultNetExecutable
{
List<String> commands = getCommands();
- CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor((String)configuration.get(
"switchformats" ));
+ CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor(
+ configuration);
commandExecutor.setLogger( logger );
commandExecutor.executeCommand(
PathUtil.getExecutable(
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java?rev=1331771&r1=1331770&r2=1331771&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/DefaultRepositoryNetExecutable.java
Sat Apr 28 14:06:33 2012
@@ -87,7 +87,7 @@ public class DefaultRepositoryNetExecuta
List<String> commands = getCommands();
CommandExecutor commandExecutor =
CommandExecutor.Factory.createDefaultCommmandExecutor(
- (String)configuration.get( "switchformats" )
+ configuration
);
commandExecutor.setLogger( logger );