Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.utils.DependencySilentLog;
Expand Down Expand Up @@ -86,7 +87,7 @@ public abstract class AbstractDependencyMojo extends AbstractMojo {
/**
* If the plugin should be silent.
*
* @deprecated to be removed in 4.0; use -Q command line option instead
* @deprecated to be removed in 4.0; use -q command line option instead
* @since 2.0
*/
@Deprecated
Expand Down Expand Up @@ -181,13 +182,15 @@ protected final boolean isSilent() {

/**
* @param silent {@link #silent}
* @deprecated to be removed in 4.0; no API replacement, use -Q command line option instead
* @deprecated to be removed in 4.0; no API replacement, use -q command line option instead
*/
@Deprecated
public void setSilent(boolean silent) {
this.silent = silent;
if (silent) {
setLog(new DependencySilentLog());
} else if (getLog() instanceof DependencySilentLog) {
setLog(new SystemStreamLog());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@

import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.testing.SilentLog;
import org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo;
import org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo;
import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
import org.apache.maven.plugins.dependency.utils.DependencySilentLog;
import org.apache.maven.plugins.dependency.utils.DependencyStatusSets;
import org.apache.maven.project.MavenProject;

public class TestCollectMojo extends AbstractDependencyMojoTestCase {

@Override
protected void setUp() throws Exception {
// required for mojo lookups to work
super.setUp("markers", false);
Expand Down Expand Up @@ -98,10 +100,15 @@ public void testCollectTestEnvironment_excludeTransitive() throws Exception {
}

public void testSilent() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml");
CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", testPom);
mojo.setSilent(false);
File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);

assertFalse(mojo.getLog() instanceof DependencySilentLog);

assertFalse(mojo.getLog() instanceof SilentLog);
mojo.setSilent(true);
assertTrue(mojo.getLog() instanceof DependencySilentLog);

mojo.setSilent(false);
assertFalse(mojo.getLog() instanceof DependencySilentLog);
} // TODO: Test skipping artifacts.
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@

import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.testing.SilentLog;
import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase;
import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
import org.apache.maven.plugins.dependency.utils.DependencySilentLog;
import org.apache.maven.plugins.dependency.utils.DependencyStatusSets;
import org.apache.maven.project.MavenProject;

public class TestResolveMojo extends AbstractDependencyMojoTestCase {

@Override
protected void setUp() throws Exception {
// required for mojo lookups to work
super.setUp("markers", false);
Expand All @@ -47,7 +48,7 @@ protected void setUp() throws Exception {
*
* @throws Exception in case of errors.
*/
public void testresolveTestEnvironment() throws Exception {
public void testResolveTestEnvironment() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);

Expand Down Expand Up @@ -79,8 +80,13 @@ public void testresolveTestEnvironment() throws Exception {
public void testSilent() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);
mojo.setSilent(false);

assertFalse(mojo.getLog() instanceof SilentLog);
assertFalse(mojo.getLog() instanceof DependencySilentLog);

mojo.setSilent(true);
assertTrue(mojo.getLog() instanceof DependencySilentLog);

mojo.setSilent(false);
assertFalse(mojo.getLog() instanceof DependencySilentLog);
} // TODO: Test skipping artifacts.
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.plugins.dependency.utils;

import org.apache.maven.plugin.logging.Log;
import org.junit.Assert;
import org.junit.Test;

public class TestSilentLog {
Expand All @@ -40,9 +41,9 @@ public void testLog() {
log.error(text);
log.error(text, e);
log.error(e);
log.isDebugEnabled();
log.isErrorEnabled();
log.isWarnEnabled();
log.isInfoEnabled();
Assert.assertFalse(log.isDebugEnabled());
Assert.assertFalse(log.isErrorEnabled());
Assert.assertFalse(log.isWarnEnabled());
Assert.assertFalse(log.isInfoEnabled());
}
}