protected boolean copyFilteredFile()

in src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java [219:254]


    protected boolean copyFilteredFile(
            String sourceId, final WarPackagingContext context, File file, String targetFilename)
            throws IOException, MojoExecutionException {
        context.addResource(targetFilename);

        if (context.getWebappStructure().registerFile(sourceId, targetFilename)) {
            final File targetFile = new File(context.getWebappDirectory(), targetFilename);
            final String encoding;
            try {
                if (isXmlFile(file)) {
                    // For xml-files we extract the encoding from the files
                    encoding = getEncoding(file);
                } else if (isPropertiesFile(file) && StringUtils.isNotEmpty(context.getPropertiesEncoding())) {
                    encoding = context.getPropertiesEncoding();
                } else {
                    // For all others we use the configured encoding
                    encoding = context.getResourceEncoding();
                }
                // fix for MWAR-36, ensures that the parent dir are created first
                targetFile.getParentFile().mkdirs();

                context.getMavenFileFilter().copyFile(file, targetFile, true, context.getFilterWrappers(), encoding);
            } catch (MavenFilteringException e) {
                throw new MojoExecutionException(e.getMessage(), e);
            }
            // CHECKSTYLE_OFF: LineLength
            // Add the file to the protected list
            context.getLog().debug(" + " + targetFilename + " has been copied (filtered encoding='" + encoding + "').");
            // CHECKSTYLE_ON: LineLength
            return true;
        } else {
            context.getLog()
                    .debug(" - " + targetFilename + " wasn't copied because it has already been packaged (filtered).");
            return false;
        }
    }