io.ultreia.java4all.config.plugin.ConfigMojoSupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of config-maven-plugin Show documentation
Show all versions of config-maven-plugin Show documentation
Maven plugin to use the config library
package io.ultreia.java4all.config.plugin;
/*-
* #%L
* Config :: Maven plugin
* %%
* Copyright (C) 2016 - 2018 Code Lutin, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import io.ultreia.java4all.config.io.spi.ConfigModelReader;
import io.ultreia.java4all.config.io.spi.ConfigModelWriter;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.nuiton.plugin.AbstractPlugin;
import org.nuiton.plugin.PluginHelper;
import java.io.File;
/**
* Created on 02/10/16.
*
* @author Tony Chemit - [email protected]
* @since 3.0
*/
abstract class ConfigMojoSupport extends AbstractPlugin {
/**
* Configuration description format {@code ini}, {@code toml} or {@code yaml}.
*
* Default value is {@code ini}.
*/
@Parameter(property = "config.format", defaultValue = "ini")
private String format;
/**
* The path of model file.
*
*
Default value is
* ${modelDirectory}/${modelName}.${format}
*/
@Parameter(property = "config.modelFile")
private File modelFile;
/**
* The source directory where to scan model file.
*/
@Parameter(property = "config.modelDirectory", defaultValue = "${basedir}/src/main/config", required = true)
private File modelDirectory;
/**
* Pour activer le mode verbeux.
*/
@Parameter(property = "config.verbose", defaultValue = "${maven.verbose}")
private boolean verbose;
/**
* Maven project.
*/
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;
private ConfigModelReader configReader;
private ConfigModelWriter configWriter;
@Override
protected void init() throws Exception {
if (isVerbose()) {
getLog().info("Use format: " + format);
}
configReader = ConfigModelReader.reader(format);
configWriter = ConfigModelWriter.writer(format);
}
@Override
public boolean isVerbose() {
return verbose;
}
@Override
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
@Override
public MavenProject getProject() {
return project;
}
@Override
public void setProject(MavenProject project) {
this.project = project;
}
ConfigModelWriter getConfigWriter() {
return configWriter;
}
ConfigModelReader getConfigReader() { return configReader; }
File getModelFile() {
return modelFile;
}
void setModelFile(String name) {
modelFile = PluginHelper.getFile(modelDirectory, name + "." + format);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy