Package org.stjs.generator

Examples of org.stjs.generator.Generator


    compile(path, Collections.singletonList(sourceFile), Collections.<File>emptyList());
    generate(path, fileName, Collections.<File>emptyList(), path);
  }

  static void generate(final String path, final String className, List<File> dependencies, String outputDir) {
    Generator gen = new Generator();
    try {
      List<URL> classpathElements = new ArrayList<URL>();
      classpathElements.add(new File(path).toURI().toURL());
      for (File dep : dependencies) {
        classpathElements.add(dep.toURI().toURL());
      }

      ClassLoader builtProjectClassLoader = new URLClassLoader(classpathElements.toArray(new URL[classpathElements.size()]), Thread
          .currentThread().getContextClassLoader());
      File sourceFolder = new File(path);
      GenerationDirectory targetFolder = new GenerationDirectory(new File(outputDir), null, null);
      File generationFolder = targetFolder.getAbsolutePath();

      GeneratorConfigurationBuilder configBuilder = new GeneratorConfigurationBuilder();
      configBuilder.allowedPackage(builtProjectClassLoader.loadClass(className).getPackage().getName());
      GeneratorConfiguration configuration = configBuilder.build();

      gen.init(builtProjectClassLoader, configuration.getSourceEncoding());
      gen.generateJavascript(builtProjectClassLoader, className, sourceFolder, targetFolder, generationFolder, configuration);
    }
    catch (Exception e) {
      throw Throwables.propagate(e);
    }
    finally {
      gen.close();
    }
  }
View Full Code Here


   * @param exchange contains the HTTP response that must be written to
   */
  public void sendTestFixture(MultiTestMethod meth, HttpExchange exchange) throws Exception {
    Class<?> testClass = meth.getTestClass().getJavaClass();
    Method method = meth.getMethod().getMethod();
    ClassWithJavascript stjsClass = new Generator().getExistingStjsClass(getConfig().getClassLoader(), testClass);

    List<FrameworkMethod> beforeMethods = meth.getTestClass().getAnnotatedMethods(Before.class);
    List<FrameworkMethod> afterMethods = meth.getTestClass().getAnnotatedMethods(After.class);

    final HTMLFixture htmlFixture = testClass.getAnnotation(HTMLFixture.class);
View Full Code Here

TOP

Related Classes of org.stjs.generator.Generator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.