public static String[] getModifiedFiles(
      BuildContext buildContext, File source, String[] includes, String[] excludes)
      throws Exception {
    if ((source == null) || !source.exists()) {
      return null;
    }

    final Scanner ds = buildContext.newScanner(source);

    if ((includes != null) && (includes.length > 0)) {
      ds.setIncludes(includes);
    }

    if ((excludes != null) && (excludes.length > 0)) {
      ds.setExcludes(excludes);
    }

    ds.scan();

    return ds.getIncludedFiles();
  }
  @Override
  public void execute() throws MojoExecutionException {
    try {
      if (buildContext.isIncremental()) {
        Scanner scanner = buildContext.newScanner(baseDir);

        String[] includes = {"", "**/*.scss"};

        scanner.setIncludes(includes);

        scanner.scan();

        String[] includedFiles = scanner.getIncludedFiles();

        if (ArrayUtil.isNotEmpty(includedFiles)) {
          CSSBuilderInvoker.invoke(baseDir, _cssBuilderArgs);
        }
      } else {
        CSSBuilderInvoker.invoke(baseDir, _cssBuilderArgs);
      }
    } catch (Exception e) {
      throw new MojoExecutionException(e.getMessage(), e);
    }
  }
Ejemplo n.º 3
0
  List<String> getIncludedFiles(File sourceDirectory, String[] includes, String[] excludes) {
    Scanner scanner = buildContext.newScanner(sourceDirectory, true);
    scanner.setIncludes(includes);
    scanner.setExcludes(excludes);
    scanner.scan();

    String[] includedFiles = scanner.getIncludedFiles();
    for (int i = 0; i < includedFiles.length; i++) {
      includedFiles[i] = new File(scanner.getBasedir(), includedFiles[i]).getAbsolutePath();
    }

    String[] result = new String[includedFiles.length];
    System.arraycopy(includedFiles, 0, result, 0, includedFiles.length);
    return Arrays.asList(result);
  }