in src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java [138:181]
private void patchSlingProperties(final File dest, final Properties additionalProps)
throws MojoExecutionException {
final File origSlingProps = new File(dest, "sling.properties");
if ( !origSlingProps.exists() ) {
throw new MojoExecutionException("sling.properties not found at " + origSlingProps);
}
// read original properties
final Properties orig = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(origSlingProps);
orig.load(fis);
} catch (final IOException ioe) {
throw new MojoExecutionException("Unable to read " + origSlingProps, ioe);
} finally {
if ( fis != null ) {
try { fis.close(); } catch (final IOException ignore) {}
}
}
// patch
final Enumeration<Object> keys = additionalProps.keys();
if ( keys.hasMoreElements() ) {
getLog().info("Patching sling.properties");
}
while ( keys.hasMoreElements() ) {
final Object key = keys.nextElement();
orig.put(key, additionalProps.get(key));
}
/// and save
FileOutputStream fos = null;
try {
fos = new FileOutputStream(origSlingProps);
orig.store(fos, null);
} catch (final IOException ioe) {
throw new MojoExecutionException("Unable to save " + origSlingProps, ioe);
} finally {
if ( fis != null ) {
try { fis.close(); } catch (final IOException ignore) {}
}
}
}