org.basepom.mojo.dvc.PluginLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-versions-check-maven-plugin Show documentation
Show all versions of dependency-versions-check-maven-plugin Show documentation
The dependency-versions-check plugin verifies that all resolved
versions of artifacts are at least the versions specified by
the project dependencies.
The Maven dependency resolution process will substitute versions for
the different artifacts in a dependency tree and sometimes chooses incompatible
versions which leads to difficult to detect problems.
This plugin resolves all dependencies and collects any requested version. It evaluates
whether the resolved versions are compatible to the requested versions and reports possible
conflicts.
The newest version!
/*
* 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 org.basepom.mojo.dvc;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import org.apache.maven.shared.utils.logging.MessageBuilder;
import org.apache.maven.shared.utils.logging.MessageUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class PluginLog {
private final Logger logger;
public PluginLog(final Class> clazz) {
checkNotNull(clazz, "clazz is null");
this.logger = LoggerFactory.getLogger(clazz);
}
public void debug(final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
synchronized (logger) {
logger.debug(format(fmt, args));
}
}
public void debug(final Throwable t, final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
checkNotNull(t, "t is null");
synchronized (logger) {
logger.debug(format(fmt, args), t);
}
}
public void info(final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
synchronized (logger) {
logger.info(format(fmt, args));
}
}
public void info(final Throwable t, final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
checkNotNull(t, "t is null");
synchronized (logger) {
logger.info(format(fmt, args), t);
}
}
public void warn(final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
MessageBuilder mb = MessageUtils.buffer();
synchronized (logger) {
logger.warn(mb.warning(format(fmt, args)).toString());
}
}
public void warn(final Throwable t, final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
checkNotNull(t, "t is null");
MessageBuilder mb = MessageUtils.buffer();
synchronized (logger) {
logger.warn(mb.warning(format(fmt, args)).toString(), t);
}
}
public void error(final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
MessageBuilder mb = MessageUtils.buffer();
synchronized (logger) {
logger.error(mb.failure(format(fmt, args)).toString());
}
}
public void error(final Throwable t, final String fmt, final Object... args) {
checkNotNull(fmt, "fmt is null");
checkNotNull(t, "t is null");
MessageBuilder mb = MessageUtils.buffer();
synchronized (logger) {
logger.error(mb.failure(format(fmt, args)).toString(), t);
}
}
public void report(final boolean quiet, final String fmt, final Object... args) {
if (quiet) {
debug(fmt, args);
} else {
info(fmt, args);
}
}
}