hudson.Util.copyFile()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(249)

本文整理了Java中hudson.Util.copyFile()方法的一些代码示例,展示了Util.copyFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.copyFile()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:copyFile

Util.copyFile介绍

[英]Copies a single file by using Ant.
[中]

代码示例

代码示例来源:origin: jenkinsci/promoted-builds-plugin

  1. /**
  2. * Copy promotion definitions from existing job.
  3. */
  4. @Override
  5. public void onCopied(Item src, Item item) {
  6. JobPropertyImpl prop;
  7. if (src instanceof Job && (prop =
  8. ((Job<?,?>)src).getProperty(JobPropertyImpl.class)) != null) {
  9. File[] subdirs = prop.getRootDir().listFiles(new FileFilter() {
  10. public boolean accept(File child) {
  11. return child.isDirectory();
  12. }
  13. });
  14. if (subdirs != null) {
  15. prop = ((Job<?,?>)item).getProperty(JobPropertyImpl.class);
  16. for (File subdir : subdirs) try {
  17. Util.copyFile(new File(subdir, "config.xml"),
  18. new File(prop.getRootDirFor(subdir.getName()), "config.xml"));
  19. } catch (Exception e) {
  20. Logger.getLogger(CopyListener.class.getName()).log(Level.WARNING,
  21. "Failed to copy/load promotion " + subdir + " into new job", e);
  22. }
  23. // Trigger loading of these files
  24. prop.setOwner(prop.getOwner());
  25. }
  26. }
  27. }
  28. }

代码示例来源:origin: jenkinsci/android-emulator-plugin

  1. Util.copyFile(new File(snapshotDir, "snapshots.img"), snapshotsFile);

代码示例来源:origin: hudson/hudson-2.x

  1. /**
  2. * Copies an existing {@link TopLevelItem} to a new name.
  3. *
  4. * The caller is responsible for calling {@link ItemListener#fireOnCopied(Item, Item)}. This method
  5. * cannot do that because it doesn't know how to make the newly added item reachable from the parent.
  6. */
  7. @SuppressWarnings({"unchecked"})
  8. public synchronized <T extends TopLevelItem> T copy(T src, String name) throws IOException {
  9. acl.checkPermission(Job.CREATE);
  10. T result = (T)createProject(src.getDescriptor(),name,false);
  11. // copy config
  12. Util.copyFile(Items.getConfigFile(src).getFile(),Items.getConfigFile(result).getFile());
  13. // reload from the new config
  14. result = (T)Items.load(parent,result.getRootDir());
  15. result.onCopiedFrom(src);
  16. add(result);
  17. ItemListener.fireOnCopied(src,result);
  18. return result;
  19. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. Util.copyFile(Items.getConfigFile(src).getFile(), jobConfigFile);

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. /**
  2. * Copies an existing {@link TopLevelItem} to a new name.
  3. *
  4. * The caller is responsible for calling {@link ItemListener#fireOnCopied(Item, Item)}. This method
  5. * cannot do that because it doesn't know how to make the newly added item reachable from the parent.
  6. */
  7. @SuppressWarnings({"unchecked"})
  8. public synchronized <T extends TopLevelItem> T copy(T src, String name) throws IOException {
  9. acl.checkPermission(Job.CREATE);
  10. T result = (T)createProject(src.getDescriptor(),name,false);
  11. // copy config
  12. Util.copyFile(Items.getConfigFile(src).getFile(),Items.getConfigFile(result).getFile());
  13. // reload from the new config
  14. result = (T)Items.load(parent,result.getRootDir());
  15. result.onCopiedFrom(src);
  16. add(result);
  17. ItemListener.fireOnCopied(src,result);
  18. return result;
  19. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. /**
  2. * Copies an existing {@link TopLevelItem} to a new name.
  3. *
  4. * The caller is responsible for calling {@link ItemListener#fireOnCopied(Item, Item)}. This method
  5. * cannot do that because it doesn't know how to make the newly added item reachable from the parent.
  6. */
  7. @SuppressWarnings({"unchecked"})
  8. public synchronized <T extends TopLevelItem> T copy(T src, String name) throws IOException {
  9. acl.checkPermission(Job.CREATE);
  10. T result = (T)createProject(src.getDescriptor(),name,false);
  11. // copy config
  12. Util.copyFile(Items.getConfigFile(src).getFile(),Items.getConfigFile(result).getFile());
  13. // reload from the new config
  14. result = (T)Items.load(parent,result.getRootDir());
  15. result.onCopiedFrom(src);
  16. add(result);
  17. ItemListener.fireOnCopied(src,result);
  18. return result;
  19. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. Util.copyFile(srcConfigFile.getFile(), Items.getConfigFile(result).getFile());

相关文章