From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KK0uM6+Zcl/uawAA0tVLHw (envelope-from ) for ; Tue, 29 Sep 2020 02:19:27 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id gIvoLq+Zcl/HTAAAbx9fmQ (envelope-from ) for ; Tue, 29 Sep 2020 02:19:27 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 440C394023A for ; Tue, 29 Sep 2020 02:19:27 +0000 (UTC) Received: from localhost ([::1]:60516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kN5Ei-000490-Sb for larch@yhetil.org; Mon, 28 Sep 2020 22:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kN5EL-00048n-Uh for emacs-orgmode@gnu.org; Mon, 28 Sep 2020 22:19:02 -0400 Received: from mail-ej1-f50.google.com ([209.85.218.50]:36186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kN5EH-0004vZ-Km for emacs-orgmode@gnu.org; Mon, 28 Sep 2020 22:19:01 -0400 Received: by mail-ej1-f50.google.com with SMTP id h26so2537523ejq.3 for ; Mon, 28 Sep 2020 19:18:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cymLTch/HFrJrZ36M4M/DX+U0eCBN52ThiYJXF8n82o=; b=YWVZeMHIvFkdicwbXswF6xJUuJIRicRF5h1dcCPXq5TWSVkZT3w1Bj3KXD2QilRNwC fCorZBfRJa15WNTJ2zv/VzSXZSPyNN3eFRfvf1CrEcUl6L6Vyzjo2/LB7PHyvcFy7eRA fydNaD1FsO2fjgKeRuUnVZeUKSZJ2lv42ZBM1UORMVk3nYr/UJb9HHpspOe+epF3sqB7 EtGK0qolII89Xud+HL3CRE5+vLglZjXFOBNI06gF7S1+a0FP2aY5dRQRu4R8HRFhWYh4 NJiFhM8tdHkpLpXEFNwAuCD8waLVnUoqm10BpO7qb/nJgOrzY5D4n1CD+5q38fTcgjLK Pq7w== X-Gm-Message-State: AOAM531diML6lJkeJo2q+Jg50cYVf5+dMKFqKkrAMkVcSFxN27M4KPSn 5+4xX2FpkmYGA3IcDEWv4uY3IQOPB64gv1SAlJU= X-Google-Smtp-Source: ABdhPJw+OQBDn93FDXWVYP5ZYhVbSbIrpWeh6bosAnwKiORkHzpqA9lzLuQt9j61/XQ0CMIN51PMb1JgpA/hycnYdBk= X-Received: by 2002:a17:906:2619:: with SMTP id h25mr1634362ejc.142.1601345935287; Mon, 28 Sep 2020 19:18:55 -0700 (PDT) MIME-Version: 1.0 References: <87imbyapel.fsf@gmail.com> <874knitj6k.fsf@gmail.com> In-Reply-To: <874knitj6k.fsf@gmail.com> From: ian martins Date: Mon, 28 Sep 2020 22:18:44 -0400 Message-ID: Subject: Re: ob-java compile only To: John Herrlin Content-Type: multipart/alternative; boundary="000000000000a2aaea05b06a67bd" Received-SPF: pass client-ip=209.85.218.50; envelope-from=ianxm1@gmail.com; helo=mail-ej1-f50.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/28 22:18:55 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.199, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-Mode mailing list Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=jhu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: t6/c2JnDndpZ --000000000000a2aaea05b06a67bd Content-Type: text/plain; charset="UTF-8" Thanks for explaining. That makes sense. I'm hesitant to add the compile-only header for a couple reasons. Generally C-c C-c on a source block means "run this" but with compile-only it'll mean "run this but don't run it." It's semantically inconsistent. Also I want to bring more feature parity to ob-java, so that there's more consistency across babel. I'm reluctant to add headers not found elsewhere. Consider some alternatives: 1. one option is to add a dummy main to every class. it could do nothing or run unit tests. it's not a bad place to kick off unit tests, but I don't think you should have to. 2. you could use org-babel-tangle to write out the source files, and compile from an emacs compile buffer. this might be more convenient than compiling from babel since recompiles are a single keystroke. 3. a future version of ob-java will know if a class has a "public static void main." at that point it'll be easy to automatically skip execution of the class if it doesn't define a main, without the need for a new header. On Mon, Sep 28, 2020 at 4:11 AM John Herrlin wrote: > > 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 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 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 > --000000000000a2aaea05b06a67bd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for explaining. That makes sense.

I'm hesitant to add the compile-only header for a coup= le reasons. Generally C-c C-c on a source block means "run this" = but with compile-only it'll mean "run this but don't run it.&q= uot; It's semantically inconsistent. Also I want to bring more feature = parity to ob-java, so that there's more consistency across babel. I'= ;m reluctant to add headers not found elsewhere.

Consider some alternatives:
1. one option is to add a dummy ma= in to every class. it could do nothing or run unit tests. it's not a ba= d place to kick off unit tests, but I don't think you should have to.
2. you could use org-babel-tangle to write out the source files, a= nd compile from an emacs compile buffer. this might be more convenient than= compiling from babel since recompiles are a single keystroke.
3. a future version of ob-java will know if a class has a "public st= atic void main." at that point it'll be easy to automatically skip= execution of the class if it doesn't define a main, without the need f= or a new header.

On Mon, Sep 28, 2020 at 4:11 AM John Herrlin <jherrlin@gmail.com> wrote:

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:

=C2=A0 =C2=A0#+HEADER: :classname se/my_test_package/Hey
=C2=A0 =C2=A0#+HEADER: :compile-only t
=C2=A0 =C2=A0#+HEADER: :results none
=C2=A0 =C2=A0#+HEADER: :dir src
=C2=A0 =C2=A0#+BEGIN_SRC java
=C2=A0 =C2=A0 =C2=A0package se.my_test_package;

=C2=A0 =C2=A0 =C2=A0public class Hey {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0public static String hey(String name) { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return "Hey " + n= ame;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0#+END_SRC

=C2=A0 =C2=A0#+BEGIN_SRC clojure :results output code
=C2=A0 =C2=A0 =C2=A0(import [se.my_test_package Hey])

=C2=A0 =C2=A0 =C2=A0(Hey/hey "John")
=C2=A0 =C2=A0#+END_SRC


Best regards



ian martins <ianxm@jh= u.edu> writes:

> Hi John,
>
> Thanks for the suggestion and patch. Is the reason for this so that yo= u 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 file= s to
> the pkg dir)
> 4. run C-c C-c on the top source block (this compiles both source file= s and
> runs main)
>
> ----- javatangle.org -----
>
> #+begin_src java :results output :classname pkg/Main :tangle pkg/Main.= java
>=C2=A0 =C2=A0package pkg;
>
>=C2=A0 =C2=A0public class Main {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0public static void main(String[] args) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0System.out.println(Hey.hey());=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0}
> #+end_src
>
> #+begin_src java :results output :classname pkg/Hey :tangle pkg/Hey.ja= va
>=C2=A0 =C2=A0package pkg;
>
>=C2=A0 =C2=A0public class Hey {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0public static String hey() {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return "hey";
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0}
> #+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.
>>
>>=C2=A0 =C2=A0 #+HEADER: :classname se/my_test_package/Hey
>>=C2=A0 =C2=A0 #+HEADER: :dir src
>>=C2=A0 =C2=A0 #+HEADER: :compile-only t
>>=C2=A0 =C2=A0 #+HEADER: :results none
>>=C2=A0 =C2=A0 #+BEGIN_SRC java
>>=C2=A0 =C2=A0 =C2=A0 package se.my_test_package;
>>
>>=C2=A0 =C2=A0 =C2=A0 public class Hey {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 public static String hey(String = name) {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return "Hey &= quot; + name;
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>>=C2=A0 =C2=A0 =C2=A0 }
>>=C2=A0 =C2=A0 #+END_SRC
>>
>> The provided diff works for my small use case. What do you think?<= br> >>
>> --
>> Best regards
>> John
>>
>>


--
Mvh John
--000000000000a2aaea05b06a67bd--