emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] possible bugfix in ob-java
@ 2020-09-13 16:44 John Herrlin
  2020-09-23 12:27 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: John Herrlin @ 2020-09-13 16:44 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 787 bytes --]


Hey,

Trying to do the following:

     #+HEADER: :classname se/my_test_package/Main
     #+HEADER: :dir src
     #+HEADER: :cmdline -classpath src:.
     #+BEGIN_SRC java :results output code
       package se.my_test_package;

       class Main {
           public static void main(String[] args) {
               System.out.println("Hey from Emacs Org mode!");
           }
       }
     #+END_SRC

I expected this to create Main.java and Main.class in directory
src/se/my_test_package/ before running =javac=. Instead I get this:

File is missing: "Opening output file", "No such file or directory"
"/tmp/src/se/my-test-package/Main.java"

In the patch I rearrange so package dirs are created before the
Main.java file is written to file system. It fixes the provided case for
me.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-java-create-package-dirs-before-write-to-file.patch --]
[-- Type: text/x-patch, Size: 1404 bytes --]

From 618b736d895b1e762cdcc8026a673aa6207a0a8b Mon Sep 17 00:00:00 2001
From: John Herrlin <jherrlin@gmail.com>
Date: Sun, 13 Sep 2020 18:07:22 +0200
Subject: [PATCH] ob-java: create package dirs before write to file

* lisp/ob-java.el (org-babel-execute:java): create package-name
directories before writing to file.

TINYCHANGE
---
 lisp/ob-java.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index f5edc6d53..dc5efe5fb 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -60,12 +60,12 @@ parameters may be used, like javac -verbose"
 	 (cmdline (or (cdr (assq :cmdline params)) ""))
 	 (cmdargs (or (cdr (assq :cmdargs params)) ""))
 	 (full-body (org-babel-expand-body:generic body params)))
-    (with-temp-file src-file (insert full-body))
-    (org-babel-eval
-     (concat org-babel-java-compiler " " cmpflag " " src-file) "")
     ;; created package-name directories if missing
     (unless (or (not packagename) (file-exists-p packagename))
       (make-directory packagename 'parents))
+    (with-temp-file src-file (insert full-body))
+    (org-babel-eval
+     (concat org-babel-java-compiler " " cmpflag " " src-file) "")
     (let ((results (org-babel-eval (concat org-babel-java-command
                                            " " cmdline " " classname " " cmdargs) "")))
       (org-babel-reassemble-table
-- 
2.28.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] possible bugfix in ob-java
  2020-09-13 16:44 [PATCH] possible bugfix in ob-java John Herrlin
@ 2020-09-23 12:27 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2020-09-23 12:27 UTC (permalink / raw)
  To: John Herrlin; +Cc: emacs-orgmode

Hi John,

Applied as a409e1033 in master.

Thanks a lot!

-- 
 Bastien


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-23 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 16:44 [PATCH] possible bugfix in ob-java John Herrlin
2020-09-23 12:27 ` Bastien

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).