|
From: | ian martins |
Subject: | Re: ob-java compile only |
Date: | Mon, 28 Sep 2020 22:18:44 -0400 |
Hey Ian,
Thank you for the quick feedback!
That workflow seems to work perfectly if it's Java all the way. Then it
compiles all the related files. I am mostly working with the classes
from Clojure.
Here is an example:
#+HEADER: :classname se/my_test_package/Hey
#+HEADER: :compile-only t
#+HEADER: :results none
#+HEADER: :dir src
#+BEGIN_SRC java
package se.my_test_package;
public class Hey {
public static String hey(String name) {
return "Hey " + name;
}
}
#+END_SRC
#+BEGIN_SRC clojure :results output code
(import [se.my_test_package Hey])
(Hey/hey "John")
#+END_SRC
Best regards
ian martins <ianxm@jhu.edu> writes:
> Hi John,
>
> Thanks for the suggestion and patch. Is the reason for this so that you can
> have classes without needing dummy "main" methods?
>
> Did you consider using org-babel-tangle to generate the source files? This
> works for me:
>
> Steps:
> 1. put javatangle.org (below) on your local.
> 2. create "pkg" directory where javatangle.org is
> 3. run org-babel-tangle on javatangle.org (this writes two source files to
> the pkg dir)
> 4. run C-c C-c on the top source block (this compiles both source files and
> runs main)
>
> ----- javatangle.org -----
>
> #+begin_src java :results output :classname pkg/Main :tangle pkg/Main.java
> package pkg;
>
> public class Main {
> public static void main(String[] args) {
> System.out.println(Hey.hey());
> }
> }
> #+end_src
>
> #+begin_src java :results output :classname pkg/Hey :tangle pkg/Hey.java
> package pkg;
>
> public class Hey {
> public static String hey() {
> return "hey";
> }
> }
> #+end_src
>
>
>
> On Sun, Sep 27, 2020 at 5:19 PM John Herrlin <jherrlin@gmail.com> wrote:
>
>>
>> Hey Ian!
>>
>> Happy to see you as the maintainer of the ob-java!
>>
>> I would like to propose a feature to ob-java. The feature allows a
>> source code block to write and compile only, without executing.
>>
>> Here is a common use case for me.
>>
>> Class without a entry point have an :compile-only header.
>>
>> #+HEADER: :classname se/my_test_package/Hey
>> #+HEADER: :dir src
>> #+HEADER: :compile-only t
>> #+HEADER: :results none
>> #+BEGIN_SRC java
>> package se.my_test_package;
>>
>> public class Hey {
>> public static String hey(String name) {
>> return "Hey " + name;
>> }
>> }
>> #+END_SRC
>>
>> The provided diff works for my small use case. What do you think?
>>
>> --
>> Best regards
>> John
>>
>>
--
Mvh John
[Prev in Thread] | Current Thread | [Next in Thread] |