当前位置: 首页>>代码示例>>Java>>正文


Java ArchiverException类代码示例

本文整理汇总了Java中org.codehaus.plexus.archiver.ArchiverException的典型用法代码示例。如果您正苦于以下问题:Java ArchiverException类的具体用法?Java ArchiverException怎么用?Java ArchiverException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ArchiverException类属于org.codehaus.plexus.archiver包,在下文中一共展示了ArchiverException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createArchiveFile

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的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;

}
 
开发者ID:khmarbaise,项目名称:multienv-maven-plugin,代码行数:27,代码来源:ConfigurationMojo.java

示例2: createIvyArchive

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
private void createIvyArchive(File sourceDir, File targetIar) throws MojoExecutionException
{
  ZipArchiver archiver = new ZipArchiver();
  archiver.setDestFile(targetIar);
  archiver.addFileSet(getDefaultFileset(sourceDir));
  FileSetConverter fsConverter = new FileSetConverter(project.getBasedir());
  for(org.codehaus.plexus.archiver.FileSet fs : fsConverter.toPlexusFileSets(iarFileSets))
  {
    archiver.addFileSet(fs);
  }
  try
  {
    archiver.createArchive();
  }
  catch (ArchiverException | IOException ex)
  {
    throw new MojoExecutionException("Failed to create IAR: " + targetIar.getAbsolutePath(), ex);
  }
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:20,代码来源:IarPackagingMojo.java

示例3: getFiles

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
private Iterator<PlexusIoResource> getFiles(final File contentDirectory) throws IOException
{
    if (!contentDirectory.isDirectory())
    {
        throw new ArchiverException(contentDirectory.getAbsolutePath() + " is not a directory.");
    }

    final PlexusIoFileResourceCollection collection = new PlexusIoFileResourceCollection();

    collection.setIncludes(getIncludes());
    collection.setExcludes(getExcludes());
    collection.setBaseDir(contentDirectory);
    collection.setIncludingEmptyDirectories(false);
    collection.setPrefix("");
    collection.setUsingDefaultExcludes(true);

    return collection.getResources();
}
 
开发者ID:electronicarts,项目名称:ea-async,代码行数:19,代码来源:AbstractAsyncMojo.java

示例4: generateArchive

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
private File generateArchive(File outDir, String archiveFilename) throws IOException, ArchiverException {
    File zipFile = new File(buildDir, archiveFilename);
    if (zipFile.exists()) {
        zipFile.delete();
    }

    zipArchiver.addDirectory(outDir);
    zipArchiver.setDestFile(zipFile);
    zipArchiver.createArchive();

    return zipFile;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:13,代码来源:SchemaDocMojo.java

示例5: createArchiveFile

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的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;

}
 
开发者ID:khmarbaise,项目名称:multienv-maven-plugin,代码行数:28,代码来源:EnvironmentMojo.java

示例6: unzip

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
public void unzip(File output, String groupId, String artifactId, String version)
        throws MojoExecutionException {
    output.mkdirs();
    archiver.setDestDirectory(output);
    for(Artifact artifact: resolve(groupId, artifactId, version)) {
        archiver.setSourceFile(artifact.getFile());
        try {
            archiver.extract();
        } catch (ArchiverException e) {
            throw new MojoExecutionException("could not unzip: " + artifact, e);
        }
    }
}
 
开发者ID:torquebox,项目名称:jruby9-maven-plugins,代码行数:14,代码来源:ArtifactHelper.java

示例7: checkPotentialReactorProblem

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
private void checkPotentialReactorProblem( Artifact artifact )
{
    File artifactFile = artifact.getFile();
    if ( artifactFile.isDirectory() )
    {
        throw new ArchiverException(
                                     String.format( "\"%s:%s:%s:%s\" dependent artifact's file is a directory, not a file. This is probably Maven reactor build problem.",
                                                    artifact.getGroupId(), artifact.getArtifactId(),
                                                    artifact.getType(), artifact.getBaseVersion() ) );
    }
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:12,代码来源:PlayDependenciesMojo.java

示例8: performPackaging

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
/**
 * Generates the mar.
 * 
 * @param marFile
 *            the target mar file
 * @throws IOException
 * @throws ArchiverException
 * @throws ManifestException
 * @throws DependencyResolutionRequiredException
 */
private void performPackaging( File marFile )
    throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException,
    MojoExecutionException
{

    buildExplodedMar( );

    // generate mar file
    getLog().info( "Generating mar " + marFile.getAbsolutePath() );
    MavenArchiver archiver = new MavenArchiver();
    archiver.setArchiver( jarArchiver );
    archiver.setOutputFile( marFile );
    jarArchiver.addDirectory( marDirectory );

    // create archive
    archiver.createArchive( project, archive );

    if ( classifier != null )
    {
        projectHelper.attachArtifact( project, "mar", classifier, marFile );
    }
    else
    {
        Artifact artifact = project.getArtifact();
        if ( primaryArtifact )
        {
            artifact.setFile( marFile );
        }
        else if ( artifact.getFile() == null || artifact.getFile().isDirectory() )
        {
            artifact.setFile( marFile );
        }
        else
        {
            projectHelper.attachArtifact( project, "mar", marFile );
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:49,代码来源:MarMojo.java

示例9: performPackaging

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
/**
 * Generates the aar.
 *
 * @param aarFile the target aar file
 * @throws IOException
 * @throws ArchiverException
 * @throws ManifestException
 * @throws DependencyResolutionRequiredException
 *
 */
private void performPackaging(File aarFile)
        throws IOException, ArchiverException, ManifestException,
        DependencyResolutionRequiredException,
        MojoExecutionException {

    buildExplodedAar();

    // generate aar file
    getLog().info("Generating aar " + aarFile.getAbsolutePath());
    MavenArchiver archiver = new MavenArchiver();
    archiver.setArchiver(jarArchiver);
    archiver.setOutputFile(aarFile);
    jarArchiver.addDirectory(aarDirectory);

    // create archive
    archiver.createArchive(project, archive);

    if (classifier != null) {
        projectHelper.attachArtifact(project, "aar", classifier, aarFile);
    } else {
        Artifact artifact = project.getArtifact();
        if (primaryArtifact) {
            artifact.setFile(aarFile);
        } else if (artifact.getFile() == null || artifact.getFile().isDirectory()) {
            artifact.setFile(aarFile);
        } else {
            projectHelper.attachArtifact(project, "aar", aarFile);
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:41,代码来源:AarMojo.java

示例10: extractApklib

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
public void extractApklib( Artifact apklibArtifact ) throws MojoExecutionException
{
    final File apkLibFile = artifactResolverHelper.resolveArtifactToFile( apklibArtifact );
    if ( apkLibFile.isDirectory() )
    {
        log.warn(
                "The apklib artifact points to '" + apkLibFile + "' which is a directory; skipping unpacking it." );
        return;
    }

    final UnArchiver unArchiver = new ZipUnArchiver ( apkLibFile )
    {
        @Override
        protected Logger getLogger()
        {
            return new ConsoleLogger( log.getThreshold(), "dependencies-unarchiver" );
        }
    };

    final File apklibDirectory = getUnpackedLibFolder( apklibArtifact );
    apklibDirectory.mkdirs();
    unArchiver.setDestDirectory( apklibDirectory );
    log.debug( "Extracting APKLIB to " + apklibDirectory );
    try
    {
        unArchiver.extract();
    }
    catch ( ArchiverException e )
    {
        throw new MojoExecutionException ( "ArchiverException while extracting " + apklibDirectory
                + ". Message: " + e.getLocalizedMessage(), e );
    }
}
 
开发者ID:simpligility,项目名称:android-ndk-maven-plugin,代码行数:34,代码来源:UnpackedLibHelper.java

示例11: shouldNotUnpackViewResourcesThatDoNotMatchTheFilters

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的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);
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:41,代码来源:EmbedderMojoBehaviour.java

示例12: shouldNotIgnoreFailureInUnpackingViewResources

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的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 ...
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:52,代码来源:EmbedderMojoBehaviour.java

示例13: copyFile

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
/**
 * Copy file from source to destination. The directories up to <code>destination</code> will be created if they
 * don't already exist. if the <code>onlyIfModified</code> flag is <tt>false</tt>, <code>destination</code> will be
 * overwritten if it already exists. If the flag is <tt>true</tt> destination will be overwritten if it's not up to
 * date.
 * <p/>
 *
 * @param context the packaging context
 * @param source an existing non-directory <code>File</code> to copy bytes from
 * @param destination a non-directory <code>File</code> to write bytes to (possibly overwriting).
 * @param targetFilename the relative path of the file from the webapp root directory
 * @param onlyIfModified if true, copy the file only if the source has changed, always copy otherwise
 * @return true if the file has been copied/updated, false otherwise
 * @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot be written to, or an
 *             IO error occurs during copying
 */
protected boolean copyFile( WarPackagingContext context, File source, File destination, String targetFilename,
                            boolean onlyIfModified )
    throws IOException
{
    if ( onlyIfModified && destination.lastModified() >= source.lastModified() )
    {
        context.getLog().debug( " * " + targetFilename + " is up to date." );
        return false;
    }
    else
    {
        if ( source.isDirectory() )
        {
            context.getLog().warn( " + " + targetFilename + " is packaged from the source folder" );

            try
            {
                JarArchiver archiver = context.getJarArchiver();
                archiver.addDirectory( source );
                archiver.setDestFile( destination );
                archiver.createArchive();
            }
            catch ( ArchiverException e )
            {
                String msg = "Failed to create " + targetFilename;
                context.getLog().error( msg, e );
                IOException ioe = new IOException( msg );
                ioe.initCause( e );
                throw ioe;
            }
        }
        else
        {
            FileUtils.copyFile( source.getCanonicalFile(), destination );
            // preserve timestamp
            destination.setLastModified( source.lastModified() );
            context.getLog().debug( " + " + targetFilename + " has been copied." );
        }
        return true;
    }
}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:58,代码来源:AbstractWarPackagingTask.java

示例14: execute

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
/**
    * 
    */    
public void execute() throws MojoExecutionException, MojoFailureException 
{
    if ( puXMLFile == null || !FileUtils.fileExists( puXMLFile ) )
    {
        throw new MojoExecutionException( "missing pu.xml file" );
    }
        
    if ( warFile == null || !FileUtils.fileExists( warFile ) )
    {
        throw new MojoExecutionException( "missing war file" );
    }
    
    try
       {
        String puTargetDir = serverDirectory + File.separator + "META-INF" + File.separator + "spring";
        String libTargetDir = serverDirectory + File.separator + "lib";
        
        FileUtils.mkdir( serverDirectory );	        
        FileUtils.mkdir( puTargetDir );
        FileUtils.mkdir( libTargetDir );
        
           FileUtils.copyFileToDirectory( new File( puXMLFile ), new File( puTargetDir ) );
           FileUtils.copyFileToDirectory( new File( warFile ), new File( serverDirectory ) );
           
           
            for (Iterator artifactIterator = pluginArtifacts.iterator(); artifactIterator.hasNext();) 
            {
               Artifact artifact = (Artifact) artifactIterator.next();
               if (artifact.getGroupId().equals("org.mortbay.jetty") ) 
               {
                   FileUtils.copyFileToDirectory( artifact.getFile().getPath(), libTargetDir );
               }
            }
            
            jarArchiver.addDirectory( new File(serverDirectory) );
            jarArchiver.setDestFile( new File(artifactName) );
            jarArchiver.createArchive();
       }
       catch ( IOException ioe )
       {
           throw new MojoExecutionException( "unable to assemble",ioe );
       }
       catch ( ArchiverException ae )
       {
           throw new MojoExecutionException( "unable to assembly jar", ae );
       }
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:51,代码来源:JOSGeneratePUMojo.java

示例15: expandArchive

import org.codehaus.plexus.archiver.ArchiverException; //导入依赖的package包/类
protected void expandArchive( Archiver archiver, File destDirectory )
    throws IOException
{
    for ( ResourceIterator iter = archiver.getResources(); iter.hasNext(); )
    {
        ArchiveEntry entry = iter.next();
        String name = entry.getName();
        name = name.replace( File.separatorChar, '/' );
        File destFile = new File( destDirectory, name );

        switch ( entry.getType() )
        {
            case ArchiveEntry.DIRECTORY:
                if ( !destFile.exists() )
                {
                    getLog().debug( "adding directory " + name + '/' );
                    if ( !destFile.mkdirs() )
                    {
                        throw new IOException( "Unable to create directory: " + destFile );
                    }
                }
                break;
            case ArchiveEntry.FILE:
                PlexusIoResource resource = entry.getResource();
                boolean skip = false;
                if ( !destFile.exists() )
                {
                    getLog().debug( "adding file " + name );
                }
                else
                {
                    long resLastModified = resource.getLastModified();
                    if ( resLastModified != PlexusIoResource.UNKNOWN_MODIFICATION_DATE )
                    {
                        long destFileLastModified = destFile.lastModified();
                        if ( resLastModified <= destFileLastModified )
                        {
                            skip = true;
                        }
                        else
                        {
                            getLog().debug( "updating file " + name );
                        }
                    }
                }
                if ( !skip )
                {
                    InputStream contents = resource.getContents();
                    RawInputStreamFacade facade = new RawInputStreamFacade( contents );
                    FileUtils.copyStreamToFile( facade, destFile );
                }
                break;
            default:
                throw new ArchiverException( "Unknown archive entry type: " + entry.getType() );
        }
    }
}
 
开发者ID:play1-maven-plugin,项目名称:play1-maven-plugin,代码行数:58,代码来源:AbstractArchivingMojo.java


注:本文中的org.codehaus.plexus.archiver.ArchiverException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。