You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Chris Marusich <cm...@gmail.com> on 2021/08/24 01:13:56 UTC

How to manage "Platform Modules" in a Maven-based NetBeans Platform application?

Hi,

I'm experimenting with ways to build NetBeans Platform applications.
I'm still new to the platform.  I've been told that Maven is the way to
go [1].  That's great; I like Maven and have used it for years.
However, I'm having trouble understanding how to use (or exclude)
NetBeans Platform modules.  How does one usually do that?

Let me explain my confusion.  Consider this blog post from 2010:

  https://blogs.oracle.com/geertjan/an-xml-editor-in-3-steps-without-any-coding

In it, Geertjan describes how to add an XML Editor to your NetBeans
Platform application.  The critical steps are:

  2. Right-click the application, choose Properties, and go to the
     Libraries panel.

    - In "platform11", add a checkmark for "Favorites".

    - In "ide12", add a checkmark for "XML Text Editor" and then click
      the "Resolve" button.

Even today in NetBeans 12.4, these steps basically seem to work in the
case of an Ant-based NetBeans Platform application.  However, in the
case of a Maven-based NetBeans Platform application, the "Libraries"
panel doesn't even exist, so it seems it must be done differently.

How do you do this in the case of a Maven-based NetBeans Platform
application?  I have not yet found good documentation that describes how
to do this with Maven.  Everything I have found so far is specific to
the Ant-based scenario.  I imagine that adding or removing platform
features must not be too difficult.  What am I missing?

After some experimentation, I did discover that I can right click on the
"Dependencies" node of my Maven-based NetBeans Platform application in
the Projects window, and from there I can type the word "favorite" into
the "Query" field of the "Search" tab.  In this way I discovered that an
artifact named org.netbeans.modules:org-netbeans-modules.favorites
exists in Maven Central.  I suppose this single artifact might be what I
need for the "Favorites" feature, but who knows?  Even if that is the
case and nothing else is required, I'm still not sure how I would go
from "I read how to do this in an Ant-specific tutorial" to "I know how
to do this in the Maven case."

By the way, I notice that by default, a new Maven-based NetBeans
Platform application will declare a dependency on the artifact
org.netbeans.cluster:platform, which in turn depends on many, many other
artifacts (including
org.netbeans.modules:org-netbeans-modules.favorites).  If I DON'T want
to include one of these things (e.g., the Favorites feature), what's the
right way to remove it from my application?

Thank you for reading this far.  Hopefully I'm just missing something
obvious.

Footnotes:
[1]  https://lists.apache.org/thread.html/r945ab924cfc641ba71bce7c50c61af299446bfbe2b7a1624b1464673%40%3Cusers.netbeans.apache.org%3E

[2]  https://leanpub.com/nbp4beginners

-- 
Chris

Re: How to manage "Platform Modules" in a Maven-based NetBeans Platform application?

Posted by Chris Marusich <cm...@gmail.com>.
Hi Geertjan,

Geertjan Wielenga <ge...@googlemail.com> writes:

> It really depends on what you’re trying to develop.
>
> Put aside the theory and ask yourself practically what it is you’re working
> towards and what kind of functionality you need from the NetBeans Platform.
>
> Based on those requirements, assemble your POM, share your specific
> questions about your actual needs here, and we’ll help.

Thank you for the suggestion.  You're probably right.  I'll try focusing
on my practical needs first, taking it one step at a time.  If I get
stuck, I'll try to provide examples and be as specific as I can.

-- 
Chris

Re: How to manage "Platform Modules" in a Maven-based NetBeans Platform application?

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
It really depends on what you’re trying to develop.

Put aside the theory and ask yourself practically what it is you’re working
towards and what kind of functionality you need from the NetBeans Platform.

Based on those requirements, assemble your POM, share your specific
questions about your actual needs here, and we’ll help.

Gj

On Tue, 24 Aug 2021 at 03:14, Chris Marusich <cm...@gmail.com> wrote:

