org.apache.tools.ant.taskdefs.Expand类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(159)

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

Expand介绍

[英]Unzip a file.
[中]解压缩文件。

代码示例

代码示例来源:origin: jenkinsci/jenkins

private static void unzipExceptClasses(File archive, File destDir, Project prj) {
  Expand e = new Expand();
  e.setProject(prj);
  e.setTaskType("unzip");
  e.setSrc(archive);
  e.setDest(destDir);
  PatternSet p = new PatternSet();
  p.setExcludes("WEB-INF/classes/");
  e.addPatternset(p);
  e.execute();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2me-common-ant

private void extractZip(final File source, final File target) throws BuildException
{
  final Expand e = new Expand();
  e.setProject(getProject());
  e.setOverwrite(false);
  if (excludeManifest)
  {
    final PatternSet ps = new PatternSet();
    ps.setExcludes("META-INF,META-INF/MANIFEST.MF"); //NOI18N
    e.addPatternset(ps);
  }
  e.setSrc(source);
  e.setDest(target);
  e.execute();
}

代码示例来源:origin: codehaus-cargo/cargo

/**
 * Unpacks the zip file containing the container files.
 * @throws IOException If the ZIP file is broken
 */
private void unpack() throws IOException
{
  File targetDir = new File(getExtractDir());
  File sourceFile = new File(getDownloadDir(), getSourceFileName());
  getLogger().info(
    "Installing container [" + sourceFile + "] in [" + targetDir.getPath() + "]",
      getClass().getName());
  Expand expandTask = createExpandTask();
  expandTask.setSrc(sourceFile);
  expandTask.setDest(targetDir);
  expandTask.execute();
  if (!targetDir.isDirectory())
  {
    throw new IOException("The file [" + sourceFile + "] is broken");
  }
}

代码示例来源:origin: stackoverflow.com

Project p = new Project();
p.init();
Expand ex = new Expand();
ex.setProject(p);
ex.setSrc(new File("myArchive.zip"));
ex.setDest(new File("targetDir"));
ex.perform();

代码示例来源:origin: HuaweiBigData/StreamCQL

private Expand createExpand(File jarFile)
{
  String outputDir = expandDir + File.separator + jarFile.getName();
  Project prj = new Project();
  FileSet fileSet = createFileSetForJarFile(jarFile, prj);
  PatternSet patternSet = createPatternSet(prj);
  Expand expand = new Expand();
  expand.setProject(prj);
  expand.setOverwrite(true);
  expand.setDest(new File(outputDir));
  expand.addFileset(fileSet);
  expand.addPatternset(patternSet);
  return expand;
}

代码示例来源:origin: ldcsaa/JessMA

/** 获取解压任务对象 */
  @Override
  protected Task getTask()
  {
    Project project    = new Project();
    Expand expand    = getExpand();
    PatternSet ps    = getPatternSet();

    expand.setProject(project);
    expand.setSrc(getSourceFile());
    expand.setDest(getTargetDir());
    expand.setOverwrite(isOverwrite());
    
    if(ps != null)
    {
      ps.setProject(project);
      expand.addPatternset(ps);
    }

    return expand;
  }
}

代码示例来源:origin: ldcsaa/JessMA

/** 获取解压任务对象 */
@Override
protected Expand getExpand()
{
  Expand expand = new Expand();
  
  if(encoding != null)
    expand.setEncoding(encoding);
  
  return expand;
}

代码示例来源:origin: HuaweiBigData/StreamCQL

private void unzipJar(String jar)
  throws IOException
{
  File jarFile = new File(jar);
  LOG.info("unzip jar {} to {}", jar, expandDir.getCanonicalPath());
  Expand expand = createExpand(jarFile);
  expand.execute();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-antext

private void extractZip(final File source, final File target) throws BuildException
{
  final Expand e = new Expand();
  e.setProject(getProject());
  e.setOverwrite(false);
  if (excludeManifest)
  {
    final PatternSet ps = new PatternSet();
    ps.setExcludes("META-INF,META-INF/MANIFEST.MF"); //NOI18N
    e.addPatternset(ps);
  }
  e.setSrc(source);
  e.setDest(target);
  e.execute();
}

代码示例来源:origin: codehaus-cargo/cargo

/**
   * Test start with one expanded WAR.
   * @throws Exception If anything goes wrong.
   */
  public void testStartWithOneExpandedWarDeployed() throws Exception
  {
    // The Apache Geronimo server doesn't support expanded WARs
    if (getContainer().getId().startsWith("geronimo"))
    {
      return;
    }

    // Copy the war from the Maven local repository in order to expand it
    File artifactDir = new File(getTestData().targetDir).getParentFile();
    Expand expandTask = (Expand) new AntUtils().createProject().createTask("unwar");
    expandTask.setDest(new File(artifactDir, "expanded-war"));
    expandTask.setSrc(new File(getTestData().getTestDataFileFor("expanded-war")));
    expandTask.execute();

    Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
      new File(artifactDir, "expanded-war").getPath(), DeployableType.WAR);

    getLocalContainer().getConfiguration().addDeployable(war);

    URL warPingURL = new URL("http://localhost:" + getTestData().port
      + "/expanded-war" + "/index.html");

    startAndStop(warPingURL);
  }
}

