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 IL1tCgiPc1+hFQAA0tVLHw (envelope-from ) for ; Tue, 29 Sep 2020 19:46:16 +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 wMQzBgiPc18TRgAAbx9fmQ (envelope-from ) for ; Tue, 29 Sep 2020 19:46:16 +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 91CB9940222 for ; Tue, 29 Sep 2020 19:46:14 +0000 (UTC) Received: from localhost ([::1]:60370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNLZj-0008WD-Rn for larch@yhetil.org; Tue, 29 Sep 2020 15:46:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNLCi-00055r-Qj for emacs-orgmode@gnu.org; Tue, 29 Sep 2020 15:22:31 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:39574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNLCg-0004IC-Uk for emacs-orgmode@gnu.org; Tue, 29 Sep 2020 15:22:24 -0400 Received: by mail-lf1-x12a.google.com with SMTP id q8so6862841lfb.6 for ; Tue, 29 Sep 2020 12:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=UNSkcT/DdkaJ5kaikMth2DNsTTmAjOEo1pIHsqIYJgI=; b=jjeP33dsD3qBJ9fMPiWY/HYAT9eoseiH4he81WuRQFjPFIcZfMT4Qst7P95CKHXyQY yzzuBIOEaiw0zF7lhc4Ewe5zRW9o+8+/rziIKBHha1G3bb8fkq2KmcrW+5NDv18tv2td 1sbAEF6fRIMieBON5x2j/3N2NTa2ySrw+q6z4DlrI4YIb4FQ8PnwFP32Ep4sr2FwbQVe zLyL5xg04aZBoYj7thdugut3esklOB6xJzeUhQHet5qvnZZqc4u3FkRpDraQsoqMsHQ9 YhuFJGoe76zYVGw6LRZoiVY/k2axgwOz3nqA+vxrf0qMR523ZOSYSxEtcb/fYT44nrnG sjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=UNSkcT/DdkaJ5kaikMth2DNsTTmAjOEo1pIHsqIYJgI=; b=RqCzCgWSxkL1JjO3zwR6zUBqwXNhtxEAesm0OeNosIHUvqnQXiGeznT8WlucpuzbKC jyxZHSibzVhVxaM7mHZwwGapfQLgG3SOpIzKKb/l5W2GKmt/MOfpG3zy/64OSFEYSrzR ST0PuudfpcYM3VvUVfYoL/PKdfYoBkqTWPb8hh4E/xh4zismlyqJ0GiBa1KIBC4nOImG CU3USMfiftV11vF7XqThU5cPhLIUYReBD70FMY7irE6b/EwzFyYbQKqXSsEsTyqEYC/6 YgG9hQZMpRyLp0iI2wr2AmINKcwbINV2rjns2iBXUdL5j5laTLEEN3u5kODyFrfjSYG6 ilMw== X-Gm-Message-State: AOAM532Ia8khdtHMmvwHua0NvW+sZCrQQITeFkdQweQLUFkhVS8zdQ7c DHNEhQ+OciGOxkGeT8k4s6hwQhteuMw= X-Google-Smtp-Source: ABdhPJw0wt7X1ZBdzKxAsE1lrZvDrjiN0iNepSSEaLAMNYyTzPf2MEDrM3kS/fap+UdZsCp8PdMR4w== X-Received: by 2002:a19:89d7:: with SMTP id l206mr1954484lfd.110.1601407339638; Tue, 29 Sep 2020 12:22:19 -0700 (PDT) Received: from fnox ([2a02:aa1:161b:a9d7:530:8e9d:bf0:4fd0]) by smtp.gmail.com with ESMTPSA id r21sm3325110lff.288.2020.09.29.12.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 12:22:18 -0700 (PDT) References: <87imbyapel.fsf@gmail.com> <874knitj6k.fsf@gmail.com> User-agent: mu4e 1.4.13; emacs 27.1 From: John Herrlin To: ian martins Subject: Re: ob-java compile only In-reply-to: Message-ID: <87y2ksie1k.fsf@gmail.com> Date: Tue, 29 Sep 2020 21:22:16 +0200 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=jherrlin@gmail.com; helo=mail-lf1-x12a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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=pass header.d=gmail.com header.s=20161025 header.b=jjeP33ds; dmarc=pass (policy=none) header.from=gmail.com; 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.21 X-TUID: MU5Vlo7Ks8XB ian martins writes: > 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. Thank you for the feedback, I am all with you on that and I think consistency is very important! > > 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. The alternatives are nice and I will manage fine! Looking forward to see what will happen to ob-java! :) > > 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 >> -- Mvh John