All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jhorstmann.i18n.mojo.WebappGettextMojo Maven / Gradle / Ivy

package net.jhorstmann.i18n.mojo;

import net.jhorstmann.i18n.tools.MessageBundle;
import net.jhorstmann.i18n.tools.xgettext.MessageExtractor;
import net.jhorstmann.i18n.xgettext.web.WebMessageExtractor;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * @goal webappGettext
 * @phase process-resources
 */
public class WebappGettextMojo extends AbstractGettextMojo {
    /**
     * Relativize the path for source-references to the project-root.
     * 
     * @parameter expression="${relativizeSrcRefPaths}" default-value="false"
     */
    protected boolean relativizeSrcRefPaths;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        if (skip) {
            getLog().info("Skipping gettext.");
            return;
        }
        MessageBundle bundle = loadMessageBundle();
        MessageExtractor extractor = new WebMessageExtractor(bundle, projectRoot, relativizeSrcRefPaths);

        int errorCount = extractMessages(extractor, webappDirectory, getWebappIncludes(), getWebappExcludes());

        if (errorCount > 0) {
            throw new MojoExecutionException("Encountered " + errorCount + " error(s) while extracting messages from webapp");
        } else {
            saveMessageBundle(bundle);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy