com.nitorcreations.willow.maven.PropertiesMojo Maven / Gradle / Ivy
package com.nitorcreations.willow.maven;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import com.nitorcreations.willow.utils.MergeableProperties;
@Mojo(name = "properties", defaultPhase = LifecyclePhase.GENERATE_TEST_RESOURCES, threadSafe = true)
public class PropertiesMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.build.directory}/application.properties", property = "outputFile", required = true)
private File outputFile;
@Parameter(required = false)
private String[] prefixes;
@Parameter(defaultValue = "root.properties", property = "rootProperties", required = true)
private String rootProperties;
@Parameter(defaultValue = "${project}", required = true)
private MavenProject project;
@Override
public void execute() throws MojoExecutionException {
ensureDir(outputFile.getParentFile());
if (prefixes == null || prefixes.length == 0) {
prefixes = new String[] { "file:" + project.getBuild().getTestOutputDirectory() + "/" };
}
Properties tmp = new Properties();
tmp.putAll(project.getProperties());
for (Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy