com.jslsolucoes.maven.plugin.resource.AddResourceMojo Maven / Gradle / Ivy
package com.jslsolucoes.maven.plugin.resource;
import java.io.File;
import java.io.IOException;
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 org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@Mojo(name = "add")
public class AddResourceMojo extends AbstractMojo {
@Parameter(property = "skip")
private boolean skip = false;
@Parameter(property = "location", required = true)
private File location;
@Parameter(property = "content", required = true)
private String content;
@Parameter(property = "encoding")
private String encoding = "UTF-8";
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!skip) {
try {
getLog().info("adding resource on " + location);
FileUtils.write(location, content, encoding);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage());
}
} else {
getLog().info("Skipping add resource execution");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy