Author: lcorneliussen
Date: Mon Apr 23 14:42:15 2012
New Revision: 1329264
URL: http://svn.apache.org/viewvc?rev=1329264&view=rev
Log:
[NPANDAY-499] Make configuration for compiler-plugins and executable-plugins
more flexible
o Let NetExecutable return an ExecutionResult + removed unecessary method
getCommands on NetExecutable
Added:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutionResult.java
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableRequirement.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutable.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/compiler/impl/CSharpCompilerForProfile.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
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java
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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -67,9 +67,9 @@ public class ExecutableRequirement
this.executableVersion = executableVersion;
}
- public ExecutableRequirement( VendorRequirement vendor, String identifier )
+ public ExecutableRequirement( VendorRequirement vendor, String profile )
{
- this(vendor, identifier, null);
+ this(vendor, profile, null);
}
public VendorRequirement getVendorRequirement(){
Added:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutionResult.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutionResult.java?rev=1329264&view=auto
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutionResult.java
(added)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutionResult.java
Mon Apr 23 14:42:15 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.executable;
+
+/**
+ * The result of an execution.
+ *
+ * @author <a href="mailto:[email protected]>Lars Corneliussen, Faktum
Software</a>
+ */
+public class ExecutionResult
+{
+ private final int result;
+
+ private final String standardOut;
+
+ private final String standardError;
+
+ public ExecutionResult( int result, String standardOut, String
standardError )
+ {
+ this.result = result;
+ this.standardOut = standardOut;
+ this.standardError = standardError;
+ }
+
+ public int getResult()
+ {
+ return result;
+ }
+
+ public String getStandardOut()
+ {
+ return standardOut;
+ }
+
+ public String getStandardError()
+ {
+ return standardError;
+ }
+}
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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -36,24 +36,13 @@ import java.util.Properties;
*/
public interface NetExecutable
{
-
- /**
- * Returns the commands that this compiler will use to compile the
application. This list is unmodifiable.
- *
- * @return the commands that this compiler will use to compile the
application
- * @throws ExecutionException
- * @throws PlatformUnsupportedException if one or more commands are not
supported by the current platform.
- */
- List<String> getCommands() throws ExecutionException,
PlatformUnsupportedException;
-
/**
- * Compiles class files.
+ * Runs the executable.
*
* @throws npanday.executable.ExecutionException
- * if the compiler writes to the standard error stream.
- * artifact (module, library, exe, winexe) or the target artifact
is not valid for the compiler
+ * if the executable fails or writes to the standard error stream.
*/
- void execute() throws ExecutionException, PlatformUnsupportedException;
+ ExecutionResult execute() throws ExecutionException,
PlatformUnsupportedException;
/**
* Initialize this executable.
@@ -68,6 +57,6 @@ public interface NetExecutable
*
* @return vendor vendor framework used to run executable
*/
+ @Deprecated
Vendor getVendor();
-
}
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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -24,6 +24,7 @@ import npanday.PlatformUnsupportedExcept
import npanday.executable.CommandExecutor;
import npanday.executable.CommandFilter;
import npanday.executable.ExecutionException;
+import npanday.executable.ExecutionResult;
import java.util.ArrayList;
import java.util.List;
@@ -61,7 +62,7 @@ public class AspxCompiler
@Override
- public void execute() throws ExecutionException,
PlatformUnsupportedException
+ public ExecutionResult execute() throws ExecutionException,
PlatformUnsupportedException
{
logger.info( "NPANDAY-068-003: Compiling Artifact: Vendor = "
+ compilerContext.getVendor() + ", Language = "
@@ -73,6 +74,7 @@ public class AspxCompiler
commandExecutor.setLogger( logger );
String executable = PathUtil.getExecutable( getExecutable(),
compilerContext.getProbingPaths(), logger );
commandExecutor.executeCommand( executable, getCommands(), null,
failOnErrorOutput() );
+ return null;
}
}
\ No newline at end of file
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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -24,6 +24,7 @@ import npanday.PathUtil;
import npanday.PlatformUnsupportedException;
import npanday.executable.CommandExecutor;
import npanday.executable.ExecutionException;
+import npanday.executable.ExecutionResult;
import npanday.executable.compiler.CompilerContext;
import npanday.executable.compiler.CompilerExecutable;
import npanday.executable.compiler.InvalidArtifactException;
@@ -32,6 +33,7 @@ import org.codehaus.plexus.logging.Logge
import java.io.File;
import java.util.Collection;
+import java.util.List;
import java.util.Properties;
/**
@@ -101,7 +103,7 @@ abstract class BaseCompiler
/**
* @see npanday.executable.compiler.CompilerExecutable#execute()
*/
- public void execute() throws ExecutionException,
PlatformUnsupportedException
+ public ExecutionResult execute() throws ExecutionException,
PlatformUnsupportedException
{
if ( compilerContext.getIncludeSources() == null && !(
new File(
@@ -110,7 +112,7 @@ abstract class BaseCompiler
) )
{
logger.info( "NPANDAY-068-002: No source files to compile." );
- return;
+ return null;
}
logger.info(
"NPANDAY-068-003: Compiling Artifact: Vendor = " +
compilerContext.getVendor() + ", Language = "
@@ -127,8 +129,16 @@ abstract class BaseCompiler
commandExecutor.executeCommand(
PathUtil.getExecutable( executable, executablePaths, logger ),
getCommands(), null, failOnErrorOutput()
);
+
+ return new ExecutionResult(
+ commandExecutor.getResult(),
+ commandExecutor.getStandardOut(),
+ commandExecutor.getStandardError()
+ );
}
+ protected abstract List<String> getCommands() throws ExecutionException,
PlatformUnsupportedException;
+
public Vendor 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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -37,7 +37,7 @@ import java.util.Properties;
public final class CSharpCompilerForProfile
extends BaseCompiler
{
- private CompilerExecutable netCompiler;
+ private DefaultCompiler netCompiler;
private CompilerContext compilerContext;
public CSharpCompilerForProfile()
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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -26,6 +26,7 @@ import npanday.executable.CommandExecuto
import npanday.executable.CommandFilter;
import npanday.executable.ExecutableContext;
import npanday.executable.ExecutionException;
+import npanday.executable.ExecutionResult;
import npanday.executable.NetExecutable;
import npanday.vendor.Vendor;
import org.codehaus.plexus.logging.Logger;
@@ -62,12 +63,12 @@ public class DefaultNetExecutable
return Collections.unmodifiableList( filter.filter( commands ) );
}
- public void execute() throws ExecutionException,
PlatformUnsupportedException
+ public ExecutionResult execute() throws ExecutionException,
PlatformUnsupportedException
{
- innerExecute();
+ return innerExecute();
}
- public void innerExecute() throws ExecutionException,
PlatformUnsupportedException
+ public ExecutionResult innerExecute() throws ExecutionException,
PlatformUnsupportedException
{
List<String> commands = getCommands();
@@ -78,6 +79,13 @@ public class DefaultNetExecutable
executableContext.getExecutableName(),
executableContext.getProbingPaths(), logger
), commands, null, true
);
+
+ return new ExecutionResult(
+ commandExecutor.getResult(),
+ commandExecutor.getStandardOut(),
+ commandExecutor.getStandardError()
+ );
+
}
public Vendor getVendor()
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=1329264&r1=1329263&r2=1329264&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
Mon Apr 23 14:42:15 2012
@@ -82,7 +82,7 @@ public class DefaultRepositoryNetExecuta
throw new ExecutionException( "NPANDAY-068-006: Couldn't find anything
to be executed!" );
}
- public void execute() throws ExecutionException
+ public ExecutionResult execute() throws ExecutionException
{
List<String> commands = getCommands();
@@ -110,6 +110,12 @@ public class DefaultRepositoryNetExecuta
"NPANDAY-063-001: Executable = " + getExecutable() + ", Args =
" + commands
);
}
+
+ return new ExecutionResult(
+ commandExecutor.getResult(),
+ commandExecutor.getStandardOut(),
+ commandExecutor.getStandardError()
+ );
}
public Vendor getVendor()
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java?rev=1329264&r1=1329263&r2=1329264&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/ThreadedNetExecutable.java
Mon Apr 23 14:42:15 2012
@@ -21,6 +21,7 @@ package npanday.executable.impl;
import npanday.PlatformUnsupportedException;
import npanday.executable.ExecutionException;
+import npanday.executable.ExecutionResult;
/**
* Provides a service for executing a command within a separate thread. This
will be used for executing long-running
@@ -48,7 +49,7 @@ public class ThreadedNetExecutable
}
}
- public void execute()
+ public ExecutionResult execute()
throws ExecutionException
{
throw new ExecutionException( "NPANDAY-116-001: Create a thread, then
use RUN - or refactor ThreadedNetExecutable");