README 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * Copyright 2009 The Closure Compiler Authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. //
  17. // Contents
  18. //
  19. The Closure Compiler performs checking, instrumentation, and
  20. optimizations on JavaScript code. The purpose of this README is to
  21. explain how to build and run the Closure Compiler.
  22. The Closure Compiler requires Java 6 or higher.
  23. http://www.java.com/
  24. //
  25. // Building The Closure Compiler
  26. //
  27. There are three ways to get a Closure Compiler executable.
  28. 1) Use one we built for you.
  29. Pre-built Closure binaries can be found at
  30. http://code.google.com/p/closure-compiler/downloads/list
  31. 2) Check out the source and build it with Apache Ant.
  32. First, check out the full source tree of the Closure Compiler. There
  33. are instructions on how to do this at the project site.
  34. http://code.google.com/p/closure-compiler/source/checkout
  35. Apache Ant is a cross-platform build tool.
  36. http://ant.apache.org/
  37. At the root of the source tree, there is an Ant file named
  38. build.xml. To use it, navigate to the same directory and type the
  39. command
  40. ant jar
  41. This will produce a jar file called "build/compiler.jar".
  42. 3) Check out the source and build it with Eclipse.
  43. Eclipse is a cross-platform IDE.
  44. http://www.eclipse.org/
  45. Under Eclipse's File menu, click "New > Project ..." and create a
  46. "Java Project." You will see an options screen. Give the project a
  47. name, select "Create project from existing source," and choose the
  48. root of the checked-out source tree as the existing directory. Verify
  49. that you are using JRE version 6 or higher.
  50. Eclipse can use the build.xml file to discover rules. When you
  51. navigate to the build.xml file, you will see all the build rules in
  52. the "Outline" pane. Run the "jar" rule to build the compiler in
  53. build/compiler.jar.
  54. //
  55. // Running The Closure Compiler
  56. //
  57. Once you have the jar binary, running the Closure Compiler is straightforward.
  58. On the command line, type
  59. java -jar compiler.jar
  60. This starts the compiler in interactive mode. Type
  61. var x = 17 + 25;
  62. then hit "Enter", then hit "Ctrl-Z" (on Windows) or "Ctrl-D" (on Mac or Linux)
  63. and "Enter" again. The Compiler will respond:
  64. var x=42;
  65. The Closure Compiler has many options for reading input from a file,
  66. writing output to a file, checking your code, and running
  67. optimizations. To learn more, type
  68. java -jar compiler.jar --help
  69. You can read more detailed documentation about the many flags at
  70. http://code.google.com/closure/compiler/docs/gettingstarted_app.html
  71. //
  72. // Compiling Multiple Scripts
  73. //
  74. If you have multiple scripts, you should compile them all together with
  75. one compile command.
  76. java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js
  77. The Closure Compiler will concatenate the files in the order they're
  78. passed at the command line.
  79. If you need to compile many, many scripts together, you may start to
  80. run into problems with managing dependencies between scripts. You
  81. should check out the Closure Library. It contains functions for
  82. enforcing dependencies between scripts, and a tool called calcdeps.py
  83. that knows how to give scripts to the Closure Compiler in the right
  84. order.
  85. http://code.google.com/p/closure-library/
  86. //
  87. // Licensing
  88. //
  89. Unless otherwise stated, all source files are licensed under
  90. the Apache License, Version 2.0.
  91. -----
  92. Code under:
  93. src/com/google/javascript/rhino
  94. test/com/google/javascript/rhino
  95. URL: http://www.mozilla.org/rhino
  96. Version: 1.5R3, with heavy modifications
  97. License: Netscape Public License and MPL / GPL dual license
  98. Description: A partial copy of Mozilla Rhino. Mozilla Rhino is an
  99. implementation of JavaScript for the JVM. The JavaScript parser and
  100. the parse tree data structures were extracted and modified
  101. significantly for use by Google's JavaScript compiler.
  102. Local Modifications: The packages have been renamespaced. All code not
  103. relavant to parsing has been removed. A JSDoc parser and static typing
  104. system have been added.
  105. -----
  106. Code in:
  107. lib/rhino
  108. Rhino
  109. URL: http://www.mozilla.org/rhino
  110. Version: Trunk
  111. License: Netscape Public License and MPL / GPL dual license
  112. Description: Mozilla Rhino is an implementation of JavaScript for the JVM.
  113. Local Modifications: Minor changes to parsing JSDoc that usually get pushed
  114. up-stream to Rhino trunk.
  115. -----
  116. Code in:
  117. lib/args4j.jar
  118. Args4j
  119. URL: https://args4j.dev.java.net/
  120. Version: 2.0.12
  121. License: MIT
  122. Description:
  123. args4j is a small Java class library that makes it easy to parse command line
  124. options/arguments in your CUI application.
  125. Local Modifications: None.
  126. -----
  127. Code in:
  128. lib/guava.jar
  129. Guava Libraries
  130. URL: http://code.google.com/p/guava-libraries/
  131. Version: r08
  132. License: Apache License 2.0
  133. Description: Google's core Java libraries.
  134. Local Modifications: None.
  135. -----
  136. Code in:
  137. lib/jsr305.jar
  138. Annotations for software defect detection
  139. URL: http://code.google.com/p/jsr-305/
  140. Version: svn revision 47
  141. License: BSD License
  142. Description: Annotations for software defect detection.
  143. Local Modifications: None.
  144. -----
  145. Code in:
  146. lib/jarjar.jar
  147. Jar Jar Links
  148. URL: http://jarjar.googlecode.com/
  149. Version: 1.1
  150. License: Apache License 2.0
  151. Description:
  152. A utility for repackaging Java libraries.
  153. Local Modifications: None.
  154. ----
  155. Code in:
  156. lib/junit.jar
  157. JUnit
  158. URL: http://sourceforge.net/projects/junit/
  159. Version: 4.8.2
  160. License: Common Public License 1.0
  161. Description: A framework for writing and running automated tests in Java.
  162. Local Modifications: None.
  163. ---
  164. Code in:
  165. lib/protobuf-java.jar
  166. Protocol Buffers
  167. URL: http://code.google.com/p/protobuf/
  168. Version: 2.3.0
  169. License: New BSD License
  170. Description: Supporting libraries for protocol buffers,
  171. an encoding of structured data.
  172. Local Modifications: None
  173. ---
  174. Code in:
  175. lib/ant.jar
  176. lib/ant-launcher.jar
  177. URL: http://ant.apache.org/bindownload.cgi
  178. Version: 1.8.1
  179. License: Apache License 2.0
  180. Description:
  181. Ant is a Java based build tool. In theory it is kind of like "make"
  182. without make's wrinkles and with the full portability of pure java code.
  183. Local Modifications: None
  184. ---
  185. Code in:
  186. lib/json.jar
  187. URL: http://json.org/java/index.html
  188. Version: JSON version 20090211
  189. License: MIT license
  190. Description:
  191. JSON is a set of java files for use in transmitting data in JSON format.
  192. Local Modifications: None
  193. ---
  194. Code in:
  195. tools/maven-ant-tasks-2.1.1.jar
  196. URL: http://maven.apache.org
  197. Version 2.1.1
  198. License: Apache License 2.0
  199. Description:
  200. Maven Ant tasks are used to manage dependencies and to install/deploy to
  201. maven repositories.
  202. Local Modifications: None