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-25 17:42:30
Message-ID: 5F1C6F06.2020809@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 07/25/20 12:54, Kartik Ohri wrote:
> I have been going through the maven javadoc plugin's source. It is huge and
> is over 6000 lines. Thankfully, most of it is customization things we can
> avoid. I saw that the current configuration for maven javadoc has
> exclude parameters in the pom.xml file. Now, maven uses a DirectoryScanner
> to help out with the excludes which is available as a package in maven
> shared utils. I am unable to think of a way to handle excludes with the
> inbuilt Java APIs. Should I utilise DirectoryScanner or do you have any
> other suggestions?

I honestly want something without any of that jazz at all.

The bare javadoc tool does the right thing if run with defaults and
pointed at the module descriptor.

All the pain of 5ee9b6b and 395ac0d involved finding any possible way
to prevent the maven-javadoc-plugin from making the javadoc tool do
the wrong thing.

Running the tool the right way shouldn't take more than 5 lines of JS.

A MavenReport plugin will also need to send some information to the
Doxia Sink to get the basic report page made with a link to the javadoc;
that part might take more than 5 lines of script but I'd be surprised
if more than 15.

Literally, if a mojo implements MavenReport (or extends AbstractMavenReport)
and makes the right objects available to the script engine, I don't think
much else would be needed.

I did some playing around with javax.script.Invocable (which the JS
engines implement). You can define an interface with some instance
methods, and ask the engine for an instance of it, and if the script
defined the right functions, you get a usable-in-Java implementation
of that interface, which works by calling the script functions.

You can even define an interface that has some default methods, and
it can be instantiated as long as the script defined the functions
that are needed. If the script also defines a function corresponding
to a default method, that gets used too. It works very much as one
would guess.

(I did a big double-take when I noticed you could have an interface
with a default method, get an instance from the script engine, then
eval another script that defines the missing function, and after that
the Java instance you already had starts using the script function
instead of the default!)

That might be useful for this purpose, as a MavenReport has a bunch
of methods (getName, getCategoryName, canGenerateReport,
isExternalReport, etc.) that could be given reasonable defaults for
most cases, but maybe a script should be able to override.
MavenReport itself might not be the exact right interface to use
(the mojo itself should implement that, or extend AbstractMavenReport),
but maybe the mojo should declare a similar interface with a subset
of those methods, and have that be what the script block should
be able to supply).

Regards,
-Chap

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2020-07-25 18:00:45 Re: PL/Java new build plugin
Previous Message Kartik Ohri 2020-07-25 16:54:47 Re: PL/Java new build plugin