Skip to content

Commit

Permalink
[MDEP-956][MDEP-932] Silence artifact copying (#436)
Browse files Browse the repository at this point in the history
* [MDEP-956] Silence artifact copying
* move logging to debug level
  • Loading branch information
elharo authored Oct 12, 2024
1 parent 706f200 commit b15f69e
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,34 @@
@Singleton
public class CopyUtil {

private final Logger logger = LoggerFactory.getLogger(CopyUtil.class);

private final BuildContext buildContext;

private final Logger logger = LoggerFactory.getLogger(CopyUtil.class);

@Inject
public CopyUtil(BuildContext buildContext) {
this.buildContext = buildContext;
}

/**
* Does the actual copy of the artifact (file) and logging.
* Copies the artifact (file).
*
* @param sourceArtifact represents the artifact (file) to copy.
* @param destination file name of destination file.
* @param sourceArtifact represents the artifact (file) to copy
* @param destination file name of destination file
* @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 {
logger.info("Copying artifact '{}' ({}) to {}", sourceArtifact, sourceArtifact.getFile(), destination);

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, sourceArtifact.getFile(), destination);
FileUtils.copyFile(source, destination);
buildContext.refresh(destination);
}
Expand Down

0 comments on commit b15f69e

Please sign in to comment.