> Hi,
>
> I'm experimenting with ways to build NetBeans Platform applications.
> I'm still new to the platform.  I've been told that Maven is the way to
> go [1].  That's great; I like Maven and have used it for years.
> However, I'm having trouble understanding how to use (or exclude)
> NetBeans Platform modules.  How does one usually do that?
>
> Let me explain my confusion.  Consider this blog post from 2010:
>
>
> https://blogs.oracle.com/geertjan/an-xml-editor-in-3-steps-without-any-coding
>
> In it, Geertjan describes how to add an XML Editor to your NetBeans
> Platform application.  The critical steps are:
>
>   2. Right-click the application, choose Properties, and go to the
>      Libraries panel.
>
>     - In "platform11", add a checkmark for "Favorites".
>
>     - In "ide12", add a checkmark for "XML Text Editor" and then click
>       the "Resolve" button.
>
> Even today in NetBeans 12.4, these steps basically seem to work in the
> case of an Ant-based NetBeans Platform application.  However, in the
> case of a Maven-based NetBeans Platform application, the "Libraries"
> panel doesn't even exist, so it seems it must be done differently.
>
> How do you do this in the case of a Maven-based NetBeans Platform
> application?  I have not yet found good documentation that describes how
> to do this with Maven.  Everything I have found so far is specific to
> the Ant-based scenario.  I imagine that adding or removing platform
> features must not be too difficult.  What am I missing?
>
> After some experimentation, I did discover that I can right click on the
> "Dependencies" node of my Maven-based NetBeans Platform application in
> the Projects window, and from there I can type the word "favorite" into
> the "Query" field of the "Search" tab.  In this way I discovered that an
> artifact named org.netbeans.modules:org-netbeans-modules.favorites
> exists in Maven Central.  I suppose this single artifact might be what I
> need for the "Favorites" feature, but who knows?  Even if that is the
> case and nothing else is required, I'm still not sure how I would go
> from "I read how to do this in an Ant-specific tutorial" to "I know how
> to do this in the Maven case."
>
> By the way, I notice that by default, a new Maven-based NetBeans
> Platform application will declare a dependency on the artifact
> org.netbeans.cluster:platform, which in turn depends on many, many other
> artifacts (including
> org.netbeans.modules:org-netbeans-modules.favorites).  If I DON'T want
> to include one of these things (e.g., the Favorites feature), what's the
> right way to remove it from my application?
>
> Thank you for reading this far.  Hopefully I'm just missing something
> obvious.
>
> Footnotes:
> [1]
> https://lists.apache.org/thread.html/r945ab924cfc641ba71bce7c50c61af299446bfbe2b7a1624b1464673%40%3Cusers.netbeans.apache.org%3E
>
> [2]  https://leanpub.com/nbp4beginners
>
> --
> Chris
>

Re: How to manage "Platform Modules" in a Maven-based NetBeans Platform application?

Posted by Chris Marusich <cm...@gmail.com>.
Hi Eirik,

Eirik Bakke <eb...@ultorg.com> writes:

> There are usually two kinds of modules you will need to add: "API"
> modules (typically groupId org.netbeans.api), and implementation
> modules (typically groupId org.netbeans.modules). The API modules you
> can find by typing the name of the class you need to use into the Add
> Dependency UI. The implementation modules are added with "
> <scope>runtime</scope> ", and you usually find them by running your
> app and getting an error that some implementation module is not
> available.

This is very useful to know.

>> By the way, I notice that by default, a new Maven-based NetBeans
>> Platform application will declare a dependency on the artifact
>> org.netbeans.cluster:platform, which in turn depends on many, many
>> other artifacts (including
>> org.netbeans.modules:org-netbeans-modules.favorites).  If I DON'T
>> want to include one of these things (e.g., the Favorites feature),
>> what's the right way to remove it from my application?
>
> Looking at my own NetBeans Platform application, it does indeed depend
> on org.netbeans.cluster:platform. I think for things that are included
> in this cluster, the best way to get rid of them is to remove the
> relevant actions/menu items etc. from the branding module's layer.xml
> . Once you have a layer.xml file added to a module, you can expand it
> in the NetBeans IDE, expand "<this layer in context>", and then start
> deleting things you don't want. This will generate the required
> ".instance_hidden" XML configuration lines.
>
> Alternatively it might be possible to not include the platform cluster
> and instead enumerate the relevant modules manually. I haven't tried
> this myself, though.

I figured I could whittle down the Maven dependencies to a smaller set,
provided I know what "the right" set is.  However, I didn't realize you
could customize the layers like you mentioned.  Nice idea!

I still have much to learn.  Thank you for your help,

-- 
Chris

RE: How to manage "Platform Modules" in a Maven-based NetBeans Platform application?

