本文整理汇总了Java中org.apache.tools.ant.taskdefs.Tar类的典型用法代码示例。如果您正苦于以下问题:Java Tar类的具体用法?Java Tar怎么用?Java Tar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tar类属于org.apache.tools.ant.taskdefs包,在下文中一共展示了Tar类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: tgz
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
public static File tgz(String folder) {
Project p = new Project();
p.init();
Tar tar = new Tar();
Tar.TarCompressionMethod method = new Tar.TarCompressionMethod();
method.setValue("gzip");
tar.setCompression(method);
tar.setProject(p);
File tgzFile = new File(folder + ".tgz");
tar.setDestFile(tgzFile);
tar.setBasedir(new File("."));
tar.setIncludes(folder + "/**");
tar.perform();
LOG.info("output file is {}", tgzFile);
return tgzFile;
}
开发者ID:tascape,项目名称:reactor,代码行数:19,代码来源:AntCompressor.java
示例2: springTgz
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
@RequestMapping(value = "/starter.tgz", produces = "application/x-compress")
@ResponseBody
public ResponseEntity<byte[]> springTgz(BasicProjectRequest basicRequest)
throws IOException {
ProjectRequest request = (ProjectRequest) basicRequest;
File dir = projectGenerator.generateProjectStructure(request);
File download = projectGenerator.createDistributionFile(dir, ".tar.gz");
dir.setExecutable(true);
Tar zip = new Tar();
zip.setProject(new Project());
zip.setDefaultexcludes(false);
TarFileSet set = zip.createTarFileSet();
set.setDir(dir);
set.setFileMode("755");
set.setDefaultexcludes(false);
set = zip.createTarFileSet();
set.setDir(dir);
set.setIncludes("**,");
set.setDefaultexcludes(false);
zip.setDestFile(download.getCanonicalFile());
Tar.TarCompressionMethod method = new Tar.TarCompressionMethod();
method.setValue("gzip");
zip.setCompression(method );
zip.execute();
return upload(download, dir, generateFileName(request, "tar.gz"),
"application/x-compress");
}
开发者ID:rvillars,项目名称:edoras-one-initializr,代码行数:30,代码来源:MainController.java
示例3: addFileToTar
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
private void addFileToTar(Tar tar, File file, String fullpath, String fileMode)
{
TarFileSet controlFileSet = tar.createTarFileSet ();
controlFileSet.setFile (file);
controlFileSet.setFullpath ("./" + fullpath);
controlFileSet.setFileMode (fileMode);
controlFileSet.setUserName ("root");
controlFileSet.setGroup ("root");
}
开发者ID:mscurtescu,项目名称:ant-deb-task,代码行数:12,代码来源:Deb.java
示例4: tgzTo
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
public TestFile tgzTo(TestFile tarFile) {
Tar tar = new Tar();
tar.setBasedir(this);
tar.setDestFile(tarFile);
tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
execute(tar);
return this;
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:9,代码来源:TestFile.java
示例5: tbzTo
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
public TestFile tbzTo(TestFile tarFile) {
Tar tar = new Tar();
tar.setBasedir(this);
tar.setDestFile(tarFile);
tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
execute(tar);
return this;
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:9,代码来源:TestFile.java
示例6: springTgz
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
@RequestMapping(value = "/starter.tgz", produces = "application/x-compress")
@ResponseBody
public ResponseEntity<byte[]> springTgz(BasicProjectRequest basicRequest)
throws IOException {
ProjectRequest request = (ProjectRequest) basicRequest;
File dir = projectGenerator.generateProjectStructure(request);
File download = projectGenerator.createDistributionFile(dir, ".tar.gz");
String wrapperScript = getWrapperScript(request);
new File(dir, wrapperScript).setExecutable(true);
Tar zip = new Tar();
zip.setProject(new Project());
zip.setDefaultexcludes(false);
TarFileSet set = zip.createTarFileSet();
set.setDir(dir);
set.setFileMode("755");
set.setIncludes(wrapperScript);
set.setDefaultexcludes(false);
set = zip.createTarFileSet();
set.setDir(dir);
set.setIncludes("**,");
set.setExcludes(wrapperScript);
set.setDefaultexcludes(false);
zip.setDestFile(download.getCanonicalFile());
Tar.TarCompressionMethod method = new Tar.TarCompressionMethod();
method.setValue("gzip");
zip.setCompression(method );
zip.execute();
return upload(download, dir, generateFileName(request, "tar.gz"),
"application/x-compress");
}
开发者ID:spring-io,项目名称:initializr,代码行数:33,代码来源:MainController.java
示例7: createMasterControlFile
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
private File createMasterControlFile () throws IOException
{
File controlFile = new File (_tempFolder, "control");
writeControlFile (controlFile, _installedSize);
File md5sumsFile = new File (_tempFolder, "md5sums");
File conffilesFile = new File (_tempFolder, "conffiles");
File masterControlFile = new File (_tempFolder, "control.tar.gz");
Tar controlTar = new Tar ();
controlTar.setProject (getProject ());
controlTar.setTaskName (getTaskName ());
controlTar.setDestFile (masterControlFile);
controlTar.setCompression (GZIP_COMPRESSION_METHOD);
addFileToTar (controlTar, controlFile, "control", "644");
addFileToTar (controlTar, md5sumsFile, "md5sums", "644");
if (conffilesFile.length () > 0)
addFileToTar (controlTar, conffilesFile, "conffiles", "644");
if (_preinst != null)
addFileToTar (controlTar, _preinst, "preinst", "755");
if (_postinst != null)
addFileToTar (controlTar, _postinst, "postinst", "755");
if (_prerm != null)
addFileToTar (controlTar, _prerm, "prerm", "755");
if (_postrm != null)
addFileToTar (controlTar, _postrm, "postrm", "755");
if (_config != null)
addFileToTar (controlTar, _config, "config", "755");
if (_templates != null)
addFileToTar (controlTar, _templates, "templates", "644");
if (_triggers != null)
addFileToTar (controlTar, _triggers, "triggers", "644");
controlTar.perform ();
deleteFileCheck(controlFile);
return masterControlFile;
}
开发者ID:mscurtescu,项目名称:ant-deb-task,代码行数:51,代码来源:Deb.java
示例8: createDataFile
import org.apache.tools.ant.taskdefs.Tar; //导入依赖的package包/类
private File createDataFile () throws IOException
{
File dataFile = new File (_tempFolder, "data.tar.gz");
Tar dataTar = new Tar ();
dataTar.setProject (getProject ());
dataTar.setTaskName (getTaskName ());
dataTar.setDestFile (dataFile);
dataTar.setCompression (GZIP_COMPRESSION_METHOD);
dataTar.setLongfile(GNU_LONGFILE_MODE);
if ( _data.size () > 0 )
{
// add folders
for (Iterator dataFoldersIter = _dataFolders.iterator (); dataFoldersIter.hasNext ();)
{
String targetFolder = (String) dataFoldersIter.next ();
TarFileSet targetFolderSet = dataTar.createTarFileSet ();
targetFolderSet.setFile (_tempFolder);
targetFolderSet.setFullpath (targetFolder);
targetFolderSet.setUserName ("root");
targetFolderSet.setGroup ("root");
}
// add actual data
for (int i = 0; i < _data.size (); i++)
{
TarFileSet data = (TarFileSet) _data.get (i);
if (data.getUserName() == null || data.getUserName().trim().length() == 0)
data.setUserName ("root");
if (data.getGroup() == null || data.getGroup().trim().length() == 0)
data.setGroup ("root");
dataTar.add (data);
}
dataTar.execute ();
}
else
{
// create an empty data.tar.gz file which is still a valid tar
TarOutputStream tarStream = new TarOutputStream(
new GZipOutputStream(
new BufferedOutputStream(new FileOutputStream(dataFile)),
Deflater.BEST_COMPRESSION
)
);
tarStream.close();
}
return dataFile;
}
开发者ID:mscurtescu,项目名称:ant-deb-task,代码行数:57,代码来源:Deb.java
注:本文中的org.apache.tools.ant.taskdefs.Tar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论