代码示例来源:origin: spring-io/initializr

private void unzip(File archiveFile, File project) {
  Expand expand = new Expand();
  expand.setProject(new Project());
  expand.setDest(project);
  expand.setSrc(archiveFile);
  expand.execute();
}

代码示例来源:origin: codehaus-cargo/cargo

/**
   * Test expanded WAR with a <code>context.xml</code> file.
   * @throws Exception If anything goes wrong.
   */
  public void testExpandedWarWithContextXmlFile() throws Exception
  {
    // Copy the war from the Maven local repository in order to expand it
    File artifactDir = new File(getTestData().targetDir).getParentFile();
    Expand expandTask = (Expand) new AntUtils().createProject().createTask("unwar");
    expandTask.setDest(new File(artifactDir, "tomcat-context"));
    expandTask.setSrc(new File(getTestData().getTestDataFileFor("tomcatcontext-war")));
    expandTask.execute();

    Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
      new File(artifactDir, "tomcat-context").getPath(), DeployableType.WAR);

    getLocalContainer().getConfiguration().addDeployable(war);

    URL warPingURL = new URL("http://localhost:" + getTestData().port + "/tomcat-context/");

    getLocalContainer().start();
    PingUtils.assertPingTrue("tomcat context war not started", "Test value is [test value]",
      warPingURL, getLogger());

    getLocalContainer().stop();
    PingUtils.assertPingFalse("tomcat context war not stopped", warPingURL, getLogger());
  }
}

代码示例来源:origin: io.tesla.jettyconsole/jetty-console-creator

private void extractWar(File file) throws CreatorExecutionException {
 Project project = new Project();
 Expand unArchiver = new Expand();
 unArchiver.setProject(project);
 unArchiver.setSrc(file);
 unArchiver.setDest(workingDirectory);
 unArchiver.execute();
}

代码示例来源:origin: codehaus-cargo/cargo

expandTask.setDest(new File(artifactDir, "tomcat-context"));
expandTask.setSrc(new File(getTestData().getTestDataFileFor("tomcatcontext-war-link-simple"
    + "-jar")));
expandTask.execute();

代码示例来源:origin: org.simplericity.jettyconsole/jetty-console-creator

private void extractWar(File file) throws CreatorExecutionException {
  Project project = new Project();
  Expand unArchiver = new Expand();
  unArchiver.setProject(project);
  unArchiver.setSrc(file);
  unArchiver.setDest(workingDirectory);
  unArchiver.execute();
}

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

private static void unzipExceptClasses(File archive, File destDir, Project prj) {
  Expand e = new Expand();
  e.setProject(prj);
  e.setTaskType("unzip");
  e.setSrc(archive);
  e.setDest(destDir);
  PatternSet p = new PatternSet();
  p.setExcludes("WEB-INF/classes/");
  e.addPatternset(p);
  e.execute();
}

代码示例来源:origin: dita-ot/dita-ot

private File unzip(final File input) {
  final File tempPluginDir = new File(tempDir, "plugin");
  final Expand unzip = new Expand();
  unzip.setProject(getProject());
  unzip.setTaskName("unzip");
  unzip.setSrc(input);
  unzip.setDest(tempPluginDir);
  unzip.execute();
  return findBaseDir(tempPluginDir);
}

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  if(!destDir.exists())
    destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteContentsRecursive(destDir);
  try {
    Expand e = new Expand();
    e.setProject(new Project());
    e.setTaskType("unzip");
    e.setSrc(archive);
    e.setDest(destDir);
    e.execute();
  } catch (BuildException x) {
    throw new IOException2("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  if(!destDir.exists())
    destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteContentsRecursive(destDir);
  try {
    Expand e = new Expand();
    e.setProject(new Project());
    e.setTaskType("unzip");
    e.setSrc(archive);
    e.setDest(destDir);
    e.execute();
  } catch (BuildException x) {
    throw new IOException2("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  if(!destDir.exists())
    destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteContentsRecursive(destDir);
  try {
    Expand e = new Expand();
    e.setProject(new Project());
    e.setTaskType("unzip");
    e.setSrc(archive);
    e.setDest(destDir);
    e.execute();
  } catch (BuildException x) {
    throw new IOException2("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

相关文章