Skip to content
Open
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
8 changes: 4 additions & 4 deletions src/it/projects/copy-dependencies-with-conflict/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ assert file.exists()

String buildLog = file.getText( "UTF-8" )
assert buildLog.contains( '[WARNING] Overwriting ' )
assert buildLog.contains( '[DEBUG] Copying artifact \'org.jdom:jdom:jar:1.1.3\'' )
assert buildLog.contains( '[DEBUG] Copying artifact \'org.jdom:jdom:pom:1.1.3\'' )
assert buildLog.contains( '[DEBUG] Copying artifact \'org.jdom:jdom:jar:1.1.3\'' )
assert buildLog.contains( '[DEBUG] Copying artifact \'org.lucee:jdom:jar:1.1.3\'' )
assert buildLog.contains( '[INFO] Copying artifact \'org.jdom:jdom:jar:1.1.3\'' )
assert buildLog.contains( '[INFO] Copying artifact \'org.jdom:jdom:pom:1.1.3\'' )
assert buildLog.contains( '[INFO] Copying artifact \'org.jdom:jdom:jar:1.1.3\'' )
assert buildLog.contains( '[INFO] Copying artifact \'org.lucee:jdom:jar:1.1.3\'' )
assert buildLog.contains( '[WARNING] Multiple files with the name jdom-1.1.3.jar in the dependency tree.' )

