All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tools.bestquality.maven.ci.PropertyResolver Maven / Gradle / Ivy

There is a newer version: 0.0.20
Show newest version
package tools.bestquality.maven.ci;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;

import java.util.Properties;
import java.util.function.Supplier;

public class PropertyResolver {
    private final Supplier nullSupplier = () -> null;
    private final MavenProject project;
    private final MavenSession session;

    public PropertyResolver(MavenProject project, MavenSession session) {
        this.project = project;
        this.session = session;
    }

    public String resolve(String property, Supplier defaultValue) {
        Properties systemProperties = session.getSystemProperties();
        if (systemProperties.containsKey(property)) {
            return systemProperties.getProperty(property);
        }
        Properties properties = project.getProperties();
        return properties.containsKey(property)
                ? properties.getProperty(property)
                : defaultValue.get();
    }

    public String resolve(String property) {
        return resolve(property, nullSupplier);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy