Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work better with custom exec-style goals #6805

Merged
merged 2 commits into from Dec 12, 2023

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Dec 6, 2023

I have realized that when you use Micronaut module's dev mode, with continuous rebuild/restart supported by Maven plugin, the IDE's project customizer does not work that well.

First of all, it seems that when I try to work with micronaut-provided configuration change some mapping to it, a NPE is printed to the console during write:

java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "org.netbeans.modules.maven.configurations.M2Configuration.getActivatedProfiles()" is null
	at org.netbeans.modules.maven.configurations.M2ConfigProvider.writeAuxiliaryData(M2ConfigProvider.java:538)
	at org.netbeans.modules.maven.configurations.M2ConfigProvider.setConfigurations(M2ConfigProvider.java:310)
	at org.netbeans.modules.maven.customizer.CustomizerProviderImpl.writeAll(CustomizerProviderImpl.java:364)
	at org.netbeans.modules.maven.customizer.CustomizerProviderImpl$OptionListener.actionPerformed(CustomizerProviderImpl.java:333)
	at org.netbeans.modules.project.uiapi.CustomizerDialog$OptionListener$2$1$1.run(CustomizerDialog.java:289)
	at org.openide.filesystems.FileUtil$2.run(FileUtil.java:420)

This is caused by missing initialization of member variables in M2Configuration and is fixed TBD.

More important is that the UI for Run is completely disabled for Micronaut. This is becuase Micronaut uses mn:run goal, which is not recognized as 'executable' - NB evaluates the mapping to be incompatibly customized by the user and refuse to enable the Run arguments customizer:
disabled-customizer

So I've added a way how a plugin (Micronaut support) can inform the Maven core that there's a goal that works similar to Run. This makes the customizer to be enabled.

The last change is to properly map Micronaut devmode's Run parameters to goal parameters. While NB uses exec.vmArgs and exec.appArgs to configure arguments to the VM and application, and passes them in exec.args to the exec:exec plugin, the Micronaut maven plugin recognizes none of these properties. So I've changed the action mapping in Micronaut module to use mn.vmArgs and vm.appArgs as described in the plugin's documentation.

@sdedic sdedic added Maven [ci] enable "build tools" tests enterprise [ci] enable enterprise job labels Dec 6, 2023
@sdedic sdedic added this to the NB21 milestone Dec 6, 2023
@sdedic sdedic requested review from mbien and dbalek December 6, 2023 16:14
@sdedic sdedic self-assigned this Dec 6, 2023
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change makes sense to me + code looks good on first glance. Haven't tested it yet but I hope to have some time this weekend.

@neilcsmith-net
Copy link
Member

We had a similar conversation a while ago with regards to the JavaFX plugin execution goals. Not sure if there's somewhere we could / should make use of this there too?

I wonder if we should get some upstream (Maven) input on this requirement? There was certainly some discussion in the earlier conversation about how this sort of thing might be supported (via configuration or convention) such that IDEs could pick up some of this information automatically.

@sdedic
Copy link
Member Author

sdedic commented Dec 7, 2023

I wonder if we should get some upstream (Maven) input on this requirement? There was certainly some discussion in the earlier conversation about how this sort of thing might be supported (via configuration or convention) such that IDEs could pick up some of this information automatically.

The main problem here is that independently developed goals are likely to have their own properties (here, the Micronaut has no exec.args full commandline equivalent, and does not support working dir too !); some of the things can be overcomed by action mapping (as in this diff). SpringBoot plugin has also run and yet different properties that control it. Actually I shelved yet some other changes that could allow to report not only name, but also property mapping, so the (core) Maven support could determine what of the "standard" features are actually supported. But implementation would take too long, so I deferred that to later time.

Re: past conversation(s) - could you pls. find a link ?

@mbien
Copy link
Member

mbien commented Dec 7, 2023

@cstamas #6805 (comment), do tools have to know about non-standard (run) goals and their usage/config or is there a mechanism which would help to discover/map them?

@cstamas
Copy link
Member

cstamas commented Dec 7, 2023

@cstamas #6805 (comment), do tools have to know about non-standard (run) goals and their usage/config or is there a mechanism which would help to discover/map them?

They def could be discovered by tools, just like https://maven.apache.org/plugins/maven-help-plugin/describe-mojo.html

@sdedic
Copy link
Member Author

sdedic commented Dec 8, 2023

I's true that NB can discover goals and user properties that control the behaviour using maven model introspection , but I what is needed here is to recognize semantics - that a goal "executes" (in some way) the application - and which properties (jf any) serve to pass JVM / commandline arguments, main class, working dir etc. Is there such semantic categorization in MojoDescriptor or Parameter ?

@sdedic sdedic marked this pull request as ready for review December 8, 2023 06:26
@cstamas
Copy link
Member

cstamas commented Dec 8, 2023

Sadly no: goal names as "just strings", there is no semantics attached to it.

But what if some (human) introspects the given plugin, and deploy some "meta mapping" and NB picks that up? It could be plain artifact somewhere in Central...

@sdedic
Copy link
Member Author

sdedic commented Dec 8, 2023

Yes, this PR is just that -- except that it does not use artifacts, but NB-specific storage for the information. Low hanging fruit. I would let this to mature a bit (to see what categorization is actually useful and in what shape) before promoting to a wider ecosystem.

@sdedic sdedic requested a review from lahodaj December 8, 2023 18:51
Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

@sdedic
Copy link
Member Author

sdedic commented Dec 11, 2023

Squashed before merge.

@sdedic
Copy link
Member Author

sdedic commented Dec 12, 2023

If no further feedback comes, I'll merge this today.

@sdedic sdedic merged commit 57b607c into apache:master Dec 12, 2023
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enterprise [ci] enable enterprise job Maven [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants