in src/main/java/org/apache/sling/maven/jspc/JspcMojo.java [373:472]
private void executeInternal() throws JasperException {
if (getLog().isDebugEnabled()) {
getLog().debug("execute() starting for " + pages.size() + " pages.");
}
try {
if (featureSupport == null && feature != null) {
File target = null;
if (feature.featureId != null) {
target = getOrResolveArtifact(project, mavenSession, artifactHandlerManager, artifactResolver, ArtifactId.fromMvnId(feature.featureId.getId())).getFile();
} else if (feature.featureFile != null && ! feature.featureFile.trim().isEmpty()){
target = new File(feature.featureFile);
}
if (target != null && target.isFile()) {
try (Reader reader = new InputStreamReader(Files.newInputStream(target.toPath()), "UTF-8")) {
Feature assembled = FeatureJSONReader.read(reader, target.getAbsolutePath());
featureSupport = FeatureSupport.createFeatureSupport(assembled, artifactId -> {
try {
return getOrResolveArtifact(project, mavenSession, artifactHandlerManager, artifactResolver, artifactId).getFile().toURI().toURL();
} catch (Exception e) {
throw new RuntimeException(e);
}
}, this.getClass().getClassLoader(), feature.failOnUnresolved, properties -> {
properties.put(org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN, org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
properties.put(org.osgi.framework.Constants.FRAMEWORK_STORAGE, new File(project.getBuild().getDirectory(), "featuresupport").getAbsolutePath());
properties.put(org.osgi.framework.Constants.FRAMEWORK_BOOTDELEGATION, "*");
return properties;
});
}
}
}
if (context == null) {
initServletContext();
}
if (printCompilationReport || generateCompilationReport) {
dependencyTracker = new DependencyTracker(
getLog(),
project.getBasedir().toPath(),
sourceDirectory.toPath(),
context,
loader,
jspcCompileArtifacts);
}
if (includes == null) {
includes = new String[]{ "**/*.jsp" };
}
// No explicit pages, we'll process all .jsp in the webapp
if (pages.size() == 0) {
scanFiles(sourceDirectory);
}
File uriRootF = new File(uriSourceRoot);
if (!uriRootF.exists() || !uriRootF.isDirectory()) {
throw new JasperException("The source location '"
+ uriSourceRoot + "' must be an existing directory");
}
pages.stream().parallel().forEach(nextjsp -> {
File fjsp = new File(nextjsp);
if (!fjsp.isAbsolute()) {
fjsp = new File(uriRootF, nextjsp);
}
if (!fjsp.exists()) {
if (getLog().isWarnEnabled()) {
getLog().warn("JSP file " + fjsp + " does not exist");
}
} else {
String s = fjsp.getAbsolutePath();
if (s.startsWith(uriSourceRoot)) {
nextjsp = s.substring(uriSourceRoot.length());
}
if (nextjsp.startsWith("." + File.separatorChar)) {
nextjsp = nextjsp.substring(2);
}
try {
processFile(nextjsp);
} catch (JasperException e) {
Throwable rootCause = e;
while (rootCause instanceof JasperException
&& ((JasperException) rootCause).getRootCause() != null) {
rootCause = ((JasperException) rootCause).getRootCause();
}
if (rootCause != e) {
rootCause.printStackTrace();
}
throw new RuntimeException(e);
}
}
});
if (dependencyTracker != null) {
dependencyTracker.processCompileDependencies();
}
} catch (/* IO */Exception ioe) {
throw new JasperException(ioe);
}
}