Re: PL/Java new build plugin

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Kartik Ohri <kartikohri13(at)gmail(dot)com>
Cc: pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Re: PL/Java new build plugin
Date: 2020-07-18 13:55:21
Message-ID: 5F12FF49.6090906@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 07/18/20 09:04, Kartik Ohri wrote:
> Therefore, we might need to do something similar as well to extract the
> script from the script tag.

That would surprise me. I think a lot of the details of how the
maven-antrun-plugin works are matters of history: Ant was there first,
then maven-antrun-plugin wanted to run it from maven and ended up
creating a temporary build xml file to do it, and so on.

I think if you were starting from scratch writing a Maven plugin to
allow scripts, you'd just have its configuration section in the pom
accept one element that is a mimetype and another element that's a
string, and go to the ScriptEngineManager and say "please give me
an engine for this mimetype so I can eval this string".

And the only tricky bit for Maven is making sure the ScriptEngineManager
will be able to find the engine on its class path.

> PS: One thing struck me that the javascript blocks seem to unnecessary if
> this is the case. The scripting plugin is wrapping the java functions in
> javascript and then parsing a javascript block to execute it. If it is
> possible to use the jshell as a scripting engine from the mojo, we could
> eliminate the javascript thing and script in Java instead. However, there

I like the jshell very much, but it is quite a different beast. By default
it starts up a second entire JVM and sends it snippets to run and gets
results back. It can be started with "-execution local" to move that
evaluation environment inside the current JVM, but that brings its own
complications. Out of the box, it isn't visible as a javax.script engine;
it's launched a whole different way.

That being said, there is somebody who figured out how to write a
ScriptEngine wrapper for it [1], which I consider very deep magic.

Which still brings us back where we were; if we develop a mojo that can
accept a mimetype and a block of text, and get the script engine for that
mimetype and run the block of text, then if we want to script bits in JS
we can, and if we want to script bits in Java we can, just by declaring
dependencies on the right script engines and using the right mimetypes.

Regards,
-Chap

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2020-07-18 13:56:16 Re: PL/Java new build plugin
Previous Message Kartik Ohri 2020-07-18 13:04:14 Re: PL/Java new build plugin