Fix checkstyle warnings in yang-test-plugin.
[controller.git] / opendaylight / config / yang-test-plugin / src / main / java / org / opendaylight / controller / config / yang / test / plugin / DeleteSources.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.config.yang.test.plugin;
9
10 import java.io.File;
11 import org.apache.maven.plugin.AbstractMojo;
12 import org.apache.maven.plugin.MojoExecutionException;
13 import org.apache.maven.plugin.MojoFailureException;
14
15 /**
16  * Delete all Module/ModuleFactory sources
17  *
18  * @goal delete-sources
19  *
20  * @phase initialize
21  */
22 public class DeleteSources extends AbstractMojo{
23     /**
24      * @parameter expression="${project.build.sourceDirectory}"
25      * @readOnly
26      * @required
27      */
28     private File directory;
29
30     @Override
31     public void execute() throws MojoExecutionException, MojoFailureException {
32         if (directory == null || !directory.exists()) {
33             super.getLog().error("Directory does not exists.");
34         }
35         File sourceDirectory = new File(directory.getPath() + Util.replaceDots(".org.opendaylight.controller.config.yang.test.impl"));
36         if (sourceDirectory == null || !sourceDirectory.exists()) {
37             super.getLog().error(String.format("Source directory does not exists %s", sourceDirectory.getPath()));
38         }
39         File[] sourceFiles = sourceDirectory.listFiles();
40         for (File sourceFile: sourceFiles) {
41             if(sourceFile.getName().endsWith("Module.java") || sourceFile.getName().endsWith("ModuleFactory.java")) {
42                 super.getLog().debug(String.format("Source file deleted: %s", sourceFile.getName()));
43                 sourceFile.delete();
44             }
45         }
46     }
47 }