本文整理汇总了Java中org.codehaus.plexus.archiver.zip.ZipArchiver.setDestFile方法的典型用法代码示例。如果您正苦于以下问题:Java ZipArchiver.setDestFile方法的具体用法?Java ZipArchiver.setDestFile怎么用?Java ZipArchiver.setDestFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.archiver.zip.ZipArchiver
的用法示例。
在下文中一共展示了ZipArchiver.setDestFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIvyArchive
import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的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);
}
}
示例2: attachGeneratedIncludeFilesAsIncZip
import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的package包/类
private void attachGeneratedIncludeFilesAsIncZip()
throws MojoExecutionException
{
try
{
ZipArchiver archiver = new ZipArchiver();
DefaultFileSet fileSet = new DefaultFileSet();
fileSet.setUsingDefaultExcludes( true );
fileSet.setDirectory( javahOutputDirectory );
archiver.addFileSet( fileSet );
archiver.setDestFile( this.incZipFile );
archiver.createArchive();
if ( StringUtils.isBlank( this.classifier ) )
{
projectHelper.attachArtifact( this.project, INCZIP_TYPE, null, this.incZipFile );
}
else
{
projectHelper.attachArtifact( this.project, INCZIP_TYPE, this.classifier, this.incZipFile );
}
}
catch ( Exception e )
{
throw new MojoExecutionException( "Unable to archive/deploy generated include files", e );
}
}
示例3: execute
import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的package包/类
/**
*
* @throws MojoExecutionException if an unexpected problem occurs
* @throws MojoFailureException if an expected problem occurs
*/
public void execute()
throws MojoExecutionException, MojoFailureException
{
try
{
File nbmBuildDirFile = new File( outputDirectory, brandingToken );
ZipArchiver archiver = new ZipArchiver();
DefaultFileSet fs = new DefaultFileSet();
fs.setDirectory( outputDirectory );
fs.setIncludes( new String[] {
brandingToken + "/**",
} );
fs.setExcludes( new String[] {
brandingToken + "/bin/*",
} );
archiver.addFileSet( fs );
File bins = new File( nbmBuildDirFile, "bin" );
for ( File bin : bins.listFiles() )
{
archiver.addFile( bin, brandingToken + "/bin/" + bin.getName(), 0755 );
}
File zipFile = new File( outputDirectory, finalName + ".zip" );
//TODO - somehow check for last modified content to see if we shall be
//recreating the zip file.
archiver.setDestFile( zipFile );
archiver.setForced( false );
archiver.createArchive();
project.getArtifact().setFile( zipFile );
}
catch ( Exception ex )
{
throw new MojoExecutionException( "", ex );
}
}
示例4: archiveWar
import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的package包/类
/**
* @param jarFile Jar file to be created
* @param sourceFolder Jar file will be created out of the contents of this folder. This corresponds to the root
* folder of the jar file once it is created.
*/
public static void archiveWar( File jarFile, String sourceFolder ) throws MojoExecutionException {
try {
ZipArchiver archiver = new ZipArchiver();
archiver.enableLogging( new ConsoleLogger( org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console" ) );
archiver.setDestFile( jarFile );
archiver.addDirectory( new File( sourceFolder ), "", new String[] { "**/*" }, null );
archiver.createArchive();
}
catch ( Exception e ) {
throw new MojoExecutionException( "Error while creating WAR file", e );
}
}
示例5: execute
import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的package包/类
public void execute()
throws MojoExecutionException
{
if ( skipIncludeDeployment )
{
return;
}
if ( this.sources.length != 0 )
{
try
{
ZipArchiver archiver = new ZipArchiver();
boolean zipIt = false;
for ( int i = 0; i < sources.length; ++i )
{
if ( sources[i].isDeployable() )
{
DefaultFileSet fileSet = new DefaultFileSet();
fileSet.setUsingDefaultExcludes( true );
fileSet.setDirectory( sources[i].getDirectory() );
fileSet.setIncludes( sources[i].getIncludes() );
fileSet.setExcludes( sources[i].getExcludes() );
archiver.addFileSet( fileSet );
zipIt = true;
}
}
if ( zipIt )
{
archiver.setDestFile( this.incZipFile );
archiver.createArchive();
projectHelper.attachArtifact( this.project, INCZIP_TYPE, null, this.incZipFile );
}
}
catch ( Exception e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
}
}
示例6: testWithValidRoboconfDependencies
import org.codehaus.plexus.archiver.zip.ZipArchiver; //导入方法依赖的package包/类
@Test
public void testWithValidRoboconfDependencies() throws Exception {
// Prepare the project
final String projectName = "project--valid";
File baseDir = this.resources.getBasedir( projectName );
Assert.assertNotNull( baseDir );
Assert.assertTrue( baseDir.isDirectory());
AbstractMojo mojo = findMojo( projectName, "resolve" );
this.rule.setVariableValueToObject( mojo, "repoSystem", newRepositorySystem());
this.rule.setVariableValueToObject( mojo, "repositories", new ArrayList<RemoteRepository>( 0 ));
// Create a Roboconf application
File dir = this.folder.newFolder();
File targetZipFile = this.folder.newFile();
Assert.assertTrue( targetZipFile.delete());
CreationBean bean = new CreationBean()
.projectDescription( "some desc" ).projectName( "my-project" )
.groupId( "net.roboconf" ).projectVersion( "1.0-SNAPSHOT" ).mavenProject( false );
ProjectUtils.createProjectSkeleton( dir, bean );
ZipArchiver zipArchiver = new ZipArchiver();
zipArchiver.addDirectory( dir );
zipArchiver.setCompress( true );
zipArchiver.setDestFile( targetZipFile );
zipArchiver.createArchive();
Assert.assertTrue( targetZipFile.isFile());
// Add dependencies
MavenProject project = (MavenProject) this.rule.getVariableValueFromObject( mojo, "project" );
project.setDependencyArtifacts( new HashSet<Artifact> ());
Artifact rbcfArtifact3 = new DefaultArtifact( "net.roboconf", "roboconf-core", "0.2", "runtime", "jar", null, new DefaultArtifactHandler());
rbcfArtifact3.setFile( targetZipFile );
project.getDependencyArtifacts().add( rbcfArtifact3 );
// Add it to our "local" repository
this.artifactIdToArtifact.put( rbcfArtifact3.getArtifactId(), rbcfArtifact3 );
// Execute it
File targetDir = new File( baseDir, MavenPluginConstants.TARGET_MODEL_DIRECTORY + "/" + Constants.PROJECT_DIR_GRAPH );
Assert.assertFalse( targetDir.isDirectory());
mojo.execute();
// Verify the import was copied in the right location
File importDir = new File( targetDir, "net.roboconf/roboconf-core" );
Assert.assertTrue( importDir.isDirectory());
Assert.assertTrue( new File( importDir, "main.graph" ).isFile());
}