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-14 04:34:02
Message-ID: 5F0D35BA.30904@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 07/13/20 12:05, Kartik Ohri wrote:
> I have incorporated your comments in the code. I read about the scripting
> engine but the details were scarce. Do you have any resources to learn
> about it ?

Hi,

The basics of getting a script engine to work are pretty straightforward;
you can look here [1] in the class that goes in the self-installer jar
and runs a script to resolve installation path names.

You can have a MIME type like application/javascript and ask the
ScriptEngineManager to get an engine that handles that MIME type,
and if there's one around, the manager gives you it.

You can put things into its symbol table by names so scripts can refer
to them, and you can have it eval a script, and you can get values back
from its symbol table that the script may have set.

There are additional possibilities I didn't use there. If the script
engine that the manager gives you is instanceof Invocable, then you don't
have to just feed it scripts to eval: you can feed it a script that
defines various functions, and after that you can use it to just invoke
the functions whenever needed. If you have some Java interface in mind,
and the script defined the right set of functions, you can ask the
engine to generate a Java class that implements the interface, which
you can use in Java any way you want. Calls to the interface methods
go to the functions in the script.

We might very well want to use that.

> How should I proceed with my work ? As of now, I am able to set the
> properties. The next step seems to be to begin replacing nar
> plugin's functionality.

I think it would probably be helpful to work on script engine integration
next. I wouldn't really want to tackle replacing nar functionality without
it.

There is also another way script engine functionality would be helpful:
I would like this plugin to also include a mojo that implements
MavenReport [2], maybe by extending AbstractMavenReport, and would
essentially have one configuration option, a script.

I would like that because I am really very tired of maven-javadoc-plugin.

This is timely because I have just made a PR that adds a bunch of new
code in pljava-packaging, enough that I would now like javadoc for that,
and I am fighting with the maven-javadoc-plugin again.

5ee9b6b was already at least one full day of working around bugs in
that plugin, and 395ac0d was another full day of the same, and I am not
interested in spending another. The thing is, running the javadoc tool
really isn't that hard! Running it and passing it the right arguments
ought to be about four lines of script, and they would be right there
in the POM for anybody to look at who wondered why it did or did not
do something.

...

By the way, if you have a moment for a break in between other things,
I would be happy if you could look at the pull request I just put in [3].

I don't have an easy way to test it on Windows, and I wouldn't be
surprised if some details in init() or start(), for example, might
need adjustment there.

Regards,
-Chap

[1] https://github.com/tada/pljava/blob/b0330f7/org/gjt/cuspy/JarX.java#L544
[2]
https://maven.apache.org/guides/plugin/guide-java-report-plugin-development.html
[3] https://github.com/tada/pljava/pull/287

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2020-07-14 05:16:59 I propose to commit a .editorconfig file for PL/Java
Previous Message Kartik Ohri 2020-07-13 16:05:14 Re: PL/Java new build plugin