• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TarFileSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: springTgz

import org.apache.tools.ant.types.TarFileSet; //导入依赖的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


示例2: springTgz

import org.apache.tools.ant.types.TarFileSet; //导入依赖的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


示例3: addTarFileset

import org.apache.tools.ant.types.TarFileSet; //导入依赖的package包/类
public void addTarFileset(TarFileSet fileset) {
    filesets.add(fileset);
}
 
开发者ID:jindrapetrik,项目名称:jbomutils,代码行数:4,代码来源:MkBomTask.java


示例4: execute

import org.apache.tools.ant.types.TarFileSet; //导入依赖的package包/类
@Override
public void execute() {
    validate();
    System.out.println("MkBom: Creating BOM file to \"" + destFile + "\" ...");
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    Set<String> dirs = new HashSet<>();
    Set<String> files = new HashSet<>();
    for (TarFileSet fs : filesets) {

        String fullPath = fs.getFullpath(project);
        String prefix = fs.getPrefix(project);
        String fileNames[] = getFileNames(fs);

        long gid = fs.hasGroupIdBeenSet() ? fs.getGid() : Long.MAX_VALUE;
        long uid = fs.hasUserIdBeenSet() ? fs.getUid() : Long.MAX_VALUE;
        for (int i = 0; i < fileNames.length; i++) {
            String targetName;
            String fileName = fileNames[i];

            if (!fullPath.isEmpty()) {
                targetName = fullPath;
            } else {
                targetName = prefix + fileName;
            }
            targetName = targetName.replace('\\', '/');
            if (targetName.isEmpty()) {
                targetName = ".";
            }
            if (!targetName.equals(".")) {
                String path_parts[] = ("./" + targetName).split("/");
                String pdir = "";
                String dirname = targetName.contains("/") ? targetName.substring(0, targetName.lastIndexOf("/")) : "";
                if (!dirs.contains(dirname)) {
                    for (int p = 0; p < path_parts.length - 1/*Last is filename*/; p++) {
                        String pname = path_parts[p];
                        if (!pdir.isEmpty()) {
                            pdir += "/";
                        }
                        pdir += pname;
                        if (!dirs.contains(pdir)) {
                            if (verbose) {
                                System.out.println("MkBom: Adding parent dir \"" + pdir + "\" ...");
                            }
                            if (fullPath.isEmpty() && (pdir + "/").startsWith(prefix)) {
                                PrintNode.print_node(output, fs.getDir(project).getAbsolutePath(), ((prefix.equals(pdir + "/")) ? prefix : pdir).replace("/", File.separator).substring(prefix.length()), pdir, uid, gid, false, fs.hasDirModeBeenSet() ? fs.getDirMode(project) : -1);
                            } else {
                                PrintNode.print_custom_node(output, pdir, uid, gid, Stat.S_IFDIR + (fs.hasDirModeBeenSet() ? fs.getDirMode(project) : 0777));
                            }
                        }
                        dirs.add(pdir);
                        if (pdir.equals(".")) {
                            pdir = "";
                        }
                    }
                }
            }
            if (verbose) {
                System.out.println("MkBom: Adding \"" + targetName + "\" ...");
            }
            if (files.contains(targetName)) {
                continue;
            }
            files.add(targetName);
            PrintNode.print_node(output, fs.getDir(project).getAbsolutePath(), fileName, targetName, uid, gid, false, fs.hasFileModeBeenSet() ? fs.getFileMode(project) : -1);
        }

    }

    try {
        MkBom.write_bom(new ByteArrayInputStream(output.toByteArray()), destFile);
        System.out.println("MkBom: File created in \"" + destFile + "\"");
    } catch (IOException ex) {
        throw new BuildException("MkBom: Cannot write to \"" + destFile + "\"", ex);
    }

}
 
开发者ID:jindrapetrik,项目名称:jbomutils,代码行数:77,代码来源:MkBomTask.java


示例5: getPackages

import org.apache.tools.ant.types.TarFileSet; //导入依赖的package包/类
public List<Map<String, Object>> getPackages() throws IOException {
	List<Map<String, Object>> packages = new ArrayList<Map<String, Object>>();

	for (SPK spk : spks) {
		log("Include SPK: " + spk.file.getName());

		// make sure file is cached locally
		if (spk.url != null) {
			log("Using " + spk.url);
			if (!spk.file.exists()) {
				spk.file.getParentFile().mkdirs();
			}
			if (spk.url == null) {
				spk.url = spk.url;
			}
			Get get = new Get();
			get.bindToOwner(this);
			get.setQuiet(true);
			get.setUseTimestamp(true);
			get.setSrc(spk.url);
			get.setDest(spk.file);
			get.execute();
		} else {
			log("Using " + spk.file);
		}

		// import SPK INFO
		Map<String, Object> info = new LinkedHashMap<String, Object>();

		TarFileSet tar = new TarFileSet();
		tar.setProject(getProject());
		tar.setSrc(spk.file);
		tar.setIncludes(INFO);
		for (Resource resource : tar) {
			if (INFO.equals(resource.getName())) {
				String text = FileUtils.readFully(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8));
				for (String line : NEWLINE.split(text)) {
					String[] s = line.split("=", 2);
					if (s.length == 2) {
						if (s[1].startsWith("\"") && s[1].endsWith("\"")) {
							s[1] = s[1].substring(1, s[1].length() - 1);
						}
						importSpkInfo(info, s[0], s[1]);
					}
				}
			}
		}
		log(String.format("Imported %d fields from SPK: %s", info.size(), info.keySet()));

		// add thumbnails and snapshots
		if (spk.thumbnail.size() > 0) {
			info.put(THUMBNAIL, spk.thumbnail.toArray(new String[0]));
		}
		if (spk.snapshot.size() > 0) {
			info.put(SNAPSHOT, spk.snapshot.toArray(new String[0]));
		}

		// add user-defined fields
		info.putAll(spk.infoList);

		// automatically generate file size and checksum fields
		if (!info.containsKey(LINK)) {
			info.put(LINK, spk.url);
		}

		info.put(MD5, md5(spk.file));
		info.put(SHA256, sha256(spk.file));
		info.put(SIZE, spk.file.length());

		packages.add(info);
	}

	return packages;
}
 
开发者ID:rednoah,项目名称:ant-spk,代码行数:75,代码来源:RepositoryTask.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NumberReplicas类代码示例发布时间:2022-05-23
下一篇:
Java PullCallback类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap