View Javadoc
1   package org.codehaus.mojo.natives.compiler;
2   
3   /*
4    * The MIT License
5    *
6    * Copyright (c) 2004, The Codehaus
7    *
8    * Permission is hereby granted, free of charge, to any person obtaining a copy of
9    * this software and associated documentation files (the "Software"), to deal in
10   * the Software without restriction, including without limitation the rights to
11   * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12   * of the Software, and to permit persons to whom the Software is furnished to do
13   * so, subject to the following conditions:
14   * 
15   * The above copyright notice and this permission notice shall be included in all
16   * copies or substantial portions of the Software.
17   * 
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24   * SOFTWARE.
25   */
26  
27  import java.io.File;
28  
29  import org.codehaus.mojo.natives.ConfigurationBase;
30  import org.codehaus.plexus.util.FileUtils;
31  
32  public class ResourceCompilerConfiguration
33      extends ConfigurationBase
34  {
35      private static final File[] EMPTY_FILE_ARRAY = new File[0];
36  
37      private static final String[] EMPTY_STRING_ARRAY = new String[0];
38  
39      /**
40       * Must be in your path
41       */
42      private String executable = "";
43  
44      private File workingDirectory;
45  
46      private File outputDirectory;
47  
48      private File debugOutputDirectory;
49  
50      private String[] options = EMPTY_STRING_ARRAY;
51  
52      private File[] includePaths = EMPTY_FILE_ARRAY;
53  
54      private File[] systemIncludePaths = EMPTY_FILE_ARRAY;
55  
56      public ResourceCompilerConfiguration()
57      {
58      }
59  
60      public String getExecutable()
61      {
62          return this.executable;
63      }
64  
65      public void setExecutable( String executable )
66      {
67          this.executable = executable;
68      }
69  
70      public File getWorkingDirectory()
71      {
72          return this.workingDirectory;
73      }
74  
75      public void setWorkingDirectory( File dir )
76      {
77          this.workingDirectory = dir;
78      }
79  
80      public String[] getOptions()
81      {
82          return this.options;
83      }
84  
85      public void setOptions( String[] options )
86      {
87          this.options = options;
88  
89          if ( this.options == null )
90          {
91              this.options = EMPTY_STRING_ARRAY;
92          }
93      }
94  
95      public File getOutputDirectory()
96      {
97          return this.outputDirectory;
98      }
99  
100     public void setOutputDirectory( File dir )
101     {
102         this.outputDirectory = dir;
103     }
104 
105     public File getDebugOutputDirectory()
106     {
107         return this.debugOutputDirectory;
108     }
109 
110     public void setDebugOutputDirectory( File dir )
111     {
112         this.debugOutputDirectory = dir;
113     }
114 
115     public File[] getIncludePaths()
116     {
117         return this.includePaths;
118     }
119 
120     public void setIncludePaths( File[] paths )
121     {
122         this.includePaths = paths;
123 
124         if ( this.includePaths == null )
125         {
126             this.includePaths = EMPTY_FILE_ARRAY;
127         }
128     }
129 
130     public File[] getSystemIncludePaths()
131     {
132         return this.systemIncludePaths;
133     }
134 
135     public void setSystemIncludePaths( File[] paths )
136     {
137         this.systemIncludePaths = paths;
138 
139         if ( this.systemIncludePaths == null )
140         {
141             this.systemIncludePaths = EMPTY_FILE_ARRAY;
142         }
143     }
144 
145     // //////////////////////////////////////////////////////////
146     // HELPER
147     // /////////////////////////////////////////////////////////
148     public File getOutputFile( File src )
149     {
150         String srcPath = src.getPath();
151 
152         String destPath = this.getOutputDirectory().getPath() + "/" + FileUtils.basename( srcPath ) + "res";
153 
154         return new File( destPath );
155     }
156 
157 }