*/
package org.opendaylight.controller.config.yang.test.plugin;
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-
+import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.regex.Pattern;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
/**
* Add implementation code from stub.txt
}
File sourceDirectory = new File(directory.getPath() + Util.replaceDots(".org.opendaylight.controller.config.yang.test.impl"));
if (!sourceDirectory.exists()) {
- super.getLog().error("Source directory does not exists " + sourceDirectory.getPath());
+ super.getLog().error(String.format("Source directory does not exists %s", sourceDirectory.getPath()));
}
File[] sourceFiles = sourceDirectory.listFiles();
if (sourceFile.getName().endsWith(".java")) {
String sourceContent;
try {
- sourceContent = FileUtils.readFileToString(sourceFile);
+ sourceContent = Files.toString(sourceFile, StandardCharsets.UTF_8);
} catch (IOException e) {
- getLog().error("Cannot read " + sourceFile.getAbsolutePath(), e);
+ getLog().error(String.format("Cannot read %s", sourceFile.getAbsolutePath()), e);
continue;
}
if (sourceFile.getName().endsWith("Module.java") || sourceFile.getName().endsWith("ModuleFactory.java")) {
if (stubFile.exists()) {
String stubContent = null;
try {
- stubContent = FileUtils.readFileToString(stubFile);
+ stubContent = Files.toString(stubFile, StandardCharsets.UTF_8);
} catch (IOException e) {
- getLog().error("Cannot read " + stubFile.getAbsolutePath(), e);
+ getLog().error(String.format("Cannot read %s", stubFile.getAbsolutePath()), e);
}
if (stubContent != null) {
sourceContent = rewriteStub(sourceContent, stubContent);
// replace the file content
try {
- FileUtils.write(sourceFile, sourceContent);
+ Files.write(sourceContent, sourceFile, StandardCharsets.UTF_8);
} catch (IOException e) {
- getLog().error("Cannot write " + sourceFile.getAbsolutePath(), e);
+ getLog().error(String.format("Cannot write %s", sourceFile.getAbsolutePath()), e);
}
}