001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyrighted [year] [name of copyright owner]".
013 *
014 * Copyright 2011 ForgeRock AS
015 * Portions Copyright 2022 Wren Security.
016 */
017package org.forgerock.i18n.maven;
018
019import java.io.File;
020
021import org.apache.maven.plugins.annotations.LifecyclePhase;
022import org.apache.maven.plugins.annotations.Mojo;
023import org.apache.maven.plugins.annotations.Parameter;
024
025/**
026 * Goal which generates message source files from a one or more property files.
027 */
028@Mojo(name="generate-messages", defaultPhase=LifecyclePhase.GENERATE_SOURCES, threadSafe=true)
029public final class GenerateMessagesMojo extends AbstractGenerateMessagesMojo {
030
031    /**
032     * The target directory in which the source files should be generated.
033     */
034    @Parameter(defaultValue="${project.build.directory}/generated-sources/messages", required=true)
035    private File targetDirectory;
036
037    /**
038     * The resource directory containing the message files.
039     */
040    @Parameter(defaultValue="${basedir}/src/main/resources", required=true)
041    private File resourceDirectory;
042
043    /**
044     * {@inheritDoc}
045     */
046    @Override
047    void addNewSourceDirectory(final File targetDirectory) {
048        getMavenProject().addCompileSourceRoot(
049                targetDirectory.getAbsolutePath());
050    }
051
052    /**
053     * {@inheritDoc}
054     */
055    @Override
056    File getResourceDirectory() {
057        return resourceDirectory;
058    }
059
060    /**
061     * {@inheritDoc}
062     */
063    @Override
064    File getTargetDirectory() {
065        return targetDirectory;
066    }
067
068}