in meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java [367:434]
private void copyProvidedFiles(final File distroFolder) throws MojoExecutionException
{
boolean customLog4jConfig = false;
boolean customMwProperties = false;
final Log log = getLog();
File srcConf = new File(conf);
if (!srcConf.isAbsolute()) {
srcConf = new File(project.getBasedir(), conf);
}
if (srcConf.isDirectory()) {
final File targetConf = new File(distroFolder, "conf");
targetConf.mkdirs();
for (final File file : srcConf.listFiles()) {
final String fileName = file.getName();
if ("log4j2.xml".equals(fileName)) {
customLog4jConfig = true;
} else if ("meecrowave.properties".equals(fileName)) {
customMwProperties = true;
} else if (fileName.startsWith(".")) {
// hidden file -> ignore
continue;
}
try {
if (log.isDebugEnabled()) {
log.debug("Copying file from " + file + " to " + targetConf);
}
Files.copy(file.toPath(), new File(targetConf, fileName).toPath());
} catch (final IOException e) {
throw new MojoExecutionException("Could not copy file " + file.getAbsolutePath(), e);
}
}
}
if (!customLog4jConfig)
{
writeLog4jConfig(distroFolder);
}
if (!customMwProperties)
{
writeMeecrowaveProperties(distroFolder);
}
final File srcBin = new File(project.getBasedir(), bin);
if (srcBin.exists() && srcBin.isDirectory()) {
final File targetRoot = new File(distroFolder, "bin");
targetRoot.mkdirs();
Stream.of(srcBin.listFiles())
.filter(f -> !f.isDirectory()) // not nested for now
.forEach(f -> {
try {
if (log.isDebugEnabled()) {
log.debug("Copying file from " + f + " to " + targetRoot);
}
final File target = new File(targetRoot, f.getName());
Files.copy(f.toPath(), target.toPath());
if (target.getName().endsWith(".sh")) {
target.setExecutable(true);
}
}
catch (final IOException e) {
throw new IllegalArgumentException("Could not copy file " + f.getAbsolutePath(), e);
}
});
}
}