PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/vendor/25jdee/jde/lisp/jde-compile.el

https://github.com/ansser/emacs.d
Emacs Lisp | 1626 lines | 1038 code | 224 blank | 364 comment | 64 complexity | 4a3d9c8968caf34f88ebdae4eeda4f45 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. ;;; jde-compile.el -- Integrated Development Environment for Java.
  2. ;; $Revision: 1.65 $ $Date: 2005/04/06 03:03:07 $
  3. ;; Author: Paul Kinnucan <paulk@mathworks.com>
  4. ;; Maintainer: Paul Kinnucan
  5. ;; Keywords: java, tools
  6. ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2008 Paul Kinnucan.
  7. ;; GNU Emacs is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  17. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. ;; Boston, MA 02111-1307, USA.
  19. ;;; Commentary:
  20. ;; This is one of a set of packages that make up the
  21. ;; Java Development Environment (JDE) for Emacs. See the
  22. ;; JDE User's Guide for more information.
  23. ;; The latest version of the JDE is available at
  24. ;; <URL:http://sunsite.auc.dk/jde/>.
  25. ;; Please send any comments, bugs, or upgrade requests to
  26. ;; Paul Kinnucan at paulk@mathworks.com.
  27. ;;; Code:
  28. (require 'eieio)
  29. (require 'cl)
  30. (require 'compile)
  31. (defgroup jde-compile-options nil
  32. "JDE Compiler Options"
  33. :group 'jde
  34. :prefix "jde-compile-option-")
  35. ;; (makunbound 'jde-compiler)
  36. (defcustom jde-compiler '("javac server" "")
  37. "Specify the type, and if necessary, the location of the compiler to
  38. be used to compile source files for the current project. The JDE
  39. supports three compilers: javac server, javac executable, and
  40. jikes. The javac server runs the com.sun.tools.javac package included
  41. with the JDK in the Beanshell. The javac executable shipped with the
  42. JDK also uses this package. The advantage of the javac server is that
  43. it avoids the vm startup time that accounts for most of the
  44. compilation time consumed by the javac executable. The javac server
  45. uses the version of com.sun.tools.javac included in the JDK for the
  46. current project. See `jde-jdk' for more information. If you want to
  47. use the javac executable to compile your project's source files,
  48. select \"javac\" as the compiler type and, optionally, specify
  49. the path to the executable in the \"Path\" field. If you do
  50. not specify a path, the JDE uses the javac executable included in the
  51. JDK for the current project. Similarly, to use jikes, select \"jikes\"
  52. and, if jikes is not on the command path of the Emacs
  53. environment, specify the path of the jikes executable."
  54. :group 'jde-project
  55. :type '(list
  56. (radio-button-choice
  57. :format "%t \n%v"
  58. :tag "Compiler type"
  59. (item "javac server")
  60. (item "javac")
  61. (item "jikes"))
  62. (file
  63. :tag "Path")))
  64. (defcustom jde-read-compile-args nil
  65. "*Specify whether to prompt for additional compiler arguments.
  66. If this variable is non-nil, the jde-compile command prompts
  67. you to enter additional compiler arguments in the minibuffer.
  68. These arguments are appended to those specified by customization
  69. variables. The JDE maintains a history list of arguments
  70. entered in the minibuffer."
  71. :group 'jde-project
  72. :type 'boolean)
  73. (defvar jde-interactive-compile-args ""
  74. "String of compiler arguments entered in the minibuffer.")
  75. (defvar jde-interactive-compile-arg-history nil
  76. "History of compiler arguments entered in the minibuffer.")
  77. ;; (makunbound 'jde-compile-finish-hook)
  78. (defcustom jde-compile-finish-hook
  79. '(jde-compile-finish-kill-buffer
  80. jde-compile-finish-refresh-speedbar
  81. jde-compile-finish-update-class-info)
  82. "List of functions to be invoked when compilation of a
  83. Java source file terminates. Each function should accept
  84. two arguments: the compilation buffer and a string
  85. describing how the compilation finished."
  86. :group 'jde
  87. :type 'hook)
  88. (defcustom jde-compile-option-hide-classpath nil
  89. "Substitute the classpath in the compilation window for
  90. ..."
  91. :group 'jde-compile-options
  92. :type 'boolean)
  93. (defun jde-compile-update-class-list ()
  94. (let ((class-dir
  95. (if (string= jde-compile-option-directory "")
  96. (expand-file-name ".")
  97. (jde-normalize-path
  98. jde-compile-option-directory
  99. 'jde-compile-option-directory))))
  100. (message (concat "Updating class list for " class-dir))
  101. (jde-jeval (concat
  102. "jde.util.JdeUtilities.updateClassList(\""
  103. class-dir
  104. "\");"))
  105. (message "Updating class list...done.")))
  106. (defun jde-compile-finish-update-class-info (buf msg)
  107. "Flush the classinfo cache and update the class list used by
  108. JDEE wizards at the end of compilation. Flush the entire cache as we
  109. don't know which classes were recompiled."
  110. ;;Setting the last java buffer as the current buffer
  111. (condition-case nil
  112. (progn
  113. (if jde-xemacsp
  114. (set-buffer (cadr (buffer-list)))
  115. (set-buffer (car (buffer-list))))
  116. (if (eq major-mode 'jde-mode)
  117. (progn
  118. (setq jde-complete-last-compiled-class (jde-parse-get-buffer-class))
  119. (jde-complete-flush-classes-in-cache (list jde-complete-last-compiled-class))
  120. (message "Flushed completion cache.")
  121. (setq jde-complete-last-compiled-class nil)
  122. (jde-compile-update-class-list))))
  123. (error nil)))
  124. (defun jde-compile-finish-refresh-speedbar (buf msg)
  125. "Refresh speedbar at the end of a compilation."
  126. (if (and (frame-live-p speedbar-frame)
  127. (frame-visible-p speedbar-frame))
  128. (speedbar-refresh)))
  129. (defcustom jde-compile-jump-to-first-error t
  130. "*Automatically jump to the first error when a compilation process completes."
  131. :group 'jde-compile-options
  132. :type 'boolean)
  133. (defun jde-compile-kill-buffer (buf)
  134. (if jde-compile-enable-kill-buffer
  135. (progn
  136. (delete-windows-on buf)
  137. (kill-buffer buf))))
  138. ;; Thanks to Jack Donohue <donohuej@synovation.com>.
  139. (defun jde-compile-finish-kill-buffer (buf msg)
  140. "Removes the jde-compile window after a few seconds if no errors."
  141. (save-excursion
  142. (set-buffer buf)
  143. (if (null (or (string-match ".*exited abnormally.*" msg)
  144. (string-match ".*BUILD FAILED.*" (buffer-string))))
  145. ;;no errors, make the compilation window go away in a few seconds
  146. (lexical-let ((compile-buffer buf))
  147. (run-at-time
  148. "2 sec" nil 'jde-compile-kill-buffer
  149. compile-buffer)
  150. (message "No compilation errors"))
  151. ;;there were errors, so jump to the first error
  152. (if jde-compile-jump-to-first-error (next-error 1)))))
  153. (defcustom jde-compile-option-command-line-args nil
  154. "*Specify options as a string of command-line arguments.
  155. The value of this variable should be a list of switches understood
  156. by the compiler, for example, -depend -g. This variable is intended to
  157. be used to set compile options not otherwise defined by the JDE, in
  158. particular, options not defined by javac but used by another compiler
  159. that you might want to use with the JDE."
  160. :group 'jde-compile-options
  161. :type '(repeat (string :tag "Argument:")))
  162. (defcustom jde-compile-option-classpath nil
  163. "*Specify paths of classes required to compile this project.
  164. The JDEE uses the specified paths to construct a -classpath
  165. argument to pass to the compiler. If you do not specify this
  166. option, the JDEE uses the value of the `jde-global-classpath'
  167. option to compile this project.
  168. Starting in JDK 1.6, a class path element containing a basename
  169. of * is considered equivalent to specifying a list of all the
  170. files in the directory with the extension .jar or .JAR. For
  171. example, if directory foo contains a.jar and b.JAR, then the
  172. class path element foo/* is expanded to A.jar;b.JAR, except that
  173. the order of jar files is unspecified. All jar files in the
  174. specified directory, even hidden ones, are included in the
  175. list. A classpath entry consisting simply of * expands to a list
  176. of all the jar files in the current directory. The CLASSPATH
  177. environment variable, where defined, will be similarly
  178. expanded. Note: Depending of the configuration of your command
  179. line environment, you may have to quote the wild card character,
  180. for example, javac -cp \"*.jar\" MyClass.java."
  181. :group 'jde-compile-options
  182. :type '(repeat (file :tag "Path")))
  183. (defcustom jde-compile-option-sourcepath nil
  184. "*Specify the source code path to search for class or interface definitions.
  185. As with the user class path, source path entries can be directories, JAR
  186. archives, or ZIP archives. If packages are used, the local path name within
  187. the directory or archive must reflect the package name.
  188. Note that classes found through the classpath are subject to automatic
  189. recompilation if their sources are found."
  190. :group 'jde-compile-options
  191. :type '(repeat (file :tag "Path")))
  192. (defcustom jde-compile-option-directory ""
  193. "*Specifies the root directory of the class file hierarchy.
  194. The compiler places compiled classes in the specified
  195. directory. For example, specifying the class
  196. directory as:
  197. C:\\users\\dac\\classes
  198. causes the class files for the classes in the MyProgram.java source
  199. file to be saved in the directory C:\\users\\dac\\classes. If your class
  200. is in the package demos\\awt, the class files would be placed in directory
  201. C:\\users\\dac\\classes\\demos\\awt."
  202. :group 'jde-compile-options
  203. :type 'directory)
  204. (defcustom jde-compile-option-deprecation nil
  205. "*Warn use or override of a deprecated member or class.
  206. A member or class is deprecated if its documentation comment contains
  207. the @deprecated tag. The compiler will emit a warning at the end of
  208. compilation whether or not the deprecation option is on; this option
  209. causes the location of each individual use or override to be noted.
  210. Deprecated members or classes are deliberately not mentioned if the
  211. source file containing the deprecation is being recompiled. This can
  212. happen because the file is on the command line or because the depend
  213. option is on and the source file is out of date.
  214. "
  215. :group 'jde-compile-options
  216. :type 'boolean)
  217. (defcustom jde-compile-option-debug
  218. (list "selected" (list t nil nil))
  219. "*Include debug information in classes.
  220. The compiler includes line number information by default.
  221. Before JDK 1.2, the the debug and optimize options were
  222. mutually exclusive. In JDK 1.2, it is possible to combine debug and
  223. optimize, but the shortcuts taken by optimized code may occasionally
  224. produce surprising debugging results. For example, declared variables
  225. may not exist and code may appear to move or not be executed at all.
  226. The JDK 1.1.x versions of javac do not support inclusion of selected
  227. debug information."
  228. :group 'jde-compile-options
  229. :type '(list
  230. (radio-button-choice
  231. :format "%t \n%v"
  232. :tag "Debug info to include in class:"
  233. (const "all")
  234. (const "none")
  235. (const "selected"))
  236. (list
  237. :tag " info"
  238. :indent 4
  239. (checkbox :format "%[%v%] %t \n"
  240. :tag "Line Numbers")
  241. (checkbox :format "%[%v%] %t \n"
  242. :tag "Variables")
  243. (checkbox :format "%[%v%] %t \n"
  244. :tag "Source")))
  245. )
  246. (defcustom jde-compile-option-optimize nil
  247. "*Directs the compiler to try to generate faster code.
  248. This may slow down compilation, make larger class files, and/or make
  249. it difficult to debug.
  250. Prior to 1.2, the optimize option tried to inline methods across
  251. classes. This created compatibility problems and sometimes generated
  252. illegal bytecode. The optimize option also implicitly turned on the
  253. depend option and implicitly turned off the debug option.
  254. In JDK 1.2, the optimize option no longer inlines across classes and
  255. so may safely be used for any java compilation. Optimize no longer
  256. implicitly turns on depend or implicitly turns off debug."
  257. :group 'jde-compile-options
  258. :type 'boolean)
  259. (defcustom jde-compile-option-depend nil
  260. "*Analyze dependencies.
  261. Causes recompilation of class files on which the source files given as
  262. command line arguments recursively depend. Without this option, only
  263. files that are directly depended on and missing or out-of-date will be
  264. recompiled. Recompilation does not extend to missing or out-of-date
  265. files only depended on by already up-to-date class files.
  266. Note: if you are using a compiler other than post JDK 1.1.6 versions
  267. of javac, you may need to specify the command-line switch used by
  268. the compiler to specify dependency checking. See
  269. `jde-compile-option-depend-switch' for more information."
  270. :group 'jde-compile-options
  271. :type 'boolean)
  272. (defcustom jde-compile-option-depend-switch (list "-Xdepend")
  273. "*Specify command line switch for depend option.
  274. This option is necessary because the command-line switch for
  275. dependency checking differs among Java compilers. Choose
  276. from the following options:
  277. -Xdepend Full dependency checking (post JDK 1.1.6)
  278. -depend Full dependency checking (jikes and pre-JDK 1.1.6)
  279. +F Check everything except jar and zip files (jikes only)
  280. +U Check everything including jar and zip files (jikes only)"
  281. :group 'jde-compile-options
  282. :type '(list
  283. (radio-button-choice
  284. :format "%t \n%v"
  285. :tag "Select -Xdepend (javac) or -depend (jikes):"
  286. (const "-Xdepend")
  287. (const "-depend")
  288. (const "+F")
  289. (const "+U"))))
  290. (defcustom jde-compile-option-vm-args nil
  291. "*Specify command-line arguments for Java interpreter.
  292. Passes the specified arguments to the Java interpreter that runs the
  293. compiler. The argument should not contain spaces. This is useful for
  294. adjusting the compiler's execution environment or memory usage."
  295. :group 'jde-compile-options
  296. :type '(repeat (string :tag "Option")))
  297. (defcustom jde-compile-option-verbose nil
  298. "*Print verbose messages.
  299. Causes the compiler and linker to print out messages about what source
  300. files are being compiled and what class files are being loaded."
  301. :group 'jde-compile-options
  302. :type 'boolean)
  303. (defcustom jde-compile-option-nowarn nil
  304. "*Turn off warnings.
  305. If this option is specified, the compiler does not print out any
  306. warnings."
  307. :group 'jde-compile-options
  308. :type 'boolean)
  309. ;;(makunbound 'jde-compile-option-annotation-processors)
  310. (defcustom jde-compile-option-annotation-processors nil
  311. "*Names of the annotation processors to run. This bypasses the default discovery process."
  312. :group 'jde-compile-options
  313. :type '(repeat (string :tag "Name")))
  314. ;;(makunbound 'jde-compile-option-annotation-processing)
  315. (defcustom jde-compile-option-annotation-processing
  316. (list "compile and process annotations")
  317. "*Controls whether annotation processing and/or compilation is done."
  318. :group 'jde-compile-options
  319. :type '(list
  320. (radio-button-choice
  321. :format "%t \n%v"
  322. :tag "Processing:"
  323. (const "compile and process annotations")
  324. (const "compile only")
  325. (const "process annotations only"))))
  326. ;;(makunbound 'jde-compile-option-annotation-processor-options)
  327. (defcustom jde-compile-option-annotation-processor-options nil
  328. "*Options to pass to annotation processors. These are not
  329. interpreted by javac directly, but are made available for use by
  330. individual processors. key should be one or more identifiers
  331. separated by \".\"."
  332. :group 'jde-compile-options
  333. :type '(repeat
  334. (cons :tag "Option"
  335. (string :tag "Key")
  336. (string :tag "Value"))))
  337. (defcustom jde-compile-option-encoding ""
  338. "*Specify the source file encoding name, such as EUCJIS\\SJIS.
  339. If this option is not specified, the platform default converter
  340. is used."
  341. :group 'jde-compile-options
  342. :type 'string)
  343. ;;(makunbound 'jde-compile-option-implicit)
  344. (defcustom jde-compile-option-implicit
  345. (list "Generate and warn")
  346. "*Specify whether to generate class files for source files loaded in
  347. order to get type information needed to compile and/or process
  348. annotations in other files. Options are:
  349. * Generate and warn
  350. Generate class files for source files loaded to get type info for other files.
  351. Do not generate class files for source files needed only to process
  352. annotations. Instead issue a warning.
  353. * Generate and do not warn
  354. Generate class files for source files needed to compile other files. Do
  355. not generate class files for source needed for processing annotions
  356. in other files and do not warn that class files are not generated.
  357. * Do not generate
  358. Do not generate class files for implicitly loaded source files.
  359. "
  360. :group 'jde-compile-options
  361. :type '(list
  362. (radio-button-choice
  363. :format "%t \n%v"
  364. :tag "Processing:"
  365. (const "Generate and warn")
  366. (const "Generate and do not warn")
  367. (const "Do not generate"))))
  368. ;;(makunbound 'jde-compile-option-source)
  369. (defcustom jde-compile-option-source (list "default")
  370. "*Enables JDK version-specific features to be used in
  371. source files.
  372. 1.3 The compiler does not support assertions
  373. 1.4 The compiler accepts code containing assertions.
  374. 1.5 Enables 1.5-specific features.
  375. 1.6 Enables 1.6-specific features.
  376. Select \"default\" to use the source features that
  377. the compiler supports by default, i.e., to not include the -source
  378. switch on the compiler command line. For example, the javac compiler
  379. defaults to 1.3 source features if the -source flag is not
  380. used.
  381. ***NOTE***
  382. This option is supported only by versions of javac shipped
  383. starting with J2SDK 1.4."
  384. :group 'jde-compile-options
  385. :type '(list
  386. (radio-button-choice
  387. :format "%t \n%v"
  388. :tag "Source release:"
  389. (const "default")
  390. (const "1.3")
  391. (const "1.4")
  392. (const "1.5")
  393. (const "1.6"))))
  394. ;;(makunbound 'jde-compile-option-target)
  395. (defcustom jde-compile-option-target (list "1.1")
  396. "*Generate class files that will work on VMs with the specified version.
  397. The default is to generate class files to be compatible with both
  398. 1.1 and 1.2 VMs. The versions supported by javac in JDK1.2 are:
  399. 1.1 Ensure that generated class files will be compatible
  400. with 1.1 and 1.2 VMs. This is the default.
  401. 1.2 Generate class files that will run on 1.2 VMs, but
  402. not on 1.1 VMs.
  403. 1.3 Generate class files that will run on VMs in the
  404. Java 2 SDK, v 1.3 and later, but will not run
  405. on 1.1 or 1.2 VMs
  406. 1.4 Generate class files that are compatible only with
  407. 1.4 VMs.
  408. By default, classes are compiled against the bootstrap and extension classes
  409. of the JDK that javac shipped with. But javac also supports cross-compiling,
  410. where classes are compiled against a bootstrap and extension classes of a
  411. different Java platform implementation. It is important to use
  412. `jde-compile-option-bootclasspath' and `jde-compile-option-extdirs' when
  413. cross-compiling."
  414. :group 'jde-compile-options
  415. :type '(list
  416. (radio-button-choice
  417. :format "%t \n%v"
  418. :tag "Target VM:"
  419. (const "1.1")
  420. (const "1.2")
  421. (const "1.3")
  422. (const "1.4"))))
  423. (defcustom jde-compile-option-bootclasspath nil
  424. "*Cross-compile against the specified set of boot classes.
  425. As with the user class path, boot class path entries can be
  426. directories, JAR archives, or ZIP archives."
  427. :group 'jde-compile-options
  428. :type '(repeat (file :tag "Path")))
  429. (defcustom jde-compile-option-extdirs nil
  430. "*Cross-compile against the specified extension directories.
  431. Each JAR archive in the specified directories is searched for class files."
  432. :group 'jde-compile-options
  433. :type '(repeat (file :tag "Path")))
  434. ;;(makunbound 'jde-compile-option-verbose-path)
  435. (defcustom jde-compile-option-verbose-path nil
  436. "*Describe how paths and standard extensions were searched to find
  437. source and class files.
  438. ***NOTE***
  439. This option is supported only by the versions of javac shipped
  440. with JDK 1.1.x and 1.2.x and oldjavac in JDK 1.3."
  441. :group 'jde-compile-options
  442. :type 'boolean)
  443. (defcustom jde-compile-enable-kill-buffer nil
  444. "* If true the 'jde-compile-finish-kill-buffer will kill the compilation
  445. buffer."
  446. :group 'jde-compile-options
  447. :type 'boolean)
  448. (defun jde-compile-show-options-buffer ()
  449. "Show the JDE Compile Options panel."
  450. (interactive)
  451. (customize-apropos "jde-compile-options" 'groups))
  452. (defclass jde-compile-server-buffer (bsh-compilation-buffer) ()
  453. "Compiler server buffer.")
  454. (defmethod bsh-compilation-buffer-create-native-buffer ((this jde-compile-server-buffer))
  455. "Creates the native Emacs buffer for the JDEE compile server."
  456. (oset this buffer-name "*JDEE Compile Server*")
  457. (oset this buffer (get-buffer-create (oref this buffer-name))))
  458. (defclass jde-compile-exec-buffer (bsh-compilation-buffer) ()
  459. "Compiler exec buffer.")
  460. (defmethod initialize-instance ((this jde-compile-exec-buffer) &rest fields)
  461. "Constructor for exec compilation buffer instance."
  462. (bsh-compilation-buffer-create-native-buffer this)
  463. (oset
  464. this
  465. filter
  466. (lexical-let ((this-buf this))
  467. (lambda (process output)
  468. (bsh-compilation-buffer-filter this-buf process output))))
  469. (oset this process (get-buffer-process (oref this buffer)))
  470. ;; Make sure this buffer is not associated with a compiler process that is
  471. ;; already running.
  472. (if (oref this process)
  473. (if (or (not (eq (process-status (oref this process)) 'run))
  474. (yes-or-no-p
  475. "A compilation process is running; kill it?"))
  476. (condition-case ()
  477. (progn
  478. (interrupt-process (oref this process))
  479. (sit-for 1)
  480. (delete-process (oref this process)))
  481. (error nil))
  482. (error "Cannot have two processes in `%s' at once"
  483. (oref this buffer-name))))
  484. (bsh-compilation-buffer-set-mode this))
  485. (defmethod bsh-compilation-buffer-create-native-buffer ((this jde-compile-exec-buffer))
  486. "Creates the native Emacs buffer for the JDEE compile server."
  487. (oset this buffer-name "*compilation*")
  488. (oset this buffer (get-buffer-create (oref this buffer-name))))
  489. (defclass jde-compile-compiler ()
  490. ((name :initarg :name
  491. :type string
  492. :documentation
  493. "Name of compiler")
  494. (version :initarg :version
  495. :type string
  496. :documentation
  497. "Compiler version.")
  498. (path :initarg :path
  499. :type string
  500. :documentation
  501. "Path of the compiler executable.")
  502. (buffer :initarg :buffer
  503. :type bsh-compilation-buffer
  504. :documentation
  505. "Compilation buffer")
  506. (window :initarg :window
  507. :type window
  508. :documentation
  509. "Window that displays the compilation buffer.")
  510. (interactive-args :initarg :interactive-args
  511. :type list
  512. :documentation
  513. "Arguments entered in the minibuffer.")
  514. (use-server-p :initarg :use-server-p
  515. :type boolean
  516. :documentation
  517. "Run as a compile server in the Beanshell."))
  518. "Class of Java compilers.")
  519. (defmethod jde-compile-classpath-arg ((this jde-compile-compiler))
  520. "Returns the classpath argument for this compiler."
  521. (let ((classpath
  522. (if jde-compile-option-classpath
  523. jde-compile-option-classpath
  524. (jde-get-global-classpath)))
  525. (symbol
  526. (if jde-compile-option-classpath
  527. 'jde-compile-option-classpath
  528. 'jde-global-classpath)))
  529. (if classpath
  530. (list
  531. "-classpath"
  532. (jde-build-classpath
  533. classpath
  534. symbol)
  535. ))))
  536. (defmethod jde-compile-sourcepath-arg ((this jde-compile-compiler))
  537. "Get the source path argument for this compiler."
  538. (if jde-compile-option-sourcepath
  539. (list
  540. "-sourcepath"
  541. (jde-build-classpath
  542. jde-compile-option-sourcepath
  543. 'jde-compile-option-sourcepath))))
  544. (defmethod jde-compile-bootclasspath-arg ((this jde-compile-compiler))
  545. "Get the boot classpath argument for this compiler."
  546. (if jde-compile-option-bootclasspath
  547. (list
  548. "-bootclasspath"
  549. (jde-build-classpath jde-compile-option-bootclasspath
  550. 'jde-compile-option-bootclasspath))))
  551. (defmethod jde-compile-extdirs-arg ((this jde-compile-compiler))
  552. "Get the extdirs argument for this compiler."
  553. (if jde-compile-option-extdirs
  554. (list
  555. "-extdirs"
  556. (jde-build-classpath
  557. jde-compile-option-extdirs
  558. 'jde-compile-option-extdirs))))
  559. (defmethod jde-compile-encoding-arg ((this jde-compile-compiler))
  560. (if (not (string= jde-compile-option-encoding ""))
  561. (list
  562. "-encoding"
  563. jde-compile-option-encoding)))
  564. (defmethod jde-compile-debug-arg ((this jde-compile-compiler))
  565. "Get the debug arg for this compiler."
  566. (let* ((include-option (nth 0 jde-compile-option-debug))
  567. (selected (nth 1 jde-compile-option-debug))
  568. (lines (nth 0 selected))
  569. (vars (nth 1 selected))
  570. (src (nth 2 selected)))
  571. (cond
  572. ((and
  573. (string= include-option "selected")
  574. lines
  575. (not vars)
  576. (not src))
  577. nil)
  578. ((string= include-option "all")
  579. (list "-g"))
  580. ((string= include-option "none")
  581. (list "-g:none"))
  582. ((and
  583. (string= include-option "selected")
  584. (or lines vars src))
  585. (list
  586. (concat
  587. "-g:"
  588. (if lines
  589. (if (or vars src) "lines,"
  590. "lines"))
  591. (if vars
  592. (if vars
  593. (if src "vars," "vars")))
  594. (if src "source")))))))
  595. (defmethod jde-compile-output-dir-arg ((this jde-compile-compiler))
  596. "Get the ouput directory arg for this compiler."
  597. (if (not (string= jde-compile-option-directory ""))
  598. (list
  599. "-d"
  600. (jde-normalize-path 'jde-compile-option-directory))))
  601. (defmethod jde-compile-deprecation-arg ((this jde-compile-compiler))
  602. "Get deprecation argument for this compiler."
  603. (if jde-compile-option-deprecation
  604. (list "-deprecation")))
  605. (defmethod jde-compile-optimize-arg ((this jde-compile-compiler))
  606. "Get optimization argument for this compiler."
  607. (if jde-compile-option-optimize
  608. (list "-O")))
  609. (defmethod jde-compile-depend-arg ((this jde-compile-compiler))
  610. "Get dependency-checking argument for this compiler."
  611. (if jde-compile-option-depend
  612. (list (car jde-compile-option-depend-switch))))
  613. (defmethod jde-compile-vm-args ((this jde-compile-compiler))
  614. "Get arguments to pass to the vm used to run this compiler."
  615. (if jde-compile-option-vm-args
  616. (mapcan
  617. (lambda (arg)
  618. (list (concat "-J" arg)))
  619. jde-compile-option-vm-args)))
  620. (defmethod jde-compile-verbose-arg ((this jde-compile-compiler))
  621. "Get verbosity level argument for this compiler."
  622. (if jde-compile-option-verbose
  623. (list "-verbose")))
  624. (defmethod jde-compile-verbose-path-arg ((this jde-compile-compiler))
  625. "Get verbose path argument for this compiler."
  626. (if jde-compile-option-verbose-path
  627. (list "-Xverbosepath")))
  628. (defmethod jde-compile-nowarn-arg ((this jde-compile-compiler))
  629. "Get no warning argument for this compiler."
  630. (if jde-compile-option-nowarn
  631. (list "-nowarn")))
  632. (defmethod jde-compile-command-line-args ((this jde-compile-compiler))
  633. "Get additional command line arguments for this compiler."
  634. jde-compile-option-command-line-args)
  635. (defmethod jde-compile-target-arg ((this jde-compile-compiler))
  636. "Get compiler target argument for this compiler."
  637. (let ((target (car jde-compile-option-target)))
  638. (if (not (string= target "1.1"))
  639. (list "-target" target))))
  640. (defmethod jde-compile-source-arg ((this jde-compile-compiler))
  641. "Get compiler source argument for this compiler."
  642. (let ((source (car jde-compile-option-source)))
  643. (if (not (string= source "default"))
  644. (list "-source" source))))
  645. (defmethod jde-compile-get-args ((this jde-compile-compiler))
  646. (append
  647. (jde-compile-classpath-arg this)
  648. (jde-compile-sourcepath-arg this)
  649. (jde-compile-bootclasspath-arg this)
  650. (jde-compile-extdirs-arg this)
  651. (jde-compile-encoding-arg this)
  652. (jde-compile-debug-arg this)
  653. (jde-compile-output-dir-arg this)
  654. (jde-compile-deprecation-arg this)
  655. (jde-compile-optimize-arg this)
  656. (jde-compile-depend-arg this)
  657. (jde-compile-vm-args this)
  658. (jde-compile-verbose-arg this)
  659. (jde-compile-verbose-path-arg this)
  660. (jde-compile-nowarn-arg this)
  661. (jde-compile-target-arg this)
  662. (jde-compile-source-arg this)
  663. (jde-compile-command-line-args this)))
  664. (defmethod jde-compile-run-exec ((this jde-compile-compiler))
  665. (let* ((outbuf (oref (oref this buffer) buffer))
  666. (compiler-path (oref this :path))
  667. (source-file (file-name-nondirectory buffer-file-name))
  668. (flag nil)
  669. (args (append
  670. (jde-compile-get-args this)
  671. (oref this :interactive-args)
  672. (list source-file))))
  673. (save-excursion
  674. (set-buffer outbuf)
  675. (let ((inhibit-read-only t)) ; make compilation buffer temporarily writable
  676. (insert (format "cd %s\n" default-directory))
  677. (insert (concat
  678. compiler-path
  679. " "
  680. (mapconcat (lambda (x)
  681. (if (and flag
  682. jde-compile-option-hide-classpath)
  683. (progn
  684. (setq flag nil)
  685. "...")
  686. (if (not (string= x "-classpath"))
  687. x
  688. (progn
  689. (setq flag t)
  690. x)))) args " ")
  691. "\n\n")))
  692. (let* ((process-environment (cons "EMACS=t" process-environment))
  693. (w32-quote-process-args ?\")
  694. (win32-quote-process-args ?\") ;; XEmacs
  695. (proc (apply 'start-process
  696. (downcase mode-name)
  697. outbuf
  698. compiler-path
  699. args)))
  700. (set-process-sentinel proc 'compilation-sentinel)
  701. (set-process-filter proc 'compilation-filter)
  702. (set-marker (process-mark proc) (point) outbuf)
  703. (setq compilation-in-progress
  704. (cons proc compilation-in-progress))))))
  705. (defmethod jde-compile-run-server ((this jde-compile-compiler))
  706. (let* ((directory-sep-char ?/)
  707. (args
  708. (append
  709. (jde-compile-get-args this)))
  710. (source-path
  711. (jde-normalize-path buffer-file-name))
  712. (arg-array (concat "new String[] {\"" source-path "\"")))
  713. (if args
  714. (setq arg-array
  715. (concat
  716. arg-array
  717. ","
  718. (mapconcat
  719. (lambda (arg)
  720. (concat "\"" arg "\""))
  721. args
  722. ","))))
  723. (setq arg-array (concat arg-array "}"))
  724. (save-excursion
  725. (set-buffer (oref (oref this buffer) buffer))
  726. (let* ((inhibit-read-only t)
  727. flag
  728. (arg-string
  729. (mapconcat
  730. (lambda (x)
  731. (if (and flag
  732. jde-compile-option-hide-classpath)
  733. (progn
  734. (setq flag nil)
  735. "...")
  736. (if (not (string= x "-classpath"))
  737. x
  738. (progn
  739. (setq flag t)
  740. x))))
  741. args " ")))
  742. (insert "CompileServer output:\n\n")
  743. (insert arg-string " " source-path "\n")))
  744. (if (not (jde-bsh-running-p))
  745. (progn
  746. (bsh-launch (oref 'jde-bsh the-bsh))
  747. (bsh-eval (oref 'jde-bsh the-bsh) (jde-create-prj-values-str))))
  748. (bsh-buffer-eval
  749. (oref 'jde-bsh the-bsh)
  750. (concat
  751. (format
  752. "jde.util.CompileServer.compile(%s);"
  753. arg-array)
  754. "\n")
  755. (oref this buffer))))
  756. (defmethod jde-compile-launch ((this jde-compile-compiler))
  757. (if (oref this :use-server-p)
  758. (jde-compile-run-server this)
  759. (jde-compile-run-exec this))
  760. (set-buffer-modified-p nil))
  761. (defmethod jde-compile-compile ((this jde-compile-compiler))
  762. (if (oref this :use-server-p)
  763. (oset this buffer (jde-compile-server-buffer "compilation buffer"))
  764. (oset this buffer (jde-compile-exec-buffer "compilation buffer")))
  765. ;; Pop to compilation buffer.
  766. (let* ((outbuf (oref (oref this buffer) buffer))
  767. (outwin (display-buffer outbuf)))
  768. (compilation-set-window-height outwin)
  769. (oset this :window outwin)
  770. (if (not jde-xemacsp)
  771. (if compilation-process-setup-function
  772. (funcall compilation-process-setup-function)))
  773. (jde-compile-launch this)
  774. (setq compilation-last-buffer outbuf)))
  775. (defclass jde-compile-javac (jde-compile-compiler)
  776. ()
  777. "Class of javac compilers.")
  778. (defmethod initialize-instance ((this jde-compile-javac) &rest fields)
  779. ;; Call parent initializer.
  780. (call-next-method)
  781. ;; Set compiler name.
  782. (oset this name "javac")
  783. )
  784. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  785. ;; ;;
  786. ;; JDK 1.1 Compiler ;;
  787. ;; ;;
  788. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  789. (defclass jde-compile-javac-11 (jde-compile-compiler)
  790. ()
  791. "Class of JDK 1.1 javac compilers.")
  792. (defmethod initialize-instance ((this jde-compile-javac-11) &rest fields)
  793. ;; Call parent initializer.
  794. (call-next-method)
  795. ;; Set compiler version.
  796. (oset this version "1.1"))
  797. (defmethod jde-compile-debug-arg ((this jde-compile-javac-11))
  798. "Get the debug arg for this compiler."
  799. (let ((include-option (nth 0 jde-compile-option-debug)))
  800. (cond
  801. ((string= include-option "all")
  802. (list "-g"))
  803. ((string= include-option "selected")
  804. (error "JDK 1.1 version of javac does not support selected debug info.")))))
  805. (defmethod jde-compile-depend-arg ((this jde-compile-javac-11))
  806. "Get dependency-checking argument for this compiler."
  807. (if jde-compile-option-depend
  808. (list "-depend")))
  809. (defmethod jde-compile-get-args ((this jde-compile-javac-11))
  810. (append
  811. (jde-compile-classpath-arg this)
  812. (jde-compile-encoding-arg this)
  813. (jde-compile-debug-arg this)
  814. (jde-compile-output-dir-arg this)
  815. (jde-compile-deprecation-arg this)
  816. (jde-compile-optimize-arg this)
  817. (jde-compile-depend-arg this)
  818. (jde-compile-vm-args this)
  819. (jde-compile-verbose-arg this)
  820. (jde-compile-nowarn-arg this)
  821. (jde-compile-command-line-args this)))
  822. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  823. ;; ;;
  824. ;; JDK 1.2 Compiler ;;
  825. ;; ;;
  826. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  827. (defclass jde-compile-javac-12 (jde-compile-compiler)
  828. ()
  829. "Class of JDK 1.2 javac compilers.")
  830. (defmethod initialize-instance ((this jde-compile-javac-12) &rest fields)
  831. ;; Call parent initializer.
  832. (call-next-method)
  833. ;; Set compiler version.
  834. (oset this version "1.2"))
  835. (defmethod jde-compile-depend-arg ((this jde-compile-javac-12))
  836. "Get dependency-checking argument for this compiler."
  837. (if jde-compile-option-depend
  838. (list "-Xdepend")))
  839. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  840. ;; ;;
  841. ;; JDK 1.3 Compiler ;;
  842. ;; ;;
  843. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  844. (defclass jde-compile-javac-13 (jde-compile-javac-12)
  845. ()
  846. "Class of JDK 1.3 javac compilers.")
  847. (defmethod initialize-instance ((this jde-compile-javac-13) &rest fields)
  848. ;; Call parent initializer.
  849. (call-next-method)
  850. ;; Set compiler version.
  851. (oset this version "1.3"))
  852. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  853. ;; ;;
  854. ;; JDK 1.4 Compiler ;;
  855. ;; ;;
  856. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  857. (defclass jde-compile-javac-14 (jde-compile-javac-13)
  858. ()
  859. "Class of JDK 1.4 javac compilers.")
  860. (defmethod initialize-instance ((this jde-compile-javac-14) &rest fields)
  861. ;; Call parent initializer.
  862. (call-next-method)
  863. ;; Set compiler version.
  864. (oset this version "1.4"))
  865. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  866. ;; ;;
  867. ;; J2SDK 1.5 Compiler ;;
  868. ;; ;;
  869. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  870. (defclass jde-compile-javac-15 (jde-compile-javac-14)
  871. ()
  872. "Class of J2SDK 1.5 javac compilers.")
  873. (defmethod initialize-instance ((this jde-compile-javac-15) &rest fields)
  874. ;; Call parent initializer.
  875. (call-next-method)
  876. ;; Set compiler version.
  877. (oset this version "1.5"))
  878. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  879. ;; ;;
  880. ;; J2SDK 1.6 Compiler ;;
  881. ;; ;;
  882. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  883. (defclass jde-compile-javac-16 (jde-compile-javac-15)
  884. ()
  885. "Class of JDK 1.6 javac compilers.")
  886. (defmethod initialize-instance ((this jde-compile-javac-16) &rest fields)
  887. ;; Call parent initializer.
  888. (call-next-method)
  889. ;; Set compiler version.
  890. (oset this version "1.6"))
  891. (defmethod jde-compile-annotation-processors-arg ((this jde-compile-javac-16))
  892. "Get the annotation processors argument for this compiler."
  893. (if jde-compile-option-annotation-processors
  894. (list
  895. "-processor"
  896. (mapconcat 'identity
  897. jde-compile-option-annotation-processors
  898. ","))))
  899. (defmethod jde-compile-annotation-processing-arg ((this jde-compile-javac-16))
  900. (let ((option (car jde-compile-option-annotation-processing)))
  901. (cond
  902. ((string= option "compile and process annotations")
  903. nil)
  904. ((string= option "compile only")
  905. (list "-proc:none"))
  906. ((string= option "process annotations only")
  907. (list "-proc:only")))))
  908. (defmethod jde-compile-annotation-processor-options-args ((this jde-compile-javac-16))
  909. "Get property arguments."
  910. (mapcar
  911. (lambda (option)
  912. (let ((key (car option))
  913. (value (cdr option)))
  914. (if (string= value "")
  915. (format "-A%s" key)
  916. (format "-A%s=%s" key value))))
  917. jde-compile-option-annotation-processor-options))
  918. (defmethod jde-compile-implicit-arg ((this jde-compile-javac-16))
  919. (let ((option (car jde-compile-option-implicit)))
  920. (cond
  921. ((string= option "Generate and warn")
  922. nil)
  923. ((string= option "Generate and do not warn")
  924. (list "-implicit:class"))
  925. ((string= option "Do not generate")
  926. (list "-implicit:none")))))
  927. (defmethod jde-compile-get-args ((this jde-compile-javac-16))
  928. (append
  929. (jde-compile-classpath-arg this)
  930. (jde-compile-encoding-arg this)
  931. (jde-compile-debug-arg this)
  932. (jde-compile-output-dir-arg this)
  933. (jde-compile-deprecation-arg this)
  934. (jde-compile-optimize-arg this)
  935. (jde-compile-depend-arg this)
  936. (jde-compile-annotation-processing-arg this)
  937. (jde-compile-annotation-processors-arg this)
  938. (jde-compile-annotation-processor-options-args this)
  939. (jde-compile-implicit-arg this)
  940. (jde-compile-vm-args this)
  941. (jde-compile-verbose-arg this)
  942. (jde-compile-nowarn-arg this)
  943. (jde-compile-command-line-args this)))
  944. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  945. ;; ;;
  946. ;; Jikes Compiler ;;
  947. ;; ;;
  948. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  949. (defclass jde-compile-jikes (jde-compile-compiler)
  950. ()
  951. "Class of jikes compilers.")
  952. (defmethod initialize-instance ((this jde-compile-jikes) &rest fields)
  953. ;; Call parent initializer.
  954. (call-next-method)
  955. ;; Set compiler name.
  956. (oset this :name "jikes")
  957. ;; Set compiler version.
  958. (oset this version "1.14"))
  959. (defmethod jde-compile-debug-arg ((this jde-compile-jikes))
  960. "Get the debug arg for this compiler."
  961. (let ((include-option (nth 0 jde-compile-option-debug)))
  962. (cond
  963. ((string= include-option "all")
  964. (list "-g"))
  965. ((string= include-option "selected")
  966. (error "Jikes does not support jde-compile-option-debug's selected debug info option.")))))
  967. (defmethod jde-compile-depend-arg ((this jde-compile-jikes))
  968. "Get dependency-checking argument for this compiler."
  969. (if jde-compile-option-depend
  970. (list "-depend")))
  971. (defmethod jde-compile-command-line-args ((this jde-compile-jikes))
  972. "Get additional command line arguments for this compiler."
  973. (append
  974. (list "+E")
  975. jde-compile-option-command-line-args))
  976. (defmethod jde-compile-classpath-arg ((this jde-compile-jikes))
  977. "Returns the classpath argument for this compiler."
  978. (let ((classpath (call-next-method))
  979. (rt (expand-file-name "jre/lib/rt.jar" (jde-get-jdk-dir))))
  980. (if (file-exists-p rt)
  981. (if classpath
  982. (or (string-match "jre/lib/rt\.jar" (cadr classpath))
  983. (setcar (cdr classpath)
  984. (concat (cadr classpath)
  985. jde-classpath-separator
  986. rt)))
  987. (setq classpath (list "-classpath" rt))))
  988. classpath))
  989. (defmethod jde-compile-get-args ((this jde-compile-jikes))
  990. (append
  991. (jde-compile-classpath-arg this)
  992. (jde-compile-sourcepath-arg this)
  993. (jde-compile-bootclasspath-arg this)
  994. (jde-compile-extdirs-arg this)
  995. (jde-compile-encoding-arg this)
  996. (jde-compile-debug-arg this)
  997. (jde-compile-output-dir-arg this)
  998. (jde-compile-deprecation-arg this)
  999. (jde-compile-source-arg this)
  1000. (jde-compile-optimize-arg this)
  1001. (jde-compile-depend-arg this)
  1002. (jde-compile-verbose-arg this)
  1003. (jde-compile-verbose-path-arg this)
  1004. (jde-compile-nowarn-arg this)
  1005. (jde-compile-target-arg this)
  1006. (jde-compile-command-line-args this)))
  1007. (defvar jde-compile-javac-compilers
  1008. (list
  1009. (jde-compile-javac-11 "javac 1.1.x")
  1010. (jde-compile-javac-12 "javac 1.2.x")
  1011. (jde-compile-javac-13 "javac 1.3.x")
  1012. (jde-compile-javac-14 "javac 1.4.x")
  1013. (jde-compile-javac-15 "javac 1.5.x")
  1014. (jde-compile-javac-16 "javac 1.6.x"))
  1015. "List of supported javac compilers.")
  1016. (defun jde-compile-get-javac ()
  1017. (let* ((jdk-version (jde-java-version))
  1018. (jdk-split-version (split-string jdk-version "[.]"))
  1019. (jdk-major-version (nth 0 jdk-split-version))
  1020. (jdk-minor-version (nth 1 jdk-split-version))
  1021. (compiler
  1022. (find-if
  1023. (lambda (compiler-x)
  1024. (let* ((compiler-split-version (split-string (oref compiler-x :version) "[.]"))
  1025. (compiler-major-version (nth 0 compiler-split-version))
  1026. (compiler-minor-version (nth 1 compiler-split-version)))
  1027. (and
  1028. (string= jdk-major-version compiler-major-version)
  1029. (string= jdk-minor-version compiler-minor-version))))
  1030. jde-compile-javac-compilers)))
  1031. (unless compiler
  1032. (let ((latest-javac (car (last jde-compile-javac-compilers))))
  1033. (if
  1034. (yes-or-no-p
  1035. (format "The JDE does not recognize JDK %s javac. Assume JDK %s javac?"
  1036. jdk-version (oref latest-javac :version)))
  1037. (setq compiler latest-javac))))
  1038. (if compiler
  1039. (if (string= (car jde-compiler) "javac server")
  1040. (oset compiler :use-server-p t)
  1041. (progn
  1042. (oset compiler :use-server-p nil)
  1043. (oset compiler
  1044. :path
  1045. (let ((compiler-path
  1046. (substitute-in-file-name (nth 1 jde-compiler))))
  1047. (if (string= compiler-path "")
  1048. (setq compiler-path (jde-get-jdk-prog 'javac))
  1049. (if (file-exists-p compiler-path)
  1050. compiler-path
  1051. (error (format "Invalid compiler path %s"
  1052. compiler-path)))))))))
  1053. compiler))
  1054. (defun jde-compile-get-jikes ()
  1055. (let ((compiler-path
  1056. (substitute-in-file-name (nth 1 jde-compiler))))
  1057. (if (string= compiler-path "")
  1058. (if (executable-find "jikes")
  1059. (setq compiler-path "jikes")
  1060. (error "Cannot find jikes."))
  1061. (unless
  1062. (or
  1063. (file-exists-p
  1064. (if (and
  1065. (eq system-type 'windows-nt)
  1066. (not (string-match "[.]exe$" compiler-path)))
  1067. (concat compiler-path ".exe")
  1068. compiler-path))
  1069. (executable-find compiler-path))
  1070. (error "Invalid compiler path: %s" compiler-path)))
  1071. (jde-compile-jikes
  1072. "Jikes"
  1073. :use-server-p nil
  1074. :path compiler-path)))
  1075. (defun jde-compile-get-the-compiler ()
  1076. "Get a compiler object that represents the compiler specified
  1077. by `jde-compiler'."
  1078. (let ((compiler-name (car jde-compiler)))
  1079. (cond
  1080. ((string-match "javac" compiler-name)
  1081. (jde-compile-get-javac))
  1082. ((string-match "jikes" compiler-name)
  1083. (jde-compile-get-jikes))
  1084. (t
  1085. (error "The JDEE does not support a compiler named %s" compiler-name)))))
  1086. ;;;###autoload
  1087. (defun jde-set-compile-options (options)
  1088. "Sets the compile options.
  1089. Enter the options as you would on the command line, e.g.,
  1090. -depend -verbose."
  1091. (interactive
  1092. "sEnter options: ")
  1093. (setq jde-compile-option-command-line-args (split-string options " ")))
  1094. ;;;###autoload
  1095. (defun jde-compile ()
  1096. "Compile the Java program in the current buffer.
  1097. This command invokes the compiler specified by `jde-compiler'
  1098. with the options specified by the JDE customization variables
  1099. that begin with `jde-compile'. If the variable
  1100. `jde-read-compile-args' is non-nil, this command reads
  1101. additional compilation options from the minibuffer, with
  1102. history enabled. If `jde-compiler' specifies the JDE compile
  1103. server, this command uses the compile server. Otherwise, it
  1104. uses the compiler executable specified by
  1105. `jde-compiler' to compile."
  1106. (interactive)
  1107. (if jde-read-compile-args
  1108. (setq jde-interactive-compile-args
  1109. (read-from-minibuffer
  1110. "Compile args: "
  1111. jde-interactive-compile-args
  1112. nil nil
  1113. '(jde-interactive-compile-arg-history . 1))))
  1114. ;; Force save-some-buffers to use the minibuffer
  1115. ;; to query user about whether to save modified buffers.
  1116. ;; Otherwise, when user invokes jde-compile from
  1117. ;; menu, save-some-buffers tries to popup a menu
  1118. ;; which seems not to be supported--at least on
  1119. ;; the PC.
  1120. (if (and (eq system-type 'windows-nt)
  1121. (not jde-xemacsp))
  1122. (let ((temp last-nonmenu-event))
  1123. ;; The next line makes emacs think that jde-compile
  1124. ;; was invoked from the minibuffer, even when it
  1125. ;; is actually invoked from the menu-bar.
  1126. (setq last-nonmenu-event t)
  1127. (save-some-buffers (not compilation-ask-about-save) nil)
  1128. (setq last-nonmenu-event temp))
  1129. (save-some-buffers (not compilation-ask-about-save) nil))
  1130. (setq compilation-finish-function
  1131. (lambda (buf msg)
  1132. (run-hook-with-args 'jde-compile-finish-hook buf msg)
  1133. (setq compilation-finish-function nil)))
  1134. (let ((compiler (jde-compile-get-the-compiler)))
  1135. (if compiler
  1136. (progn
  1137. (oset compiler
  1138. :interactive-args
  1139. (if (and jde-interactive-compile-args
  1140. (not (string= jde-interactive-compile-args "")))
  1141. (split-string jde-interactive-compile-args " ")))
  1142. (jde-compile-compile compiler))
  1143. (error "Unknown compiler. Aborting compilation."))))
  1144. (provide 'jde-compile)
  1145. ;; Change History
  1146. ;; $Log: jde-compile.el,v $
  1147. ;; Revision 1.65 2005/04/06 03:03:07 paulk
  1148. ;; Fix jde-compile-kill-buffer to honor jde-compile-enable-kill-buffer.
  1149. ;;
  1150. ;; Revision 1.64 2005/02/02 03:49:31 paulk
  1151. ;; Updated to be compatible with new Emacs policy of making compilation buffers read-only.
  1152. ;;
  1153. ;; Revision 1.63 2004/10/20 06:17:06 paulk
  1154. ;; Update to support reloading classes from a single classpath entry. Thanks to Martin Schwamberger.
  1155. ;;
  1156. ;; Revision 1.62 2004/08/21 04:29:20 paulk
  1157. ;; Update the wizard class list after compiling a class.
  1158. ;;
  1159. ;; Revision 1.61 2004/08/03 03:55:00 paulk
  1160. ;; Emacs 21.3.5 compatibility fix: Updated jde-compile-finish-kill-buffer to include prefix argument which is not optional in Emacs 21.3.5.
  1161. ;;
  1162. ;; Revision 1.60 2004/05/26 05:15:33 paulk
  1163. ;; Fix version-matching bug in jde-compile-get-javac.
  1164. ;;
  1165. ;; Revision 1.59 2004/04/15 03:58:59 paulk
  1166. ;; Add "default" option to jde-compile-option-source.
  1167. ;;
  1168. ;; Revision 1.58 2004/02/22 08:02:29 paulk
  1169. ;; Update to support J2SDK1.5.0.
  1170. ;;
  1171. ;; Revision 1.57 2003/07/15 11:56:23 paulk
  1172. ;; Update jde-compile-option-target.
  1173. ;;
  1174. ;; Revision 1.56 2003/04/08 03:16:28 paulk
  1175. ;; Fixes regression that causes compilation buffer's default directory to be set incorrectly. Also rename compile server buffer from *compilation* to *JDEE Compile Server*
  1176. ;;
  1177. ;; Revision 1.55 2003/04/05 06:26:19 paulk
  1178. ;; Added jde-compile-jump-to-first-error option. Thanks to Sean Wellington.
  1179. ;;
  1180. ;; Revision 1.54 2003/04/04 13:35:00 jslopez
  1181. ;; Adds the source argument to the jikes compiler.
  1182. ;;
  1183. ;; Revision 1.53 2003/03/04 10:12:50 paulk
  1184. ;; Updated the compile server to use the new compilation-mode buffer support
  1185. ;; provided by bsh class.
  1186. ;;
  1187. ;; Revision 1.52 2003/02/28 04:13:33 jslopez
  1188. ;; Adds customization variable jde-compile-enable-kill-buffer. If true the
  1189. ;; jde-compile-finish-kill-buffer hook will kill the compilation buffer.
  1190. ;;
  1191. ;; Revision 1.51 2003/02/17 08:13:05 paulk
  1192. ;; Changes required to support new package-independent version of beanshell.el
  1193. ;;
  1194. ;; Revision 1.50 2003/02/07 00:31:57 jslopez
  1195. ;; Adds jde-compile-option-source to be compile 1.4 code with
  1196. ;; the assert key word on it.
  1197. ;;
  1198. ;; Revision 1.49 2002/12/12 05:24:46 paulk
  1199. ;; Fixed bug that caused the compile command to fail when jikes
  1200. ;; is the compiler and jde-compiler does not specify the path of the
  1201. ;; jikes executable.
  1202. ;;
  1203. ;; Revision 1.48 2002/11/22 09:32:13 paulk
  1204. ;; Improve error reporting when a user attempts to use an unsupported compiler.
  1205. ;;
  1206. ;; Revision 1.47 2002/11/05 07:47:25 paulk
  1207. ;; Mac OS (darwin) compatibility fix: find path of javac compiler. Thanks to Andrew Hyatt.
  1208. ;;
  1209. ;; Revision 1.46 2002/09/18 15:20:19 jslopez
  1210. ;; Fixes bug in jde-compile-finish-kill-buffer.
  1211. ;; The regexp BUILD FAILED was being match agains the wrong string.
  1212. ;; Now it is being match against the contents of the compilation buffer.
  1213. ;;
  1214. ;; Revision 1.45 2002/09/16 04:23:50 paulk
  1215. ;; Added missing -encoding switch for compiler encoding comma…

Large files files are truncated, but you can click here to view the full file