View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar;
21  
22  import java.io.File;
23  
24  import org.apache.maven.plugin.MojoExecutionException;
25  import org.apache.maven.plugin.MojoFailureException;
26  import org.apache.maven.plugins.annotations.Parameter;
27  
28  /**
29   * Abstract GNU Mojo keeps configuration
30   *
31   * @author Mark Donszelmann
32   */
33  public abstract class AbstractGnuMojo extends AbstractResourcesMojo {
34    /**
35     * Use GNU goals on Windows
36     */
37    @Parameter(defaultValue = "nar.gnu.useonwindows", required = true)
38    private boolean gnuUseOnWindows;
39  
40    /**
41     * Source directory for GNU style project
42     */
43    @Parameter(defaultValue = "${basedir}/src/gnu")
44    private File gnuSourceDirectory;
45  
46    /**
47     * Directory in which gnu sources are copied and "configured"
48     */
49    @Parameter(defaultValue = "${project.build.directory}/nar/gnu")
50    private File gnuTargetDirectory;
51  
52    /**
53     * @return
54     * @throws MojoFailureException
55     * @throws MojoExecutionException
56     */
57    private File getGnuAOLDirectory() throws MojoFailureException, MojoExecutionException {
58      return new File(this.gnuTargetDirectory, getAOL().toString());
59    }
60  
61    /**
62     * @return
63     * @throws MojoFailureException
64     * @throws MojoExecutionException
65     */
66    protected final File getGnuAOLSourceDirectory() throws MojoFailureException, MojoExecutionException {
67      return new File(getGnuAOLDirectory(), "src");
68    }
69  
70    /**
71     * @return
72     * @throws MojoFailureException
73     * @throws MojoExecutionException
74     */
75    protected final File getGnuAOLTargetDirectory() throws MojoFailureException, MojoExecutionException {
76      return new File(getGnuAOLDirectory(), "target");
77    }
78  
79    protected final File getGnuSourceDirectory() {
80      return this.gnuSourceDirectory;
81    }
82  
83    /**
84     * Returns true if we do not want to use GNU on Windows
85     * 
86     * @return
87     */
88    protected final boolean useGnu() {
89      return this.gnuUseOnWindows || !NarUtil.isWindows();
90    }
91  }