com.liferay.gradle.util.FileUtil类的使用及代码示例

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

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

FileUtil介绍

暂无

代码示例

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-source-formatter

private String _relativizeDir(File dir, File startDir) {
  String relativePath = FileUtil.relativize(dir, startDir);
  if (!relativePath.isEmpty()) {
    if (File.separatorChar != '/') {
      relativePath = relativePath.replace(File.separatorChar, '/');
    }
    if (relativePath.charAt(relativePath.length() - 1) != '/') {
      relativePath += '/';
    }
  }
  return relativePath;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-deployment-helper

protected String getDeploymentFileNames() {
  StringBuilder sb = new StringBuilder();
  for (File file : getDeploymentFiles()) {
    sb.append(FileUtil.getAbsolutePath(file));
    sb.append(',');
  }
  sb.setLength(sb.length() - 1);
  return sb.toString();
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-app-javadoc-builder

private String _getPackageName(File file, Set<File> srcDirs) {
  File dir = null;
  for (File srcDir : srcDirs) {
    if (FileUtil.isChild(file, srcDir)) {
      dir = srcDir;
      break;
    }
  }
  if (dir == null) {
    return null;
  }
  String relativePath = FileUtil.relativize(file, dir);
  relativePath = relativePath.substring(
    0, relativePath.lastIndexOf(File.separatorChar));
  return relativePath.replace(File.separatorChar, '.');
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-theme-builder

@Override
public boolean isSatisfiedBy(FileTreeElement fileTreeElement) {
  File diffsDir = buildThemeTask.getDiffsDir();
  if ((diffsDir != null) &&
    FileUtil.isChild(fileTreeElement.getFile(), diffsDir)) {
    return true;
  }
  return false;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-wsdl-builder

private void _addTaskBuildWSDLTasks(
  BuildWSDLTask buildWSDLTask, File inputFile,
  Configuration wsdlBuilderConfiguration) {
  Project project = buildWSDLTask.getProject();
  if (buildWSDLTask.isBuildLibs()) {
    String tmpDirName =
      "build-wsdl/" + FileUtil.stripExtension(inputFile.getName());
    File tmpDir = new File(project.getBuildDir(), tmpDirName);
    File tmpSrcDir = new File(tmpDir, "src");
    Task generateTask = _addTaskBuildWSDLGenerate(
      buildWSDLTask, wsdlBuilderConfiguration, inputFile, tmpSrcDir,
      true);
    Task compileTask = _addTaskBuildWSDLCompile(
      buildWSDLTask, wsdlBuilderConfiguration, inputFile, tmpDir,
      generateTask);
    Jar jar = _addTaskBuildWSDLJar(
      buildWSDLTask, inputFile, compileTask, generateTask);
    buildWSDLTask.dependsOn(jar);
    TaskOutputs taskOutputs = buildWSDLTask.getOutputs();
    taskOutputs.file(jar.getArchivePath());
  }
  else {
    Task generateTask = _addTaskBuildWSDLGenerate(
      buildWSDLTask, wsdlBuilderConfiguration, inputFile,
      buildWSDLTask.getDestinationDir(), false);
    buildWSDLTask.dependsOn(generateTask);
  }
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-wsdl-builder

private Jar _addTaskBuildWSDLJar(
  BuildWSDLTask buildWSDLTask, File inputFile, Task compileTask,
  final Task generateTask) {
  Project project = buildWSDLTask.getProject();
  String taskName = GradleUtil.getTaskName(
    buildWSDLTask.getName(), inputFile);
  Jar jar = GradleUtil.addTask(project, taskName, Jar.class);
  jar.from(compileTask.getOutputs());
  if (buildWSDLTask.isIncludeSource()) {
    jar.into(
      "OSGI-OPT/src",
      new Closure<Void>(project) {
        @SuppressWarnings("unused")
        public void doCall(CopySpec copySpec) {
          copySpec.from(generateTask.getOutputs());
        }
      });
  }
  jar.setDestinationDir(buildWSDLTask.getDestinationDir());
  String wsdlName = FileUtil.stripExtension(inputFile.getName());
  jar.setArchiveName(wsdlName + "-ws.jar");
  return jar;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-source-formatter

private String _merge(Iterable<File> files, File startFile) {
  StringBuilder sb = new StringBuilder();
  int i = 0;
  for (File file : files) {
    if (i > 0) {
      sb.append(',');
    }
    sb.append(FileUtil.relativize(file, startFile));
    i++;
  }
  return sb.toString();
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-deployment-helper

protected List<String> getCompleteArgs() {
  List<String> completeArgs = new ArrayList<>();
  GUtil.addToCollection(completeArgs, getArgs());
  completeArgs.add("--fileNames=" + getDeploymentFileNames());
  completeArgs.add(
    "--outputFile=" + FileUtil.getAbsolutePath(getOutputFile()));
  File deploymentPath = getDeploymentPath();
  if (deploymentPath != null) {
    completeArgs.add(
      "--path=" + FileUtil.getAbsolutePath(deploymentPath));
  }
  return completeArgs;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-jsdoc

private String _relativize(File file) {
  String relativePath = FileUtil.relativize(file, getWorkingDir());
  if (File.separatorChar != '/') {
    relativePath = relativePath.replace(File.separatorChar, '/');
  }
  return relativePath;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-js-module-config-generator

completeArgs.add(FileUtil.getAbsolutePath(getModuleConfigFile()));
completeArgs.add(FileUtil.getAbsolutePath(getOutputFile()));
completeArgs.add(FileUtil.getAbsolutePath(outputDir));
completeArgs.add(FileUtil.getAbsolutePath(outputDir.getParentFile()));

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-rest-builder

private String _relativize(File file) {
  if (file == null) {
    return null;
  }
  String relativePath = FileUtil.relativize(file, getWorkingDir());
  return relativePath.replace('\\', '/');
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-js-transpiler

List<String> completeArgs = super.getCompleteArgs();
String destination = FileUtil.getAbsolutePath(getWorkingDir());

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-change-log-builder

private static String _relativize(File file, Repository repository) {
  File gitDir = repository.getDirectory();
  String relativePath = FileUtil.relativize(file, gitDir.getParentFile());
  if (File.separatorChar == '\\') {
    relativePath = relativePath.replace('\\', '/');
  }
  return relativePath;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-css-builder

private List<String> _getCompleteArgs() {
  List<String> args = new ArrayList<>(getArgs());
  args.add(
    "sass.append.css.import.timestamps=" +
      isAppendCssImportTimestamps());
  args.add("sass.dir=" + _getDirNamesArg());
  String docrootDirName = FileUtil.getAbsolutePath(getBaseDir());
  args.add("sass.docroot.dir=" + _removeTrailingSlash(docrootDirName));
  args.add("sass.generate.source.map=" + isGenerateSourceMap());
  args.add("sass.output.dir=" + _addTrailingSlash(getOutputDirName()));
  String importPath = FileUtil.getAbsolutePath(getImportPath());
  args.add("sass.portal.common.path=" + importPath);
  args.add("sass.precision=" + getPrecision());
  String rtlExcludedPathRegexps = CollectionUtils.join(
    ",", getRtlExcludedPathRegexps());
  args.add("sass.rtl.excluded.path.regexps=" + rtlExcludedPathRegexps);
  String sassCompilerClassName = getSassCompilerClassName();
  if (Validator.isNotNull(sassCompilerClassName)) {
    args.add("sass.compiler.class.name=" + sassCompilerClassName);
  }
  return args;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-tlddoc-builder

private List<String> _getCompleteArgs() {
  List<String> args = new ArrayList<>(getArgs());
  args.add("-d");
  args.add(FileUtil.relativize(getDestinationDir(), getWorkingDir()));
  File xsltDir = getXsltDir();
  if (xsltDir != null) {
    args.add("-xslt");
    args.add(FileUtil.relativize(xsltDir, getWorkingDir()));
  }
  for (File file : getSource()) {
    args.add(FileUtil.relativize(file, getWorkingDir()));
  }
  return args;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-js-transpiler

private void _addTasksExpandSoyCompileDependencies(
  TranspileJSTask transpileJSTask, Configuration configuration) {
  Project project = transpileJSTask.getProject();
  RenameDependencyClosure renameDependencyClosure =
    new RenameDependencyClosure(project, configuration.getName());
  Iterable<TaskDependency> taskDependencies =
    JSTranspilerPluginUtil.getTaskDependencies(configuration);
  for (File file : configuration) {
    Copy copy = JSTranspilerPluginUtil.addTaskExpandCompileDependency(
      project, file, project.getBuildDir(),
      "expandSoyCompileDependency", renameDependencyClosure);
    copy.dependsOn(taskDependencies);
    transpileJSTask.dependsOn(copy);
    String path = FileUtil.getAbsolutePath(copy.getDestinationDir());
    path += "/META-INF/resources/**/*.soy";
    transpileJSTask.soyDependency(path);
  }
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-lang-builder

private List<String> _getCompleteArgs() {
  List<String> args = new ArrayList<>(getArgs());
  args.add(
    "lang.dir=" + FileUtil.relativize(getLangDir(), getWorkingDir()));
  args.add(
    "lang.excluded.language.ids=" +
      StringUtil.merge(getExcludedLanguageIds(), ","));
  args.add("lang.file=" + getLangFileName());
  args.add("lang.title.capitalization=" + isTitleCapitalization());
  boolean translate = isTranslate();
  if (translate) {
    String translateSubscriptionKey = getTranslateSubscriptionKey();
    if (Validator.isNull(translateSubscriptionKey)) {
      if (_logger.isWarnEnabled()) {
        _logger.warn(
          "Translation is disabled because credentials are not " +
            "specified");
      }
      translate = false;
    }
    else {
      args.add(
        "lang.translate.subscription.key=" +
          translateSubscriptionKey);
    }
  }
  args.add("lang.translate=" + translate);
  return args;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-xsd-builder

protected Task addTaskBuildXSDGenerate(BuildXSDTask buildXSDTask) {
  Project project = buildXSDTask.getProject();
  JavaExec javaExec = GradleUtil.addTask(
    project, buildXSDTask.getName() + "Generate", JavaExec.class);
  File tmpSrcDir = new File(
    project.getBuildDir(), buildXSDTask.getName() + "/src");
  javaExec.args("-d");
  javaExec.args(FileUtil.getAbsolutePath(tmpSrcDir));
  javaExec.args("-srconly");
  Iterable<File> xsdFiles = buildXSDTask.getInputFiles();
  for (File xsdFile : xsdFiles) {
    javaExec.args(FileUtil.getAbsolutePath(xsdFile));
  }
  javaExec.dependsOn(
    BasePlugin.CLEAN_TASK_NAME +
      StringUtil.capitalize(javaExec.getName()));
  javaExec.setClasspath(
    GradleUtil.getConfiguration(project, CONFIGURATION_NAME));
  javaExec.setDescription(
    "Invokes the XMLBeans Schema Compiler in order to generate Java " +
      "types from XML Schema.");
  javaExec.setMain("org.apache.xmlbeans.impl.tool.SchemaCompiler");
  TaskInputs taskInputs = javaExec.getInputs();
  taskInputs.files(xsdFiles);
  TaskOutputs taskOutputs = javaExec.getOutputs();
  taskOutputs.dir(tmpSrcDir);
  return javaExec;
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-wsdl-builder

private Task _addTaskBuildWSDLGenerate(
  BuildWSDLTask buildWSDLTask, FileCollection classpath, File inputFile,
  final File destinationDir, boolean deleteDestinationDir) {
  Project project = buildWSDLTask.getProject();
  String taskName = GradleUtil.getTaskName(
    buildWSDLTask.getName() + "Generate", inputFile);
  JavaExec javaExec = GradleUtil.addTask(
    project, taskName, JavaExec.class);
  GenerateOptions generateOptions = buildWSDLTask.getGenerateOptions();
  javaExec.args(generateOptions.getArgs());
  javaExec.args("--output=" + FileUtil.getAbsolutePath(destinationDir));
  javaExec.args(FileUtil.getAbsolutePath(inputFile));
  if (deleteDestinationDir) {
    javaExec.doFirst(
      new Action<Task>() {
        @Override
        public void execute(Task task) {
          Project project = task.getProject();
          project.delete(destinationDir);
        }
      });
  }
  javaExec.setClasspath(classpath);
  javaExec.setMain("org.apache.axis.wsdl.WSDL2Java");
  TaskInputs taskInputs = javaExec.getInputs();
  taskInputs.file(inputFile);
  TaskOutputs taskOutputs = javaExec.getOutputs();
  taskOutputs.dir(destinationDir);
  return javaExec;
}

相关文章