![JAR search and dependency download from the Maven repository](/logo.png)
ch.sourcepond.maven.plugin.repobuilder.ArtifactCopier Maven / Gradle / Ivy
The newest version!
/*Copyright (C) 2015 Roland Hauser,
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 ch.sourcepond.maven.plugin.repobuilder;
import static java.nio.file.Files.copy;
import static java.nio.file.Files.createDirectories;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import java.io.IOException;
import java.nio.file.Path;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.plugin.MojoExecutionException;
/**
* Component to copy an artifacts content to a new path.
*/
@Named
@Singleton
class ArtifactCopier {
/**
* Copies the original file specified to the copy path specified. If the
* copy path already exists, it will be overwritten.
*
* @param pOriginal
* Path to copy; must be a file and not {@code null}
* @param pCopy
* Path where to copy the original file; must be non-existent or
* must point to a file. Must not be {@code null}.
* @throws MojoExecutionException
* Thrown if an {@link IOException} occurred during copy.
*/
public void copyToDedicatedRepository(final Path pOriginal, final Path pCopy) throws MojoExecutionException {
try {
createDirectories(pCopy.getParent());
copy(pOriginal, pCopy, REPLACE_EXISTING);
} catch (final IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy