View Javadoc
1   /*
2    * The contents of this file are subject to the terms of the Common Development and
3    * Distribution License (the License). You may not use this file except in compliance with the
4    * License.
5    *
6    * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7    * specific language governing permission and limitations under the License.
8    *
9    * When distributing Covered Software, include this CDDL Header Notice in each file and include
10   * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11   * Header, with the fields enclosed by brackets [] replaced by your own identifying
12   * information: "Portions Copyrighted [year] [name of copyright owner]".
13   *
14   * Copyright 2011 ForgeRock AS
15   * Portions Copyright 2022 Wren Security.
16   */
17  package org.forgerock.i18n.maven;
18  
19  import java.io.File;
20  
21  import org.apache.maven.plugins.annotations.LifecyclePhase;
22  import org.apache.maven.plugins.annotations.Mojo;
23  import org.apache.maven.plugins.annotations.Parameter;
24  
25  /**
26   * Goal which generates message source files from a one or more property files.
27   */
28  @Mojo(name="generate-messages", defaultPhase=LifecyclePhase.GENERATE_SOURCES, threadSafe=true)
29  public final class GenerateMessagesMojo extends AbstractGenerateMessagesMojo {
30  
31      /**
32       * The target directory in which the source files should be generated.
33       */
34      @Parameter(defaultValue="${project.build.directory}/generated-sources/messages", required=true)
35      private File targetDirectory;
36  
37      /**
38       * The resource directory containing the message files.
39       */
40      @Parameter(defaultValue="${basedir}/src/main/resources", required=true)
41      private File resourceDirectory;
42  
43      /**
44       * {@inheritDoc}
45       */
46      @Override
47      void addNewSourceDirectory(final File targetDirectory) {
48          getMavenProject().addCompileSourceRoot(
49                  targetDirectory.getAbsolutePath());
50      }
51  
52      /**
53       * {@inheritDoc}
54       */
55      @Override
56      File getResourceDirectory() {
57          return resourceDirectory;
58      }
59  
60      /**
61       * {@inheritDoc}
62       */
63      @Override
64      File getTargetDirectory() {
65          return targetDirectory;
66      }
67  
68  }