com.metreeca.mark.mojos.MarkMojo Maven / Gradle / Ivy
/*
* Copyright © 2019-2023 Metreeca srl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.metreeca.mark.mojos;
import com.metreeca.mark.Opts;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.function.Function;
/**
* Base site goal.
*/
public abstract class MarkMojo extends AbstractMojo implements Opts {
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;
@Parameter(defaultValue = "${project.basedir}/docs/", property = "mark.source")
private String source;
@Parameter(defaultValue = "", property = "mark.target")
private String target;
@Parameter(defaultValue = "", property = "mark.layout")
private String layout;
@Parameter(defaultValue = "false", property = "mark.readme")
private boolean readme;
@Parameter
private Map options;
@Override public Path source() {
return Paths.get(source == null ? "" : source);
}
@Override public Path target() {
return Paths.get(target == null ? "" : target);
}
@Override public Path layout() { return Paths.get(layout == null ? "" : layout); }
@Override public boolean readme() {
return readme;
}
@Override public Map global() {
return Map.of("project", project);
}
@Override public V option(final String option, final Function mapper) {
return mapper.apply(options == null ? null : options.get(option));
}
@Override public Log logger() { return getLog(); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setProject(final MavenProject project) {
this.project=project;
}
void setSource(final String source) {
this.source=source;
}
void setTarget(final String target) {
this.target=target;
}
void setLayout(final String layout) {
this.layout=layout;
}
void setReadme(final boolean readme) {
this.readme=readme;
}
void setOptions(final Map options) {
this.options=options;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy