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 2012/05/16 10:30:02 UTC
svn commit: r1339106 - in /incubator/npanday/trunk:
components/dotnet-executable/src/main/java/npanday/executable/compiler/
components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/
components/dotnet-executable/src/main/java/npanday/...
Author: lcorneliussen
Date: Wed May 16 10:30:01 2012
New Revision: 1339106
URL: http://svn.apache.org/viewvc?rev=1339106&view=rev
Log:
[NPANDAY-210] Deprecate includeSources in favor of include/exclude patterns
o added possibility to skip compile from within the compiler executable or compiler context
o skipping test compile, if no sources found
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerContext.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.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/CSharpCompilerForProfile.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DotGNUCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/JavaCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/NemerleCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/PhpCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/RubyCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java
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=1339106&r1=1339105&r2=1339106&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 Wed May 16 10:30:01 2012
@@ -180,9 +180,16 @@ public interface CompilerContext
boolean isTestCompile();
/**
+ * Figures out, if a compile run is necessary.
+ *
+ * @return
+ */
+ boolean shouldCompile();
+
+ /**
* The list of sources to be included in the compilation.
*/
- Set<File> expandIncludedSourceFiles();
+ Set<File> getSourceFiles();
/**
* The directory to store the compile output too.
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=1339106&r1=1339105&r2=1339106&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 Wed May 16 10:30:01 2012
@@ -32,6 +32,11 @@ import java.io.File;
public interface CompilerExecutable
extends NetExecutable
{
+ /**
+ *
+ * @return
+ */
+ boolean shouldCompile();
/**
* Returns the assembly path for this executable.
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=1339106&r1=1339105&r2=1339106&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 Wed May 16 10:30:01 2012
@@ -33,6 +33,11 @@ public class AspxCompiler
extends BaseCompiler
{
+ public boolean shouldCompile()
+ {
+ return true;
+ }
+
public boolean failOnErrorOutput()
{
return true;
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=1339106&r1=1339105&r2=1339106&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 Wed May 16 10:30:01 2012
@@ -52,6 +52,11 @@ public final class CSharpCompilerForProf
this.compilerContext = (CompilerContext) npandayContext;
}
+ public boolean shouldCompile()
+ {
+ return netCompiler.shouldCompile();
+ }
+
public boolean failOnErrorOutput()
{
return netCompiler.failOnErrorOutput();
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java Wed May 16 10:30:01 2012
@@ -22,6 +22,7 @@ package npanday.executable.compiler.impl
import npanday.PlatformUnsupportedException;
import npanday.executable.CommandFilter;
import npanday.executable.ExecutionException;
+import npanday.executable.ExecutionResult;
import npanday.executable.execution.quoting.CustomSwitchAwareQuotingStrategy;
import npanday.vendor.Vendor;
import org.apache.maven.artifact.Artifact;
@@ -51,6 +52,17 @@ public final class DefaultCompiler
strategy.addQuoteNormally("resource");
}
+ @Override
+ public ExecutionResult execute() throws ExecutionException, PlatformUnsupportedException
+ {
+ return super.execute();
+ }
+
+ public boolean shouldCompile()
+ {
+ return compilerContext.shouldCompile();
+ }
+
public boolean failOnErrorOutput()
{
//MONO writes warnings to standard error: this turns off failing builds on warnings for MONO
@@ -75,8 +87,6 @@ public final class DefaultCompiler
List<String> commands = new ArrayList<String>();
-
-
if(compilerContext.getOutputDirectory() != null)
{
File f = new File(compilerContext.getOutputDirectory(), compilerContext.getArtifact().getName());
@@ -268,7 +278,7 @@ public final class DefaultCompiler
FileUtils.mkdir(TempDir);
- Set<File> sourceFiles = compilerContext.expandIncludedSourceFiles();
+ Set<File> sourceFiles = compilerContext.getSourceFiles();
if( sourceFiles != null && !sourceFiles.isEmpty() )
{
for(File includeSource : sourceFiles )
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DotGNUCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DotGNUCompiler.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DotGNUCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DotGNUCompiler.java Wed May 16 10:30:01 2012
@@ -36,6 +36,11 @@ import java.util.Set;
public final class DotGNUCompiler
extends BaseCompiler
{
+ public boolean shouldCompile()
+ {
+ return true;
+ }
+
public boolean failOnErrorOutput()
{
return true;
@@ -89,7 +94,7 @@ public final class DotGNUCompiler
commands.addAll( compilerContext.getCommands() );
}
- Set<File> sourceFiles = compilerContext.expandIncludedSourceFiles();
+ Set<File> sourceFiles = compilerContext.getSourceFiles();
if( sourceFiles != null && !sourceFiles.isEmpty() )
{
for(File includeSource : sourceFiles )
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/JavaCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/JavaCompiler.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/JavaCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/JavaCompiler.java Wed May 16 10:30:01 2012
@@ -25,6 +25,11 @@ import java.util.List;
public class JavaCompiler extends BaseCompiler
{
+ public boolean shouldCompile()
+ {
+ return true;
+ }
+
public boolean failOnErrorOutput()
{
return false;
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/NemerleCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/NemerleCompiler.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/NemerleCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/NemerleCompiler.java Wed May 16 10:30:01 2012
@@ -21,7 +21,6 @@ package npanday.executable.compiler.impl
import npanday.executable.ExecutionException;
import org.apache.maven.artifact.Artifact;
-import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.util.ArrayList;
@@ -39,6 +38,12 @@ public final class NemerleCompiler
extends BaseCompiler
{
+ public boolean shouldCompile()
+ {
+ // TODO: figure out when nemerle compile can be skipped; or just remove this all together :)
+ return true;
+ }
+
public boolean failOnErrorOutput()
{
return true;
@@ -76,7 +81,7 @@ public final class NemerleCompiler
}
}
- Set<File> sourceFiles = compilerContext.expandIncludedSourceFiles();
+ Set<File> sourceFiles = compilerContext.getSourceFiles();
if( sourceFiles != null && !sourceFiles.isEmpty() )
{
for(File includeSource : sourceFiles )
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/PhpCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/PhpCompiler.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/PhpCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/PhpCompiler.java Wed May 16 10:30:01 2012
@@ -35,6 +35,12 @@ public final class PhpCompiler
extends BaseCompiler
{
+ public boolean shouldCompile()
+ {
+ // TODO: figure out when php compile can be skipped; or just remove this all together :)
+ return true;
+ }
+
public boolean failOnErrorOutput()
{
return true;
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/RubyCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/RubyCompiler.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/RubyCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/RubyCompiler.java Wed May 16 10:30:01 2012
@@ -35,6 +35,12 @@ import java.util.List;
public final class RubyCompiler
extends BaseCompiler
{
+ public boolean shouldCompile()
+ {
+ // TODO: figure out when ruby compile can be skipped; or just remove this all together :)
+ return true;
+ }
+
public boolean failOnErrorOutput()
{
//MONO writes warnings to standard error: this turns off failing builds on warnings for MONO
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java Wed May 16 10:30:01 2012
@@ -164,6 +164,16 @@ public final class CompilerContextImpl
return config.isTestCompile();
}
+ public boolean shouldCompile()
+ {
+ if (isTestCompile() && getSourceFiles().size() == 0){
+ logger.info( "NPANDAY-061-017: Skipping test compile; no sources found" );
+ return false;
+ }
+
+ return true;
+ }
+
public void enableLogging( Logger logger )
{
this.logger = logger;
@@ -303,16 +313,6 @@ public final class CompilerContextImpl
return logger;
}
- public CompilerConfig getNetCompilerConfig()
- {
- return config;
- }
-
- public CompilerCapability getCompilerCapability()
- {
- return compilerCapability;
- }
-
public File getGeneratedSourcesDirectory()
{
return ( config.isTestCompile() )
@@ -439,7 +439,7 @@ public final class CompilerContextImpl
if ( icons.length > 1 )
{
throw new PlatformUnsupportedException(
- "NPANDAY-061-007: There is more than one win32icon in resource directory: Number = " + icons.length
+ "NPANDAY-061-008: There is more than one win32icon in resource directory: Number = " + icons.length
);
}
if ( icons.length == 1 )
@@ -449,7 +449,16 @@ public final class CompilerContextImpl
}
}
- public Set<File> expandIncludedSourceFiles()
+ Set<File> expandedSourceFiles;
+ public Set<File> getSourceFiles()
+ {
+ if (expandedSourceFiles == null)
+ expandedSourceFiles = expandSourceFiles();
+
+ return expandedSourceFiles;
+ }
+
+ private Set<File> expandSourceFiles()
{
Set<File> files = Sets.newHashSet();
if ( config.getDeprecatedIncludeSourcesConfiguration() != null )
@@ -477,8 +486,8 @@ public final class CompilerContextImpl
if ( additionalRoots.size() > 0 )
{
- getLogger().info(
- "NPANDAY-161-004: Adding additional compile source roots: " + additionalRoots
+ getLogger().debug(
+ "NPANDAY-061-009: Adding additional compile source roots: " + additionalRoots
);
for(String root : additionalRoots){
@@ -495,8 +504,8 @@ public final class CompilerContextImpl
List<File> mainSources = expandMainSourceFilePatterns();
List<File> testSources = expandTestSourceFilePatterns();
- getLogger().info(
- "NPANDAY-161-002: Since source and tests reside in same folder, "
+ getLogger().debug(
+ "NPANDAY-061-010: Since source and tests reside in same folder, "
+ " test sources will be excluded from main sources and vice versa"
);
@@ -516,7 +525,7 @@ public final class CompilerContextImpl
}
}
- getLogger().info( "NPANDAY-161-004: Found " + files.size() + " source files to compile" );
+ logger.info( "NPANDAY-061-011: Found " + files.size() + " source files" );
return files;
}
@@ -524,7 +533,7 @@ public final class CompilerContextImpl
private List<File> expandMainSourceFilePatterns()
{
getLogger().debug(
- "NPANDAY-161-007: Expanding main sources"
+ "NPANDAY-061-012: Expanding main sources"
);
List<String> includes = Lists.newArrayList();
if ( config.getIncludes() != null )
@@ -555,7 +564,7 @@ public final class CompilerContextImpl
private List<File> expandTestSourceFilePatterns()
{
getLogger().debug(
- "NPANDAY-161-008: Expanding test sources"
+ "NPANDAY-061-013: Expanding test sources"
);
List<String> includes = Lists.newArrayList();
if ( config.getTestIncludes() != null )
@@ -576,8 +585,8 @@ public final class CompilerContextImpl
}
else
{
- getLogger().info(
- "NPANDAY-161-006: Since source and tests reside in same folder, "
+ getLogger().debug(
+ "NPANDAY-061-014: Since source and tests reside in same folder, "
+ "and no default includes are stated, conventions for finding tests will be applied."
);
includes.add( "**/Test/*" + config.getLanguageFileExtension() );
@@ -606,7 +615,7 @@ public final class CompilerContextImpl
{
if ( !directory.exists() || directory.list().length == 0 )
{
- getLogger().debug( "NPANDAY-161-000: " + directory + " is empty; no sources found" );
+ getLogger().debug( "NPANDAY-061-015: " + directory + " is empty; no sources found" );
return Lists.newArrayList();
}
@@ -628,7 +637,7 @@ public final class CompilerContextImpl
if ( getLogger().isDebugEnabled() )
{
getLogger().debug(
- "NPANDAY-161-001: scanned for source files:" + NEW_LINE + " - directory: " + directory.getAbsolutePath()
+ "NPANDAY-061-016: scanned for source files:" + NEW_LINE + " - directory: " + directory.getAbsolutePath()
+ NEW_LINE + " - includes: " + includes + NEW_LINE + " - excludes: " + excludes + NEW_LINE
+ " - included (*.*): " + scanner.getIncludedFiles().length + NEW_LINE + " - included sources (*."
+ config.getLanguageFileExtension() + "): " + files.size() + NEW_LINE + " - excluded: "
Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original)
+++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Wed May 16 10:30:01 2012
@@ -70,6 +70,7 @@ import java.util.regex.Pattern;
* Abstract Class for compile mojos for both test-compile and compile.
*
* @author Shane Isbell, Leopoldo Lee Agdeppa III
+ * @author <a href="me@lcorneliussen.de">Lars Corneliussen, Faktum Software</a>
*/
public abstract class AbstractCompilerMojo
extends AbstractMojo
@@ -1169,6 +1170,11 @@ public abstract class AbstractCompilerMo
getCompilerRequirement(), getCompilerConfig(), project
);
+ if (!compilerExecutable.shouldCompile()) {
+ getLog().debug("NPANDAY-900-010: Compiler vetoed compile, see preceding log entries for details");
+ return;
+ }
+
File compiledArtifact = compilerExecutable.getCompiledArtifact();
// TODO: see issue with CompilerContextImpl.getArtifact(), which does not incorporate outputDirectory
Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java?rev=1339106&r1=1339105&r2=1339106&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java (original)
+++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java Wed May 16 10:30:01 2012
@@ -52,8 +52,6 @@ public final class TestCompilerMojo
public void execute()
throws MojoExecutionException
{
-
-
String skipTests = System.getProperty( "maven.test.skip" );
if ( ( skipTests != null && skipTests.equalsIgnoreCase( "true" ) ) || skipTestCompile )
{
@@ -63,7 +61,6 @@ public final class TestCompilerMojo
// execute as a test
super.execute(true);
-
}
protected void initializeDefaults()
@@ -93,8 +90,6 @@ public final class TestCompilerMojo
protected CompilerConfig getCompilerConfig() throws MojoExecutionException
{
-
- //Config
CompilerConfig compilerConfig = new CompilerConfig();
compilerConfig.setCommands( getParameters() );