All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.dreampie.CoffeeCompiler Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2010 David Yeung
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.dreampie;

import cn.dreampie.logging.CoffeeLogger;
import cn.dreampie.logging.CoffeeLoggerFactory;
import cn.dreampie.resource.CoffeeSource;
import com.google.common.collect.Lists;
import com.google.javascript.jscomp.*;
import com.google.javascript.jscomp.Compiler;
import org.apache.commons.io.FileUtils;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.Scriptable;

import java.io.*;
import java.net.URL;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by wangrenhui on 2014/7/11.
 */
public class CoffeeCompiler {
  private static CoffeeLogger logger = CoffeeLoggerFactory.getLogger(CoffeeSource.class);

  private URL coffeeJs = CoffeeCompiler.class.getClassLoader().getResource("lib/coffee-script-1.7.1.js");
  private List

* This method sneaks into the CommandLineRunner class of the Closure command line tool * and pulls the default Externs there. This class could be modified to instead look * somewhere more relevant to the project. */ private List getExterns() { try { return CommandLineRunner.getDefaultExterns(); } catch (IOException e) { throw new CoffeeException("Unable to load default External variables Files. The files include definitions for global javascript/browser objects such as window, document.", e); } } public List





© 2015 - 2025 Weber Informatics LLC | Privacy Policy