View Javadoc
1   /*
2    * YuiCompressor Maven plugin
3    *
4    * Copyright 2012-2024 Hazendaz.
5    *
6    * Licensed under the GNU Lesser General Public License (LGPL),
7    * version 2.1 or later (the "License").
8    * You may not use this file except in compliance with the License.
9    * You may read the licence in the 'lgpl.txt' file in the root folder of
10   * project or obtain a copy at
11   *
12   *     https://www.gnu.org/licenses/lgpl-2.1.html
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" basis,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  package net.alchim31.maven.yuicompressor;
21  
22  import java.io.IOException;
23  
24  import org.apache.maven.plugins.annotations.LifecyclePhase;
25  import org.apache.maven.plugins.annotations.Mojo;
26  
27  /**
28   * Check JS files with jslint.
29   */
30  @Mojo(name = "jslint", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresProject = true, threadSafe = true)
31  public class JSLintMojo extends MojoSupport {
32  
33      /** The jslint. */
34      private JSLintChecker jslint;
35  
36      @Override
37      protected String[] getDefaultIncludes() {
38          return new String[] { "**/**.js" };
39      }
40  
41      @Override
42      public void beforeProcess() throws IOException {
43          jslint = new JSLintChecker();
44      }
45  
46      @Override
47      public void afterProcess() {
48          // Do nothing
49      }
50  
51      @Override
52      protected void processFile(SourceFile src) throws IOException {
53          getLog().info("check file :" + src.toFile());
54          jslint.check(src.toFile(), jsErrorReporter);
55      }
56  }