use of org.apache.maven.shared.filtering.MavenFilteringException in project sling by apache.
the class AbstractLaunchpadStartingMojo method executeWithArtifacts.
/**
* {@inheritDoc}
*/
@Override
protected void executeWithArtifacts() throws MojoExecutionException {
try {
final Map<String, String> props = new HashMap<String, String>();
props.put(SharedConstants.SLING_HOME, slingHome);
// ensure launchpad is set
props.put(SharedConstants.SLING_LAUNCHPAD, slingHome);
if (forceBundleLoad) {
props.put(SharedConstants.FORCE_PACKAGE_BUNDLE_LOADING, "true");
}
// set up and configure Felix Logger
int logLevelNum;
if (logLevel == null) {
logLevelNum = DEFAULT_LOG_LEVEL;
} else {
logLevelNum = toLogLevelInt(logLevel, DEFAULT_LOG_LEVEL);
}
props.put(LOG_LEVEL_PROP, String.valueOf(logLevelNum));
// Display port number on console, in case HttpService doesn't
getLog().info("HTTP server port: " + httpPort);
props.put(PROP_PORT, String.valueOf(httpPort));
// prevent tons of needless WARN from the framework
Logger logger = new Logger();
logger.setLogLevel(Logger.LOG_ERROR);
if (propertiesFile.exists()) {
File tmp = null;
try {
tmp = File.createTempFile("sling", "props");
mavenFileFilter.copyFile(propertiesFile, tmp, true, project, Collections.EMPTY_LIST, true, System.getProperty("file.encoding"), mavenSession);
Properties loadedProps = PropertyUtils.loadPropertyFile(tmp, null);
for (Object key : loadedProps.keySet()) {
props.put((String) key, (String) loadedProps.get(key));
}
} catch (IOException e) {
throw new MojoExecutionException("Unable to create filtered properties file", e);
} catch (MavenFilteringException e) {
throw new MojoExecutionException("Unable to create filtered properties file", e);
} finally {
if (tmp != null) {
tmp.delete();
}
}
}
sling = startSling(resourceProvider, props, logger);
} catch (BundleException be) {
getLog().error("Failed to Start OSGi framework", be);
}
}
use of org.apache.maven.shared.filtering.MavenFilteringException in project sling by apache.
the class AbstractUsingBundleListMojo method readSlingBootstrap.
/**
* Try to read the bootstrap command file
* The filter is copied to a tmp location to apply filtering.
* @throws MojoExecutionException
*/
private void readSlingBootstrap(final File bootstrapFile, final int mode) throws MojoExecutionException {
if (bootstrapFile.exists()) {
File tmp = null;
Reader reader = null;
try {
tmp = File.createTempFile("sling", "bootstrap");
mavenFileFilter.copyFile(bootstrapFile, tmp, true, project, Collections.EMPTY_LIST, true, System.getProperty("file.encoding"), mavenSession);
reader = new FileReader(tmp);
final StringBuilder sb = new StringBuilder();
if (mode == 0) {
if (this.slingBootstrapCommand != null) {
sb.append(this.slingBootstrapCommand);
}
} else if (mode == 1) {
if (this.slingWebappBootstrapCommand != null) {
sb.append(this.slingWebappBootstrapCommand);
}
} else {
if (this.slingStandaloneBootstrapCommand != null) {
sb.append(this.slingStandaloneBootstrapCommand);
}
}
final char[] buffer = new char[2048];
int l;
while ((l = reader.read(buffer, 0, buffer.length)) != -1) {
sb.append(buffer, 0, l);
}
sb.append('\n');
if (mode == 0) {
this.slingBootstrapCommand = sb.toString();
} else if (mode == 1) {
this.slingWebappBootstrapCommand = sb.toString();
} else {
this.slingStandaloneBootstrapCommand = sb.toString();
}
} catch (final IOException e) {
throw new MojoExecutionException("Unable to create filtered bootstrap file", e);
} catch (final MavenFilteringException e) {
throw new MojoExecutionException("Unable to create filtered bootstrap file", e);
} finally {
if (tmp != null) {
tmp.delete();
}
if (reader != null) {
try {
reader.close();
} catch (final IOException ignore) {
}
}
}
}
}
use of org.apache.maven.shared.filtering.MavenFilteringException in project project-build-plugin by axonivy.
the class DeploymentOptionsFileFactory method createFromTemplate.
public File createFromTemplate(File optionsFile, MavenProject project, MavenSession session, MavenFileFilter fileFilter) throws MojoExecutionException {
if (!isOptionsFile(optionsFile)) {
return null;
}
String fileFormat = FilenameUtils.getExtension(optionsFile.getName());
File targetFile = getTargetFile(fileFormat);
try {
fileFilter.copyFile(optionsFile, targetFile, true, project, Collections.emptyList(), false, StandardCharsets.UTF_8.name(), session);
} catch (MavenFilteringException ex) {
throw new MojoExecutionException("Failed to resolve templates in options file", ex);
}
return targetFile;
}
Aggregations