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-test-messages", defaultPhase=LifecyclePhase.GENERATE_TEST_SOURCES, threadSafe=true)
29  public final class GenerateTestMessagesMojo extends
30          AbstractGenerateMessagesMojo {
31  
32      /**
33       * The target directory in which the source files should be generated.
34       */
35      @Parameter(defaultValue="${project.build.directory}/generated-test-sources/messages", required=true)
36      private File targetDirectory;
37  
38      /**
39       * The resource directory containing the message files.
40       */
41      @Parameter(defaultValue="${basedir}/src/test/resources", required=true)
42      private File resourceDirectory;
43  
44      /**
45       * {@inheritDoc}
46       */
47      @Override
48      void addNewSourceDirectory(final File targetDirectory) {
49          getMavenProject().addTestCompileSourceRoot(
50                  targetDirectory.getAbsolutePath());
51      }
52  
53      /**
54       * {@inheritDoc}
55       */
56      @Override
57      File getResourceDirectory() {
58          return resourceDirectory;
59      }
60  
61      /**
62       * {@inheritDoc}
63       */
64      @Override
65      File getTargetDirectory() {
66          return targetDirectory;
67      }
68  
69  }