@Override
  public <A extends Arg> JavaTest createBuildRule(
      TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args)
      throws NoSuchBuildTargetException {
    SourcePathResolver pathResolver = new SourcePathResolver(resolver);

    JavacOptions javacOptions =
        JavacOptionsFactory.create(templateJavacOptions, params, resolver, pathResolver, args);

    CxxLibraryEnhancement cxxLibraryEnhancement =
        new CxxLibraryEnhancement(
            params, args.useCxxLibraries, resolver, pathResolver, cxxPlatform);
    params = cxxLibraryEnhancement.updatedParams;

    BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR);

    JavaTest test =
        resolver.addToIndex(
            new JavaTest(
                params.appendExtraDeps(
                    Iterables.concat(
                        BuildRules.getExportedRules(
                            Iterables.concat(
                                params.getDeclaredDeps().get(),
                                resolver.getAllRules(args.providedDeps.get()))),
                        pathResolver.filterBuildRuleInputs(javacOptions.getInputs(pathResolver)))),
                pathResolver,
                args.srcs.get(),
                ResourceValidator.validateResources(
                    pathResolver, params.getProjectFilesystem(), args.resources.get()),
                javacOptions.getGeneratedSourceFolderName(),
                args.labels.get(),
                args.contacts.get(),
                args.proguardConfig.transform(
                    SourcePaths.toSourcePath(params.getProjectFilesystem())),
                new BuildTargetSourcePath(abiJarTarget),
                javacOptions.trackClassUsage(),
                /* additionalClasspathEntries */ ImmutableSet.<Path>of(),
                args.testType.or(TestType.JUNIT),
                new JavacToJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY),
                javaOptions.getJavaRuntimeLauncher(),
                args.vmArgs.get(),
                cxxLibraryEnhancement.nativeLibsEnvironment,
                validateAndGetSourcesUnderTest(
                    args.sourceUnderTest.get(), params.getBuildTarget(), resolver),
                args.resourcesRoot,
                args.mavenCoords,
                args.testRuleTimeoutMs.or(defaultTestRuleTimeoutMs),
                args.env.get(),
                args.getRunTestSeparately(),
                args.stdOutLogLevel,
                args.stdErrLogLevel));

    resolver.addToIndex(
        CalculateAbi.of(
            abiJarTarget, pathResolver, params, new BuildTargetSourcePath(test.getBuildTarget())));

    return test;
  }
    public static boolean compile(String[] args, File episode) throws Exception {

      JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
      DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
      StandardJavaFileManager fileManager =
          compiler.getStandardFileManager(diagnostics, null, null);
      JavacOptions options = JavacOptions.parse(compiler, fileManager, args);
      List<String> unrecognizedOptions = options.getUnrecognizedOptions();
      if (!unrecognizedOptions.isEmpty())
        Logger.getLogger(SchemaGenerator.class.getName())
            .log(Level.WARNING, "Unrecognized options found: {0}", unrecognizedOptions);
      Iterable<? extends JavaFileObject> compilationUnits =
          fileManager.getJavaFileObjectsFromFiles(options.getFiles());
      JavaCompiler.CompilationTask task =
          compiler.getTask(
              null,
              fileManager,
              diagnostics,
              options.getRecognizedOptions(),
              options.getClassNames(),
              compilationUnits);
      com.sun.tools.internal.jxc.ap.SchemaGenerator r =
          new com.sun.tools.internal.jxc.ap.SchemaGenerator();
      if (episode != null) r.setEpisodeFile(episode);
      task.setProcessors(Collections.singleton(r));
      return task.call();
    }