Skip to content

Commit

Permalink
Configuration option to always compile all files alexnederlof#30
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasrdm committed Jan 29, 2016
1 parent 5a7f3d5 commit eca8ab2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ You can use the plugin by adding it to the plug-in section in your pom;
<verbose>false</verbose>
<numberOfThreads>4</numberOfThreads>
<failOnMissingSourceDirectory>true</failOnMissingSourceDirectory>
<sourceScanner>org.codehaus.plexus.compiler.util.scan.StaleSourceScanner</sourceScanner>
</configuration>
</plugin>
</plugins>
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/com/alexnederlof/jasperreport/JasperReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
Expand Down Expand Up @@ -149,6 +150,13 @@ public class JasperReporter extends AbstractMojo {
* @parameter default-value="true"
*/
private boolean failOnMissingSourceDirectory = true;

/**
* This is the source inclusion scanner class used, a <code>org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner</code> implementation class.
*
* @parameter default-value="org.codehaus.plexus.compiler.util.scan.StaleSourceScanner"
*/
private String sourceScanner = StaleSourceScanner.class.getName();

private Log log;

Expand Down Expand Up @@ -210,7 +218,7 @@ protected Set<File> jrxmlFilesToCompile(SourceMapping mapping) throws MojoExecut
}

try {
SourceInclusionScanner scanner = new StaleSourceScanner();
SourceInclusionScanner scanner = createSourceInclusionScanner();
scanner.addSourceMapping(mapping);
return scanner.getIncludedSources(sourceDirectory, outputDirectory);
} catch (InclusionScanException e) {
Expand All @@ -229,6 +237,7 @@ private void logConfiguration(Log log) {
log.info("JasperReports Compiler: " + compiler);
log.info("Number of threads: " + numberOfThreads);
log.info("classpathElements: " + classpathElements);
log.info("Source Scanner: " + sourceScanner);
}

/**
Expand Down Expand Up @@ -373,5 +382,17 @@ private void checkForExceptions(List<Future<Void>> output) throws InterruptedExc
future.get();
}
}

private SourceInclusionScanner createSourceInclusionScanner() throws MojoExecutionException {
if (sourceScanner.equals(StaleSourceScanner.class.getName())) {
return new StaleSourceScanner();
}
else if (sourceScanner.equals(SimpleSourceInclusionScanner.class.getName())) {
return new SimpleSourceInclusionScanner(Collections.singleton("**/*"), Collections.<String> emptySet());
}
else {
throw new MojoExecutionException("sourceScanner not supported: \'" + sourceScanner + "\'.");
}
}

}

0 comments on commit eca8ab2

Please sign in to comment.