本文整理汇总了Java中org.codehaus.plexus.archiver.manager.NoSuchArchiverException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchArchiverException类的具体用法?Java NoSuchArchiverException怎么用?Java NoSuchArchiverException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchArchiverException类属于org.codehaus.plexus.archiver.manager包,在下文中一共展示了NoSuchArchiverException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createArchiveFile
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
private File createArchiveFile( File targetDirectory, String directory, String archiveExt )
throws NoSuchArchiverException, IOException, MojoExecutionException
{
final MavenArchiver mavenArchiver = new MavenArchiver();
mavenArchiver.setArchiver( jarArchiver );
jarArchiver.addFileSet( new DefaultFileSet( targetDirectory ) );
// jarArchiver.setDuplicateBehavior( duplicate );
File resultArchive = getArchiveFile( getOutputDirectory(), getFinalName(), directory, archiveExt );
mavenArchiver.setOutputFile( resultArchive );
try
{
mavenArchiver.createArchive( getMavenSession(), getMavenProject(), getArchive() );
}
catch ( ArchiverException | ManifestException | DependencyResolutionRequiredException e )
{
getLog().error( e.getMessage(), e );
throw new MojoExecutionException( e.getMessage(), e );
}
return resultArchive;
}
示例2: unpackCompiler
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
private void unpackCompiler() throws MojoExecutionException {
final File file = getArtifact(typescriptGroupId, typescriptArtifactId, typescriptClassifier, typescriptExtension, typescriptVersion);
final UnArchiver unarchiver;
try {
unarchiver = archiverManager.getUnArchiver(file);
}
catch (final NoSuchArchiverException e) {
throw new MojoExecutionException("Unsupported archive type for artifact " + file.getName());
}
final boolean createdDirectory = typescriptHome.mkdirs();
if (!createdDirectory) {
throw new MojoExecutionException("Unable to create tsc directory " + typescriptHome.getAbsolutePath());
}
getLog().info("Extracting tsc to " + typescriptHome.getAbsolutePath());
unarchiver.setSourceFile(file);
unarchiver.setDestDirectory(typescriptHome);
unarchiver.extract();
}
示例3: extract
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
/**
* Method description
*
*
* @param artifact
* @param target
*
* @throws MojoExecutionException
*/
private void extract(File artifact, File target) throws MojoExecutionException
{
logger.info("extract {} to {}", artifact, target);
try
{
UnArchiver unarchiver = archiverManager.getUnArchiver(artifact);
unarchiver.setSourceFile(artifact);
unarchiver.setDestDirectory(target);
unarchiver.extract();
}
catch (NoSuchArchiverException ex)
{
throw new MojoExecutionException("could not find unarchiver", ex);
}
}
示例4: createArchiveFile
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
private File createArchiveFile( File unpackDirectory, File targetDirectory, String directory, String archiveExt )
throws NoSuchArchiverException, IOException, MojoExecutionException
{
final MavenArchiver mavenArchiver = new MavenArchiver();
mavenArchiver.setArchiver( jarArchiver );
jarArchiver.addFileSet( new DefaultFileSet( targetDirectory ) );
jarArchiver.addFileSet( new DefaultFileSet( unpackDirectory ) );
// jarArchiver.setDuplicateBehavior( duplicate );
File resultArchive = getArchiveFile( getOutputDirectory(), getFinalName(), directory, archiveExt );
mavenArchiver.setOutputFile( resultArchive );
try
{
mavenArchiver.createArchive( getMavenSession(), getMavenProject(), getArchive() );
}
catch ( ArchiverException | ManifestException | DependencyResolutionRequiredException e )
{
getLog().error( e.getMessage(), e );
throw new MojoExecutionException( e.getMessage(), e );
}
return resultArchive;
}
示例5: shouldNotUnpackViewResourcesThatDoNotMatchTheFilters
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
@Test
public void shouldNotUnpackViewResourcesThatDoNotMatchTheFilters() throws MojoExecutionException,
MojoFailureException, NoSuchArchiverException, ArchiverException {
// Given
UnpackViewResources mojo = new UnpackViewResources() {
@Override
protected Embedder newEmbedder() {
return new Embedder();
}
};
ArchiverManager archiveManager = mock(ArchiverManager.class);
MavenProject project = mock(MavenProject.class);
File resourcesFile = new File("some");
Artifact someResources = mock(Artifact.class);
when(someResources.getArtifactId()).thenReturn("some-resources");
when(someResources.getType()).thenReturn("jar");
when(someResources.getFile()).thenReturn(resourcesFile);
Set<Artifact> allArtifacts = new HashSet<Artifact>();
allArtifacts.add(someResources);
String buildDirectory = "target";
Build build = new Build();
build.setDirectory(buildDirectory);
// When
mojo.project = project;
mojo.archiverManager = archiveManager;
mojo.resourceIncludes = "ftl/*";
mojo.resourcesExcludes = "com/*";
when(project.getArtifacts()).thenReturn(allArtifacts);
when(project.getBuild()).thenReturn(build);
mojo.execute();
// Then
verify(archiveManager, Mockito.never()).getUnArchiver(resourcesFile);
}
示例6: shouldNotIgnoreFailureInUnpackingViewResources
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
@Test(expected = MojoExecutionException.class)
public void shouldNotIgnoreFailureInUnpackingViewResources() throws MojoExecutionException, MojoFailureException,
NoSuchArchiverException, ArchiverException {
// Given
UnpackViewResources mojo = new UnpackViewResources() {
@Override
protected Embedder newEmbedder() {
return new Embedder();
}
};
ArchiverManager archiveManager = mock(ArchiverManager.class);
MavenProject project = mock(MavenProject.class);
File coreFile = new File("core");
Artifact coreResources = mock(Artifact.class);
when(coreResources.getArtifactId()).thenReturn("jbehave-core");
when(coreResources.getType()).thenReturn("zip");
when(coreResources.getFile()).thenReturn(coreFile);
File siteFile = new File("site");
Artifact siteResources = mock(Artifact.class);
when(siteResources.getArtifactId()).thenReturn("jbehave-site-resources");
when(siteResources.getType()).thenReturn("zip");
when(siteResources.getFile()).thenReturn(siteFile);
Set<Artifact> allArtifacts = new HashSet<Artifact>();
allArtifacts.add(coreResources);
allArtifacts.add(siteResources);
String buildDirectory = "target";
Build build = new Build();
build.setDirectory(buildDirectory);
UnArchiver coreArchiver = mock(UnArchiver.class);
UnArchiver siteArchiver = mock(UnArchiver.class);
// When
mojo.project = project;
mojo.archiverManager = archiveManager;
when(project.getArtifacts()).thenReturn(allArtifacts);
when(project.getBuild()).thenReturn(build);
when(archiveManager.getUnArchiver(coreFile)).thenReturn(coreArchiver);
when(archiveManager.getUnArchiver(siteFile)).thenReturn(siteArchiver);
Mockito.doThrow(new ArchiverException("bum")).when(siteArchiver).extract();
mojo.execute();
// Then
verify(coreArchiver).extract();
// and fail as expected ...
}
示例7: extractArtifact
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
private void extractArtifact(Artifact artifact, File destinationDirectory) throws MojoExecutionException {
try {
UnArchiver unArchiver = archiverManager.getUnArchiver(artifact.getFile());
unArchiver.setUseJvmChmod(true);
unArchiver.setIgnorePermissions(false);
unArchiver.setSourceFile(artifact.getFile());
unArchiver.setDestDirectory(destinationDirectory);
unArchiver.extract();
} catch (NoSuchArchiverException e) {
throw new MojoExecutionException("Could not find archiver for artifact " + artifact.getArtifactId());
}
}
示例8: getZipArchiver
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
protected ZipArchiver getZipArchiver() throws NoSuchArchiverException
{
ZipArchiver result = (ZipArchiver) archiverManager.getArchiver( "zip" );
result.setDuplicateBehavior( Archiver.DUPLICATES_FAIL ); // Just in case
return result;
}
示例9: getWarArchiver
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
protected WarArchiver getWarArchiver() throws NoSuchArchiverException
{
WarArchiver result = (WarArchiver) archiverManager.getArchiver( "war" );
result.setDuplicateBehavior( Archiver.DUPLICATES_FAIL ); // Just in case
return result;
}
示例10: shouldUnpackViewResources
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; //导入依赖的package包/类
@Test
public void shouldUnpackViewResources() throws MojoExecutionException, MojoFailureException,
NoSuchArchiverException, ArchiverException {
// Given
UnpackViewResources mojo = new UnpackViewResources() {
@Override
protected Embedder newEmbedder() {
return new Embedder();
}
};
ArchiverManager archiveManager = mock(ArchiverManager.class);
MavenProject project = mock(MavenProject.class);
File coreFile = new File("core");
Artifact coreResources = mock(Artifact.class);
when(coreResources.getArtifactId()).thenReturn("jbehave-core");
when(coreResources.getType()).thenReturn("zip");
when(coreResources.getFile()).thenReturn(coreFile);
File siteFile = new File("site");
Artifact siteResources = mock(Artifact.class);
when(siteResources.getArtifactId()).thenReturn("jbehave-site-resources");
when(siteResources.getType()).thenReturn("zip");
when(siteResources.getFile()).thenReturn(siteFile);
Set<Artifact> allArtifacts = new HashSet<Artifact>();
allArtifacts.add(coreResources);
allArtifacts.add(siteResources);
String buildDirectory = "target";
Build build = new Build();
build.setDirectory(buildDirectory);
UnArchiver coreArchiver = mock(UnArchiver.class);
UnArchiver siteArchiver = mock(UnArchiver.class);
// When
mojo.project = project;
mojo.archiverManager = archiveManager;
mojo.resourceIncludes = "ftl/*";
mojo.resourcesExcludes = "com/*";
when(project.getArtifacts()).thenReturn(allArtifacts);
when(project.getBuild()).thenReturn(build);
when(archiveManager.getUnArchiver(coreFile)).thenReturn(coreArchiver);
when(archiveManager.getUnArchiver(siteFile)).thenReturn(siteArchiver);
unpackTo(mojo, null); // default view directory
unpackTo(mojo, new File(System.getProperty("java.io.tmpdir")+"/jbehave/view"));
// Then
verify(coreArchiver, times(2)).extract();
verify(siteArchiver, times(2)).extract();
}