Hi Chris.
Firstly, I have no experience in developing Netbeans Platform projects.  However, I have developed many others, all Open Source https://github.com/bewillcott <https://github.com/bewillcott>. As a suggestion to help with the deployment side, I wish to offer the following ideas for the Maven POM:

<project ...>

   ...

    <properties>
        <jar.manifest.mainClass>com.yourproject.Main</jar.manifest.mainClass>
        ...
    </properties>

    <profiles>
        <profile>
            <id>release-profile</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>Zip Binary Jar and libs</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>zip</executable>
                                    
<workingDirectory>${project.build.directory}</workingDirectory>
                                    
<includeProjectDependencies>false</includeProjectDependencies>
                                    
<includePluginDependencies>true</includePluginDependencies>
                                    <arguments>
                                        <argument>-r</argument>
                                        
<argument>${project.build.finalName}.zip</argument>
                                        
<argument>${project.build.finalName}.jar</argument>
                                        <argument>libs</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                   ...

                </plugins>
            </build>
        </profile>

        ...

    </profiles>

    <build>
        <resources>
            <resource>
                <directory>
                    src/main/resources
                </directory>
                <includes>
                    <include>
                    **/*
                    </include>
                </includes>
            </resource>

            ...

        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <excludeScope>test</excludeScope>
                            <outputDirectory>
                                ${project.build.directory}/libs
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>libs/</classpathPrefix>
                            <mainClass>${jar.manifest.mainClass}</mainClass>
                            
<addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
                            
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            ...

        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>

                ...

            </plugins>
        </pluginManagement>

        ...
  </build>
</project>

What you will end-up with, amongst other files, is a Zip file with the program jar and a 'libs' directory containing all of the project's dependencies.  To install, just unpack the zip file into an application directory, and run the application from this directory ("java -jar <finalName>.jar").  It will automatically find all of its dependencies in the 'lib' directory.

Separately, I don't see any issue with an end-user having to install a version of the JRE to run Java applications.  In Windows, it is quite easy, isn't it?

I know that this does not properly answer your questions, but I hope it helps.

Regards,
Brad.

On 8/7/21 3:24 am, Chris Marusich <cmmarus...@gmail.com> wrote:
Subject:
NetBeans Platform "Golden Path"
From:
Chris Marusich <cmmarus...@gmail.com>
Date:
8/7/21, 3:24 am

To:
users@netbeans.apache.org


Hi,

What's the current "best practice" or "golden path" for building and
distributing a NetBeans Platform application and managing its
dependencies (e.g., from Maven central)?  That's a big general question,
so I'll ask some specifics:

- Should I ever try to use JPMS modules when building a NetBeans
Platform application?  I've found that in my projects (which are
NetBeans Maven-based projects, not NetBeans Platform projects), when I
use JPMS modules, it can cause problems for NetBeans [1], so I wonder if
it's really wise to even try mixing JPMS modules with NetBeans projects
at this time, let alone NetBeans Platform projects.

- Should I ever try to make a Maven-based NetBeans Platform application?
I see there are Maven templates in NetBeans that offer to create a
Maven-based NetBeans Platform project.  However, all the examples online
and in books that I've seen so far do NOT use Maven.  In spite of this,
recent emails on this list have suggested that Maven-based NetBeans
projects are generally preferred over the older Ant-based project types.
So I'm a bit confused about what the currently prevailing wisdom on this
matter is, in the case of NetBeans Platform projects.  Perhaps Maven can
be used to build NetBeans Platform applications/modules or not,
depending on the situation.  As a beginner in the world of NetBeans
Platform, I just want to try making a NetBeans Platform project using
whatever approach is more likely to work without trouble and remain
supported by the community.  But what approach might that be?

- If I want to use a library that is available from Maven central in my
NetBeans Platform application, is the best option to just manually
download the JAR file, manually create a NetBeans Platform "wrapper
module" for the JAR, and then use the "wrapper module" in my
application?  I tried using the nbm-maven-plugin to use dependencies
from Maven in a simple NetBeans Platform application, but I encountered
problems and couldn't figure out how to get it to work.  So to me it
feels like the answer to this question is "yes, at the moment you should
manage your JARs manually in order to have the best developer experience
when working on a NetBeans Platform application," but I'm not sure.  I'm
curious to hear the opinions of people who have more experience with the
NetBeans Platform.

- If I want to build a stand-alone release of my NetBeans Platform
application that I can distribute to an end user, what's a good way to
do it?  It seems that some of the features in NetBeans that build a
stand-alone release will only work when your project is not a
Maven-based NetBeans Platform application.  Additionally, although
recent developments like jlink and jpackage have made it somewhat easier
to produce stand-alone application bundles that don't require the user
to first install a JRE, which is nice, it seems that these tools
sometimes require the use of JPMS modules, which can be problematic in
NetBeans (see above).  And in any case NetBeans does not yet seem to
expose any way to take advantage of these new tools.  So what IS the
most common way that people build a release version of a NetBeans
Platform application, anyway?
Ultimately, I just don't understand what the current "best practice" or
"golden path" is for using NetBeans Platform.  I'd like to know, though.
I am happy to help improve the tutorials, but the problem is that even
after reading various tutorials and documentation, and even after
experimenting quite a bit on my own, I don't even understand what the
path of least resistance is supposed to be.

Footnotes:
[1]http://mail-archives.apache.org/mod_mbox/netbeans-users/202010.mbox/%3c87sg9wgt19....@gmail.com%3E

-- Chris

Reply via email to