return true
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +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.Parameter;
import org.apache.maven.plugins.dependency.utils.DependencySilentLog;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
Expand Down Expand Up @@ -61,16 +59,6 @@ public abstract class AbstractDependencyMojo extends AbstractMojo {
*/
protected final MavenSession session;

/**
* If the plugin should be silent.
*
* @since 2.0
* @deprecated to be removed in 4.0; use -q command line option instead
*/
@Deprecated
@Parameter(property = "silent", defaultValue = "false")
private boolean silent;

/**
* Skip plugin execution completely.
*
Expand Down Expand Up @@ -172,27 +160,4 @@ public boolean isSkip() {
public void setSkip(boolean skip) {
this.skip = skip;
}

/**
* @return {@link #silent}
* @deprecated to be removed in 4.0
*/
@Deprecated
protected final boolean isSilent() {
return silent;
}

/**
* @param silent {@link #silent}
* @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 @@ -92,6 +92,15 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo
@Parameter(property = "mdep.overIfNewer", defaultValue = "true")
private boolean overIfNewer;

/**
* If the plugin should be more silent with logging.
* <br/>
* Use {@code -q} command line option if you want to suppress all output.
* @since 2.0
*/
@Parameter(property = "silent", defaultValue = "false")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be deprecated as it was where it was moved from

private boolean silent;

/**
* Overwrite if newer.
*
Expand Down Expand Up @@ -386,6 +395,13 @@ public void setLocalRepositoryDirectory(File localRepositoryDirectory) {
this.localRepositoryDirectory = localRepositoryDirectory;
}

/**
* @return {@link #silent}
*/
protected final boolean isSilent() {
return silent;
}

/**
* @param artifact the artifact
* @throws MojoFailureException in case of an error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
*
* @param artifactItem containing the information about the artifact to copy
* @throws MojoExecutionException with a message if an error occurs
* @see CopyUtil#copyArtifactFile(Artifact, File)
* @see CopyUtil#copyArtifactFile(Artifact, File, boolean)
*/
protected void copyArtifact(ArtifactItem artifactItem) throws MojoExecutionException {
File destFile = new File(artifactItem.getOutputDirectory(), artifactItem.getDestFileName());
if (destFile.exists()) {
getLog().warn("Overwriting " + destFile);
}
try {
copyUtil.copyArtifactFile(artifactItem.getArtifact(), destFile);
copyUtil.copyArtifactFile(artifactItem.getArtifact(), destFile, isSilent());
} catch (IOException e) {
throw new MojoExecutionException(
"Failed to copy artifact '" + artifactItem.getArtifact() + "' ("
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void unpackArtifact(ArtifactItem artifactItem) throws MojoExecutionExcep
artifactItem.getEncoding(),
ignorePermissions,
artifactItem.getFileMappers(),
getLog());
isSilent());
handler.setMarker();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil
@Parameter(property = "mdep.failOnMissingClassifierArtifact", defaultValue = "false")
protected boolean failOnMissingClassifierArtifact;

/**
* If the plugin should be more silent with logging.
* <br/>
* Use {@code -q} command line option if you want to suppress all output.
* @since 2.0
*/
@Parameter(property = "silent", defaultValue = "false")
private boolean silent;

protected AbstractFromDependenciesMojo(
MavenSession session,
BuildContext buildContext,
Expand Down Expand Up @@ -233,4 +242,11 @@ public boolean isUseRepositoryLayout() {
public void setUseRepositoryLayout(boolean useRepositoryLayout) {
this.useRepositoryLayout = useRepositoryLayout;
}

/**
* @return {@link #silent}
*/
protected final boolean isSilent() {
return silent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected void copyArtifact(
* @param useBaseVersion specifies if the baseVersion of the artifact should be used instead of the version
* @param removeClassifier specifies if the classifier should be removed from the file name when copying
* @throws MojoExecutionException with a message if an error occurs
* @see CopyUtil#copyArtifactFile(Artifact, File)
* @see CopyUtil#copyArtifactFile(Artifact, File, boolean)
* @see DependencyUtil#getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, boolean, File, Artifact)
*/
private static final String SIGNATURE_EXTENSION = ".asc";
Expand Down Expand Up @@ -267,7 +267,7 @@ protected void copyArtifact(
getLog().warn("Overwriting " + destFile);
}
try {
copyUtil.copyArtifactFile(artifact, destFile);
copyUtil.copyArtifactFile(artifact, destFile, isSilent());

// Copy the signature file if the copySignatures flag is true
if (copySignatures) {
Expand Down Expand Up @@ -307,7 +307,7 @@ private void copySignatureFile(Artifact artifact, File destDir, String destFileN
if (signatureFile != null && signatureFile.exists()) {
File signatureDestFile = new File(destDir, destFileName + SIGNATURE_EXTENSION);
try {
copyUtil.copyFile(signatureFile, signatureDestFile);
copyUtil.copyFile(signatureFile, signatureDestFile, isSilent());
} catch (IOException e) {
getLog().warn("Failed to copy signature file: " + signatureFile, e);
}
Expand Down Expand Up @@ -354,7 +354,7 @@ public void copyPoms(File destDir, Set<Artifact> artifacts, boolean removeVersio
pomArtifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier));
if (!pomDestFile.exists()) {
try {
copyUtil.copyArtifactFile(pomArtifact, pomDestFile);
copyUtil.copyArtifactFile(pomArtifact, pomDestFile, isSilent());
} catch (IOException e) {
throw new MojoExecutionException(
"Failed to copy artifact '" + pomArtifact + "' (" + pomArtifact.getFile() + ") to "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected void doExecute() throws MojoExecutionException {
getEncoding(),
ignorePermissions,
getFileMappers(),
getLog());
isSilent());
DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(artifact, this.markersDirectory);
handler.setMarker();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.utils.DependencyUtil;
import org.apache.maven.plugins.dependency.utils.ResolverUtil;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -64,6 +65,15 @@ public class GoOfflineMojo extends AbstractResolveMojo {

private final DependencyResolver dependencyResolver;

/**
* If the plugin should be more silent with logging.
* <br/>
* Use {@code -q} command line option if you want to suppress all output.
* @since 2.0
*/
@Parameter(property = "silent", defaultValue = "false")
private boolean silent;

@Inject
// CHECKSTYLE_OFF: ParameterNumber
public GoOfflineMojo(
Expand Down Expand Up @@ -93,7 +103,7 @@ protected void doExecute() throws MojoExecutionException {

final Set<Artifact> dependencies = resolveDependencyArtifacts();

if (!isSilent()) {
if (!silent) {
for (Artifact artifact : plugins) {
this.getLog().info("Resolved plugin: " + DependencyUtil.getFormattedFileName(artifact, false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,26 @@ public CopyUtil(BuildContext buildContext) {
*
* @param sourceArtifact the artifact (file) to copy
* @param destination file name of destination file
* @param silent if true, don't show information about copied files
* @throws IOException if copy has failed
* @throws MojoExecutionException if artifact file is a directory (which has not been packaged yet)
* @since 3.7.0
*/
public void copyArtifactFile(Artifact sourceArtifact, File destination) throws IOException, MojoExecutionException {
public void copyArtifactFile(Artifact sourceArtifact, File destination, boolean silent)
throws IOException, MojoExecutionException {
File source = sourceArtifact.getFile();
if (source.isDirectory()) {
// usual case is a future jar packaging, but there are special cases: classifier and other packaging
throw new MojoExecutionException("Artifact '" + sourceArtifact
+ "' has not been packaged yet (is a directory). When used on reactor artifact, "
+ "copy should be executed after packaging: see MDEP-187.");
}
logger.debug("Copying artifact '{}' ({}) to {}", sourceArtifact.getId(), sourceArtifact.getFile(), destination);

if (!silent || logger.isDebugEnabled()) {
logger.info(
"Copying artifact '{}' ({}) to {}", sourceArtifact.getId(), sourceArtifact.getFile(), destination);
}

FileUtils.copyFile(source, destination);
buildContext.refresh(destination);
}
Expand All @@ -77,11 +84,14 @@ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws I
*
* @param source the source file to copy
* @param destination the destination file
* @param silent if true, don't show information about copied files
* @throws IOException if copy has failed
* @since 3.2.0
*/
public void copyFile(File source, File destination) throws IOException {
logger.debug("Copying file '{}' to {}", source, destination);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really can't see why this should be anything other than debug by default. This is not an actionable message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg. When using copy mojo from cli I need an information what was copied for auditing

public void copyFile(File source, File destination, boolean silent) throws IOException {
if (!silent || logger.isDebugEnabled()) {
logger.info("Copying file '{}' to {}", source, destination);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and now if the user turns on debugging but this is silent they don't see this

}
FileUtils.copyFile(source, destination);
buildContext.refresh(destination);
}
Expand Down
Loading
Loading