Posted by Eirik Bakke <eb...@ultorg.com>.
Yes, I think the "Libraries" UI that's described in the blog post works only on Ant-based NetBeans Platform projects. I'd still recommend using Maven going forward, though.

For Maven, you can click "Add Dependency" in the context menu for the "Dependencies" folder, to help add dependencies to your module's pom.xml.

There are usually two kinds of modules you will need to add: "API" modules (typically groupId org.netbeans.api), and implementation modules (typically groupId org.netbeans.modules). The API modules you can find by typing the name of the class you need to use into the Add Dependency UI. The implementation modules are added with " <scope>runtime</scope> ", and you usually find them by running your app and getting an error that some implementation module is not available.

> By the way, I notice that by default, a new Maven-based NetBeans Platform application will declare a dependency on the artifact org.netbeans.cluster:platform, which in turn depends on many, many other artifacts (including org.netbeans.modules:org-netbeans-modules.favorites).  If I DON'T want to include one of these things (e.g., the Favorites feature), what's the right way to remove it from my application?

Looking at my own NetBeans Platform application, it does indeed depend on org.netbeans.cluster:platform. I think for things that are included in this cluster, the best way to get rid of them is to remove the relevant actions/menu items etc. from the branding module's layer.xml . Once you have a layer.xml file added to a module, you can expand it in the NetBeans IDE, expand "<this layer in context>", and then start deleting things you don't want. This will generate the required ".instance_hidden" XML configuration lines.

Alternatively it might be possible to not include the platform cluster and instead enumerate the relevant modules manually. I haven't tried this myself, though.

-- Eirik

-----Original Message-----
From: Chris Marusich <cm...@gmail.com> 
Sent: Monday, August 23, 2021 9:14 PM
To: users@netbeans.apache.org
Subject: How to manage "Platform Modules" in a Maven-based NetBeans Platform application?

Hi,

I'm experimenting with ways to build NetBeans Platform applications.
I'm still new to the platform.  I've been told that Maven is the way to go [1].  That's great; I like Maven and have used it for years.
However, I'm having trouble understanding how to use (or exclude) NetBeans Platform modules.  How does one usually do that?

Let me explain my confusion.  Consider this blog post from 2010:

  https://blogs.oracle.com/geertjan/an-xml-editor-in-3-steps-without-any-coding

In it, Geertjan describes how to add an XML Editor to your NetBeans Platform application.  The critical steps are:

  2. Right-click the application, choose Properties, and go to the
     Libraries panel.

    - In "platform11", add a checkmark for "Favorites".

    - In "ide12", add a checkmark for "XML Text Editor" and then click
      the "Resolve" button.

Even today in NetBeans 12.4, these steps basically seem to work in the case of an Ant-based NetBeans Platform application.  However, in the case of a Maven-based NetBeans Platform application, the "Libraries"
panel doesn't even exist, so it seems it must be done differently.

How do you do this in the case of a Maven-based NetBeans Platform application?  I have not yet found good documentation that describes how to do this with Maven.  Everything I have found so far is specific to the Ant-based scenario.  I imagine that adding or removing platform features must not be too difficult.  What am I missing?

After some experimentation, I did discover that I can right click on the "Dependencies" node of my Maven-based NetBeans Platform application in the Projects window, and from there I can type the word "favorite" into the "Query" field of the "Search" tab.  In this way I discovered that an artifact named org.netbeans.modules:org-netbeans-modules.favorites
exists in Maven Central.  I suppose this single artifact might be what I need for the "Favorites" feature, but who knows?  Even if that is the case and nothing else is required, I'm still not sure how I would go from "I read how to do this in an Ant-specific tutorial" to "I know how to do this in the Maven case."

By the way, I notice that by default, a new Maven-based NetBeans Platform application will declare a dependency on the artifact org.netbeans.cluster:platform, which in turn depends on many, many other artifacts (including org.netbeans.modules:org-netbeans-modules.favorites).  If I DON'T want to include one of these things (e.g., the Favorites feature), what's the right way to remove it from my application?

Thank you for reading this far.  Hopefully I'm just missing something obvious.

Footnotes:
[1]  https://lists.apache.org/thread.html/r945ab924cfc641ba71bce7c50c61af299446bfbe2b7a1624b1464673%40%3Cusers.netbeans.apache.org%3E

[2]  https://leanpub.com/nbp4beginners

--
Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists