blob: 81cb2df296e25d8d9ab29737b65035db9b9004c1 [file] [log] [blame]
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>NetBeans Platform Maven Command Line Tutorial</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="NetBeans Platform Maven Command Line Tutorial - Apache NetBeans">
<meta name="author" content="Apache NetBeans">
<meta name="description" content="NetBeans Platform Maven Command Line Tutorial - Apache NetBeans">
<meta name="keywords" content="Apache NetBeans Platform, Platform Tutorials, NetBeans Platform Maven Command Line Tutorial">
<meta name="generator" content="Apache NetBeans">
<link rel="stylesheet" href="../../../../_/css/font-awesome.min.css">
<link rel="alternate" type="application/atom+xml" title="Apache NetBeans Blog" href="https://netbeans.apache.org/blogs/atom" />
<link rel="stylesheet" href="../../../../_/css/highlightjs/default.min.css">
<link rel="stylesheet" href="../../../../_/css/netbeans.css">
<link rel="apple-touch-icon" sizes="180x180" href="../../../../_/images/fav/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../../../../_/images/fav/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../../../../_/images/fav/favicon-16x16.png">
<link rel="manifest" href="../../../../_/images/fav/site.webmanifest">
<link rel="mask-icon" href="../../../../_/images/fav/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#ffc40d">
<meta name="theme-color" content="#ffffff">
<link href="../../../../_/css/font-open-sans.css" rel="stylesheet">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
</head>
<body>
<div class="title-bar" data-responsive-toggle="responsive-menu" data-hide-for="medium">
<button type="button" data-toggle="responsive-menu"><i style='font-size: 32px; color: #fff; padding: 8px' class='fa fa-bars'></i></button>
<div class="title-bar-title">Apache NetBeans</div>
</div>
<div class="top-bar" id="responsive-menu">
<div class='top-bar-left'>
<a class='title' href="../../../../index.html"><img src='../../../../_/images/apache-netbeans.svg' style='padding: 8px; height: 48px;'> Apache NetBeans</a>
</div>
<div class="top-bar-right">
<ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown">
<li> <input id="search-input" type="text" placeholder="Search the docs"> </li>
<li> <a href="../../../../front/main/community">Community</a> </li>
<li> <a href="../../../../front/main/participate">Participate</a> </li>
<li> <a href="../../../../front/main/blogs">Blog</a></li>
<li> <a href="../../../../front/main/help">Get Help</a> </li>
<li> <a href="https://plugins.netbeans.apache.org/">Plugins</a> </li>
<li> <a href="../../../../front/main/download">Download</a> </li>
</ul>
</div>
</div>
<!-- src/templates/news -->
<section class="hero news alternate">
<div class='grid-container'>
<div class='cell'>
<div class="annotation">Latest release</div>
<h1>Apache NetBeans 27</h1>
<p><a class="button success" href="../../../../front/main/download/nb27">Download</a></p>
</div>
</div>
</section>
<div class='grid-container main-content tutorial'>
<h1 class="sect0">NetBeans Platform Maven Command Line Tutorial</h1>
<div class="sectionbody">
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon"><i class="fa icon-note" title="Note"></i></td>
<td class="content">This tutorial needs a review.
You can <a href="https://github.com/apache/netbeans-antora-tutorials/edit/main/modules/ROOT/pages/tutorials/nbm-maven-commandline.adoc" title="Edit this tutorial in github">edit it in GitHub </a>
following these <a href="../../../../tutorial/main/kb/docs/contributing">contribution guidelines.</a></td>
</tr></tbody>
</table>
</div>
</div>
<div id="toc" class="toc">
<div id="toctitle"></div>
<ul class="sectlevel1">
<li><a href="#_creating_the_netbeans_platform_application">Creating the NetBeans Platform Application</a></li>
<li><a href="#_installing_and_running_the_netbeans_platform_application">Installing and Running the NetBeans Platform Application</a></li>
<li><a href="#_creating_a_netbeans_module_from_an_archetype">Creating a NetBeans Module from an Archetype</a></li>
<li><a href="#_adding_the_new_netbeans_module_as_a_dependency">Adding the New NetBeans Module as a Dependency</a></li>
<li><a href="#_building_the_netbeans_platform_application_with_the_new_netbeans_module">Building the NetBeans Platform Application With the New NetBeans Module</a></li>
<li><a href="#_see_also">See Also</a></li>
</ul>
</div>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Welcome to the <a href="https://netbeans.apache.org/platform/"><strong>NetBeans Platform</strong></a>!</p>
</div>
<div class="paragraph">
<p>This document demonstrates how to create a NetBeans Platform application and module from a command line prompt using the Maven build framework. To create this application you do not need to install or use the NetBeans IDE. You will need to create and edit some files, but you can use a simple text editor. However, an IDE can be very helpful when performing tasks such as editing the POM and managing dependencies.</p>
</div>
<div class="paragraph">
<p>In this tutorial you will see that after you install Maven, you can specify goals and parameters and execute Maven goals from the command line prompt to create and build projects. The IDE performs the same task, but provides an interface that simplifies the task of specifying the parameters for creating projects.</p>
</div>
<div class="paragraph">
<p>Before starting this tutorial you may want to familiarize yourself with the following documentation.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="http://maven.apache.org/guides/mini/guide-configuring-maven.html">Maven - Guide to Configuring Maven</a></p>
</li>
<li>
<p><a href="http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html">Maven in 5 Minutes</a></p>
</li>
<li>
<p><a href="http://www.sonatype.com/books/maven-book/reference/introduction.html">Chapter 1. Introducing Apache Maven</a> (from <a href="http://www.sonatype.com/books/maven-book/reference/public-book.html">Maven: The Definitive Guide</a>)</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_creating_the_netbeans_platform_application"><a class="anchor" href="#_creating_the_netbeans_platform_application"></a>Creating the NetBeans Platform Application</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this exercise you will execute the Maven goal <code>generate</code> from the command line to generate a new NetBeans Platform application from an archetype in the codehaus.org repository. In the command you will specify the parameters that will be used when Maven generates the application.</p>
</div>
<div class="olist arabic">
<ol class="arabic" start="1">
<li>
<p>Install <a href="http://maven.apache.org/">Maven</a>.</p>
</li>
</ol>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>Open a command line terminal.</p>
</li>
</ol>
</div>
<div class="olist arabic">
<ol class="arabic" start="3">
<li>
<p>Test your Maven installation by typing the following command.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn -version</code></pre>
</div>
</div>
<div class="paragraph">
<p>After you type the command you will see details about the Maven installation, including the version of Maven and the JDK, such as the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T15:51:42+02:00)
Maven home: C:\apache-maven-3.2.2
Java version: 1.8.0-ea, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="4">
<li>
<p>Navigate to the directory where you want to create the NetBeans Platform application.</p>
</li>
</ol>
</div>
<div class="olist arabic">
<ol class="arabic" start="5">
<li>
<p>Type the following command, on a single line, in a terminal window (also known as the command prompt):</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn
-DarchetypeGroupId=org.apache.netbeans.archetypes
-DarchetypeArtifactId=netbeans-platform-app-archetype
-DarchetypeVersion=1.22
-DgroupId=com.mycompany
-DartifactId=mavenPlatformApp
-Dversion=1.0-SNAPSHOT
-Dpackage=com.mycompany
-DnetbeansVersion=RELEASE120-1
archetype:generate</code></pre>
</div>
</div>
<div class="paragraph">
<p>Here it is on a single line, so that you can easily copy/paste it:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn -DarchetypeGroupId=org.apache.netbeans.archetypes -DarchetypeArtifactId=netbeans-platform-app-archetype -DarchetypeVersion=1.22 -DgroupId=com.mycompany -DartifactId=mavenPlatformApp -Dversion=1.0-SNAPSHOT -Dpackage=com.mycompany -DnetbeansVersion=RELEASE120-1 archetype:generate</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="6">
<li>
<p>When prompted, enter Y, for "Yes".</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>You can see that the command specifies the archetype that Maven will use to create the NetBeans Platform application ( <a href="https://repo1.maven.org/maven2/org/apache/netbeans/archetypes/netbeans-platform-app-archetype/"> <code>netbeans-platform-app-archetype</code> </a>). The location of the repository for the archetype is ( <code><a href="https://repo1.maven.org/maven2/org/apache/netbeans/archetypes/" class="bare">https://repo1.maven.org/maven2/org/apache/netbeans/archetypes/</a></code> ) and the version ( <code>1.22</code> ) and GroupId ( <code>org.apache.netbeans.archetypes</code> ) of the archetype.</p>
</div>
<div class="paragraph">
<p>When you run the command, Maven will automatically retrieve the archetype and create the project according to the details specified in the command (artifact id, version, package).</p>
</div>
<div class="paragraph">
<p><strong>Note.</strong> When you use NetBeans IDE to create a Mavenized NetBeans Platform application, the IDE executes a Maven goal with the same parameters.</p>
</div>
<div class="paragraph">
<p>For more information about the plugin that is used to generate the artifacts, see the documentation on the <a href="http://bits.netbeans.org/mavenutilities/nbm-maven-plugin/">nbm-maven-plugin</a>.</p>
</div>
<div class="paragraph">
<p>When you run the command, you will see output similar to the following in the terminal window.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: artifactId, Value: mavenPlatformApp
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mycompany
[INFO] Parameter: packageInPathFormat, Value: com/mycompany
[INFO] Parameter: package, Value: com.mycompany
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: netbeansVersion, Value: RELEASE120-1
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: artifactId, Value: mavenPlatformApp
[INFO] project created from Archetype in dir: C:\apps\mavenPlatformApp
[INFO] -------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -------------------------------------------------------------------
[INFO] Total time: 12.396 s
[INFO] Finished at: 2020-06-16T19:23:32+02:00
[INFO] Final Memory: 16M/133M</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you look in the root directory <code>mavenPlatformApp</code> that was created, you can see that the new project contains a <code>pom.xml</code> file and a directory for each of the default sub-modules of the archetype: application and branding.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../../_images/tutorials/maven-commandline_80_p1.png" alt="maven commandline 80 p1">
</div>
<div class="title">Figure 1. Screenshot of structure of mavenPlatformApp</div>
</div>
<div class="paragraph">
<p>If you open <code>pom.xml</code> for mavenPlatformApp in an editor, you will see that the POM specifies all the details required for building the application:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;com.mycompany&lt;/groupId&gt;
&lt;artifactId&gt;mavenPlatformApp-parent&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;pom&lt;/packaging&gt;
&lt;name&gt;mavenPlatformApp-parent&lt;/name&gt;
&lt;repositories&gt;
&lt;!--
Repository hosting NetBeans modules, especially APIs.
Versions are based on IDE releases, e.g.: RELEASE691
To create your own repository, use: nbm:populate-repository
If you use Apache NetBeans starting with Apache NetBeans 9.0
you can remove the netbeans repository section
--&gt;
&lt;repository&gt;
&lt;id&gt;netbeans&lt;/id&gt;
&lt;name&gt;NetBeans&lt;/name&gt;
&lt;url&gt;http://bits.netbeans.org/nexus/content/groups/netbeans/&lt;/url&gt;
&lt;/repository&gt;
&lt;/repositories&gt;
&lt;build&gt;
&lt;pluginManagement&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.netbeans.utilities&lt;/groupId&gt;
&lt;artifactId&gt;nbm-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;4.3&lt;/version&gt;
&lt;extensions&gt;true&lt;/extensions&gt;
&lt;configuration&gt;
&lt;brandingToken&gt;${brandingToken}&lt;/brandingToken&gt;
&lt;cluster&gt;${brandingToken}&lt;/cluster&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;!-- NetBeans 6.9+ requires JDK 6, starting NetBeans 7.4 source 1.7 is required --&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
&lt;version&gt;3.8.1&lt;/version&gt;
&lt;configuration&gt;
&lt;source&gt;1.8&lt;/source&gt;
&lt;target&gt;1.8&lt;/target&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
&lt;version&gt;3.1.2&lt;/version&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/pluginManagement&gt;
&lt;/build&gt;
&lt;modules&gt;
&lt;module&gt;branding&lt;/module&gt;
&lt;module&gt;application&lt;/module&gt;
&lt;/modules&gt;
&lt;properties&gt;
&lt;netbeans.version&gt;RELEASE120-1&lt;/netbeans.version&gt;
&lt;brandingToken&gt;mavenplatformapp&lt;/brandingToken&gt;
&lt;/properties&gt;
&lt;/project&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you look at the <code>&lt;properties&gt;</code> element, you can see that the version of the NetBeans Platform is specified as <code>RELEASE120-1</code>. In the POM of your sub-modules, you can specify <code>${netbeans.version}</code> as the version and the module will use the version specified in the parent POM project. The enables you to easily update the NetBeans Platform version for all the project&#8217;s sub-modules.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_installing_and_running_the_netbeans_platform_application"><a class="anchor" href="#_installing_and_running_the_netbeans_platform_application"></a>Installing and Running the NetBeans Platform Application</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this exercise you will run the Maven <code>install</code> goal from the command line to build the application and copy the artifacts in your local repository. The NetBeans Platform application is a multi-module application. You will use the reactor mechanism in Maven to build the application project and the project&#8217;s dependencies. After you build the application you will execute the <code>run-platform</code> goal to launch the application.</p>
</div>
<div class="olist arabic">
<ol class="arabic" start="1">
<li>
<p>Navigate to the <code>mavenPlatformApp</code> directory and type the following command to build the project:</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn install</code></pre>
</div>
</div>
<div class="paragraph">
<p>The above command will take some time to complete. When the command completes, you will see the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for mavenPlatformApp-parent 1.0-SNAPSHOT:
[INFO]
[INFO] mavenPlatformApp-parent ............................ SUCCESS [ 0.500 s]
[INFO] mavenPlatformApp-branding .......................... SUCCESS [ 5.076 s]
[INFO] mavenPlatformApp-app ............................... SUCCESS [ 18.783 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.918 s
[INFO] Finished at: 2020-06-16T19:28:51+02:00
[INFO] ------------------------------------------------------------------------</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>After the command above completes, navigate to the <code>application</code> directory and type the following command to launch the application.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn nbm:run-platform</code></pre>
</div>
</div>
<div class="paragraph">
<p>When you run the <code>nbm-maven-plugin</code> with the <code>run-platform</code> goal, as done above, Maven will launch your NetBeans Platform application:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../../_images/tutorials/maven-commandline_72_p2.png" alt="maven commandline 72 p2">
</div>
<div class="title">Figure 2. Screenshot of default application</div>
</div>
<div class="paragraph">
<p>Browse through the menus to see what your new application consists of. Open some windows, undock some of them, and you will have something that looks like this:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../../_images/tutorials/maven-commandline_72_p3.png" alt="maven commandline 72 p3">
</div>
<div class="title">Figure 3. Screenshot of default application</div>
</div>
<div class="paragraph">
<p>You have now successfully created and launched your NetBeans Platform application. The default branding elements are located in the <code>branding</code> sub-module that was generated according to the archetype. The NetBeans IDE provides tools and wizards that can help you to modify the branding elements.</p>
</div>
<div class="paragraph">
<p>In the next section you will create a new module for the application.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_creating_a_netbeans_module_from_an_archetype"><a class="anchor" href="#_creating_a_netbeans_module_from_an_archetype"></a>Creating a NetBeans Module from an Archetype</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You will now create a new module that is named mavenPlatformModuleA in the <code>mavenPlatformApp</code> directory. In the same way that you created the NetBeans Platform application, you will run a Maven command from the command line and use the module archetype <code>nbm-archetype</code> .</p>
</div>
<div class="paragraph">
<p>After you create the module, you will use a text editor to create a simple class in the module. You will then build the module to install the module in the local repository.</p>
</div>
<div class="olist arabic">
<ol class="arabic" start="1">
<li>
<p>Navigate to the <code>mavenPlatformApp</code> directory in the command line terminal and run the following command:</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn
-DarchetypeGroupId=org.apache.netbeans.archetypes
-DarchetypeArtifactId=nbm-archetype
-DarchetypeVersion=1.17
archetype:generate</code></pre>
</div>
</div>
<div class="paragraph">
<p>Here it is on a single line:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn -DarchetypeGroupId=org.apache.netbeans.archetypes -DarchetypeArtifactId=nbm-archetype -DarchetypeVersion=1.17 archetype:generate</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>When prompted, enter the following values:</p>
<div class="ulist">
<ul>
<li>
<p>groupId: <code>com.mycompany</code></p>
</li>
<li>
<p>artifactId: <code>mavenPlatformModuleA</code></p>
</li>
<li>
<p>version: &lt;press Enter to accept the default&gt;</p>
</li>
<li>
<p>package: <code>com.mycompany.mavenplatformmodulea</code></p>
</li>
<li>
<p>netbeansVersion: <code>RELEASE110</code></p>
</li>
</ul>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>You can edit <code>netbeansVersion</code> later. You can see that the command specifies <code> <a href="https://repo1.maven.org/maven2/org/apache/netbeans/archetypes/nbm-archetype/">nbm-archetype</a></code> . The archetype will be retrieved from the remote repository.</p>
</div>
<div class="paragraph">
<p>When you run the command, you will see output similar to the following in the terminal window:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: nbm-archetype:1.17
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: artifactId, Value: mavenPlatformModuleA
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mycompany.mavenplatformmodulea
[INFO] Parameter: packageInPathFormat, Value: com/mycompany/mavenplatformmodulea
[INFO] Parameter: package, Value: com.mycompany.mavenplatformmodulea
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: netbeansVersion, Value: RELEASE110
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: artifactId, Value: mavenPlatformModuleA
[INFO] project created from Archetype in dir: C:\Users\Geertjan\demo\mavenPlatformApp\mavenPlatformModuleA
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for mavenPlatformApp-parent 1.0-SNAPSHOT:
[INFO]
[INFO] mavenPlatformApp-parent ............................ SUCCESS [01:09 min]
[INFO] mavenPlatformApp-branding .......................... SKIPPED
[INFO] mavenPlatformApp-app ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:11 min
[INFO] Finished at: 2020-06-16T19:39:56+02:00
[INFO] ------------------------------------------------------------------------</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you look at the contents of the <code>mavenPlatformApp</code> directory, you will see that the directory contains a new directory that is named <code>mavenPlatformModuleA</code> . The new directory contains a <code>src</code> directory and <code>pom.xml</code> . The file <code>bundle.properties</code> is generated in the <code>resources/com/mycompany/mavenplatformmodulea</code> directory:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../../_images/tutorials/maven-commandline_72_p4.png" alt="maven commandline 72 p4">
</div>
<div class="title">Figure 4. Screenshot of structure of mavenplatformmodulea</div>
</div>
<div class="paragraph">
<p>In the next step you will create a class in the <code>java/com/mycompany/mavenplatformmodulea</code> directory.</p>
</div>
<div class="olist arabic">
<ol class="arabic" start="3">
<li>
<p>Edit the new module&#8217;s <code>pom.xml</code> to make the following changes (add marked as <strong>1</strong>, update marked as <strong>2</strong>) to add a dependency on the modules you are referring to in the code above.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.netbeans.api&lt;/groupId&gt;
&lt;artifactId&gt;org-netbeans-api-annotations-common&lt;/artifactId&gt;
&lt;version&gt;RELEASE120-1&lt;/version&gt; <i class="conum" data-value="2"></i><b>(2)</b>
&lt;/dependency&gt;
&lt;dependency&gt; <i class="conum" data-value="1"></i><b>(1)</b>
&lt;groupId&gt;org.netbeans.api&lt;/groupId&gt;
&lt;artifactId&gt;org-openide-util&lt;/artifactId&gt;
&lt;version&gt;RELEASE120-1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt; <i class="conum" data-value="1"></i><b>(1)</b>
&lt;groupId&gt;org.netbeans.api&lt;/groupId&gt;
&lt;artifactId&gt;org-openide-awt&lt;/artifactId&gt;
&lt;version&gt;RELEASE120-1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt; <i class="conum" data-value="1"></i><b>(1)</b>
&lt;groupId&gt;org.netbeans.api&lt;/groupId&gt;
&lt;artifactId&gt;org-openide-dialogs&lt;/artifactId&gt;
&lt;version&gt;RELEASE120-1&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>added dependency</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>update platform version from RELEASE110 to RELEASE120-1</td>
</tr>
</table>
</div>
<div class="olist arabic">
<ol class="arabic" start="4">
<li>
<p>Use a text editor to create the following class <code>HelloWorldActionListener.java</code> in the <code>java/com/mycompany/mavenplatformmodulea</code> directory.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">package com.mycompany.mavenplatformmodulea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
@ActionID(category = "Window",
id = "com.mycompany.mavenproject2.HelloWorldActionListener")
@ActionRegistration(displayName = "#CTL_HelloWorldActionListener")
@ActionReference(path = "Menu/Window", position = 0)
@Messages("CTL_HelloWorldActionListener=Hello World")
public final class HelloWorldActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
NotifyDescriptor d = new NotifyDescriptor.Message("hello...");
DialogDisplayer.getDefault().notify(d);
}
}</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="5">
<li>
<p>On the command line, navigate to the <code>mavenPlatformModuleA</code> directory and run the following command to build and install the module in the local repository.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn install</code></pre>
</div>
</div>
<div class="paragraph">
<p>When you run the <code>install</code> command, Maven builds the module and copies the JAR and NBM artifacts to the local repository.</p>
</div>
<div class="paragraph">
<p>Now that the artifact is in the local repository, you can add the artifact as a dependency of the NetBeans Platform application, as shown in the next section.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_adding_the_new_netbeans_module_as_a_dependency"><a class="anchor" href="#_adding_the_new_netbeans_module_as_a_dependency"></a>Adding the New NetBeans Module as a Dependency</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this section you will add the module as a dependency of the NetBeans Platform application by declaring the dependency in the POM of the application project.</p>
</div>
<div class="olist arabic">
<ol class="arabic" start="1">
<li>
<p>Open the <code>pom.xml</code> file in the <code>application</code> directory in a text editor.</p>
</li>
</ol>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>Declare the mavenPlatformModuleA module as a dependency of the application by making the following changes (marked as <strong>1</strong>) to the POM.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.netbeans.cluster&lt;/groupId&gt;
&lt;artifactId&gt;platform&lt;/artifactId&gt;
&lt;version&gt;${netbeans.version}&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;
&lt;artifactId&gt;mavenPlatformApp-branding&lt;/artifactId&gt;
&lt;version&gt;${project.version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt; <i class="conum" data-value="1"></i><b>(1)</b>
&lt;groupId&gt;com.mycompany&lt;/groupId&gt;
&lt;artifactId&gt;mavenPlatformModuleA&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- NbModuleSuite functional in RELEASE70 or later: --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.netbeans.api&lt;/groupId&gt;
&lt;artifactId&gt;org-netbeans-modules-nbjunit&lt;/artifactId&gt;
&lt;version&gt;${netbeans.version}&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;!-- To use Jelly Tools in your functional tests, add or replace with:
&lt;dependency&gt;
&lt;groupId&gt;org.netbeans.api&lt;/groupId&gt;
&lt;artifactId&gt;org-netbeans-modules-jellytools-platform&lt;/artifactId&gt;
&lt;version&gt;${netbeans.version}&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
--&gt;
&lt;/dependencies&gt;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>added dependency to <code><code>mavenPlatformModuleA</code></code></td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_building_the_netbeans_platform_application_with_the_new_netbeans_module"><a class="anchor" href="#_building_the_netbeans_platform_application_with_the_new_netbeans_module"></a>Building the NetBeans Platform Application With the New NetBeans Module</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You are now almost ready to launch the NetBeans Platform application with the new module installed. You first need to make sure that the new module is specified as a module of the parent POM project. You can then repeat the steps to build and launch the application.</p>
</div>
<div class="olist arabic">
<ol class="arabic" start="1">
<li>
<p>Open the <code>pom.xml</code> in the <code>mavenPlatformApp</code> directory in a text editor.</p>
</li>
</ol>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>Confirm that the new module <code><code>mavenPlatformModuleA</code></code> is specified in the list of modules that are included with the application.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;modules&gt;
&lt;module&gt;branding&lt;/module&gt;
&lt;module&gt;application&lt;/module&gt;
&lt;module&gt;mavenPlatformModuleA&lt;/module&gt;
&lt;/modules&gt;</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="3">
<li>
<p>Navigate to the <code>mavenPlatformApp</code> directory in the command line terminal and type the following command to build the project.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn install</code></pre>
</div>
</div>
<div class="paragraph">
<p>When you run the command, you can see that the new module is included in the list of modules.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for mavenPlatformApp-parent 1.0-SNAPSHOT:
[INFO]
[INFO] mavenPlatformApp-parent ............................ SUCCESS [ 0.198 s]
[INFO] mavenPlatformApp-branding .......................... SUCCESS [ 2.490 s]
[INFO] mavenPlatformModuleA ............................... SUCCESS [ 1.281 s]
[INFO] mavenPlatformApp-app ............................... SUCCESS [ 5.488 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.668 s
[INFO] Finished at: 2020-06-16T19:51:02+02:00
[INFO] ------------------------------------------------------------------------</code></pre>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="4">
<li>
<p>Navigate to the <code>application</code> directory and type the following command to launch the application.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">mvn nbm:run-platform</code></pre>
</div>
</div>
<div class="paragraph">
<p>When you run the command, Maven will launch the application with the new module.</p>
</div>
<div class="paragraph">
<p>You have now successfully added a new module to the application and launched the application. To confirm that the module was loaded when the application launched, choose Window &gt; Hello World from the main menu of the application to display the greeting:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="../../_images/tutorials/maven-commandline_72_p5.png" alt="maven commandline 72 p5">
</div>
<div class="title">Figure 5. Screenshot of Message Dialog</div>
</div>
<div class="imageblock">
<div class="content">
<img src="../../_images/tutorials/maven-commandline_72_p6.png" alt="maven commandline 72 p6">
</div>
<div class="title">Figure 6. Screenshot of Message Dialog</div>
</div>
<div class="paragraph">
<p>This tutorial demonstrated how you can use the Maven command line to create NetBeans Platform applications. For more examples on how to build NetBeans Platform applications and modules, see the tutorials listed in the <a href="../../kb/docs/platform/" class="xref page">NetBeans Platform Learning Trail</a>.</p>
</div>
<div class="paragraph">
<p><a href="../../../../front/main/community/mailing-lists/" class="xref page">Send Us Your Feedback</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_see_also"><a class="anchor" href="#_see_also"></a>See Also</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This document described how to use the Maven build framework to create a new NetBeans Platform application without using NetBeans IDE. For more information about creating and developing applications, see the following resources.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="../nbm-maven-quickstart/" class="xref page">NetBeans Platform Quick Start Using Maven</a></p>
</li>
<li>
<p><a href="../../kb/docs/platform/" class="xref page">NetBeans Platform Learning Trail</a></p>
</li>
<li>
<p><a href="https://bits.netbeans.org/dev/javadoc/">NetBeans API Javadoc</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If you have any questions about the NetBeans Platform, feel free to write to the mailing list, <a href="mailto:dev@platform.netbeans.org">dev@platform.netbeans.org</a>, or view the <a href="https://mail-archives.apache.org/mod_mbox/netbeans-dev/">NetBeans Platform mailing list archive</a>.</p>
</div>
</div>
</div>
<section class='tools'>
<ul class="menu align-center">
<li><a title="Facebook" href="https://www.facebook.com/NetBeans"><i class="fa fa-md fa-facebook"></i></a></li>
<li><a title="Twitter" href="https://twitter.com/netbeans"><i class="fa fa-md fa-twitter"></i></a></li>
<li><a title="Github" href="https://github.com/apache/netbeans"><i class="fa fa-md fa-github"></i></a></li>
<li><a title="YouTube" href="https://www.youtube.com/user/netbeansvideos"><i class="fa fa-md fa-youtube"></i></a></li>
<li><a title="Atom Feed" href="https://netbeans.apache.org/blogs/atom"><i class="fa fa-mf fa-rss"></i></a></li>
<li><a title="Slack" href="https://tinyurl.com/netbeans-slack-signup/"><i class="fa fa-md fa-slack"></i></a></li>
<li><a title="Issues" href="https://github.com/apache/netbeans/issues"><i class="fa fa-mf fa-bug"></i></a></li>
</ul>
<ul class="menu align-center">
<li><a href="https://github.com/apache/netbeans-antora-tutorials/edit/main/modules/ROOT/pages/tutorials/nbm-maven-commandline.adoc" title="See this page in github"><i class="fa fa-md fa-edit"></i> See this page in GitHub.</a></li>
</ul>
</section>
</div>
<div class='grid-container incubator-area' style='margin-top: 64px'>
<div class='grid-x grid-padding-x'>
<div class='large-auto cell text-center'>
<a href="https://www.apache.org/">
<img style="height: 60px" title="Apache Software Foundation" src="../../../../_/images/asf_logo_wide.svg" />
</a>
</div>
<div class='large-auto cell text-center'>
<a href="https://www.apache.org/events/current-event.html">
<img style="width:234px; height: 60px;" title="Apache Software Foundation current event" src="https://www.apache.org/events/current-event-234x60.png"/>
</a>
</div>
</div>
</div>
<footer>
<div class="grid-container">
<div class="grid-x grid-padding-x">
<div class="large-auto cell">
<h1><a href="../../../../front/main/about">About</a></h1>
<ul>
<li><a href="../../../../front/main/community/who">Who's Who</a></li>
<li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li><a href="https://www.apache.org/security/">Security</a></li>
</ul>
</div>
<div class="large-auto cell">
<h1><a href="../../../../front/main/community">Community</a></h1>
<ul>
<li><a href="../../../../front/main/community/mailing-lists">Mailing lists</a></li>
<li><a href="../../../../front/main/community/committer">Becoming a committer</a></li>
<li><a href="../../../../front/main/community/events">NetBeans Events</a></li>
<li><a href="https://www.apache.org/events/current-event.html">Apache Events</a></li>
</ul>
</div>
<div class="large-auto cell">
<h1><a href="../../../../front/main/participate">Participate</a></h1>
<ul>
<li><a href="../../../../front/main/participate/submit-pr">Submitting Pull Requests</a></li>
<li><a href="../../../../front/main/participate/report-issue">Reporting Issues</a></li>
<li><a href="../../../../front/main/participate/#documentation">Improving the documentation</a></li>
</ul>
</div>
<div class="large-auto cell">
<h1><a href="../../../../front/main/help">Get Help</a></h1>
<ul>
<li><a href="../../../../front/main/help/#documentation">Documentation</a></li>
<li><a href="../../../../wiki/main/wiki">Wiki</a></li>
<li><a href="../../../../front/main/help/#support">Community Support</a></li>
<li><a href="../../../../front/main/help/commercial-support">Commercial Support</a></li>
</ul>
</div>
<div class="large-auto cell">
<h1><a href="../../../../front/main/download">Download</a></h1>
<ul>
<li><a href="../../../../front/main/download">Releases</a></li>
<li><a href="https://plugins.netbeans.apache.org/">Plugins</a></li>
<li><a href="../../../../front/main/download/#_daily_builds_and_building_from_source">Building from source</a></li>
<li><a href="../../../../front/main/download/#_older_releases">Previous releases</a></li>
</ul>
</div>
</div>
</div>
</footer>
<div class='footer-disclaimer'>
<div class="footer-disclaimer-content">
<p>Copyright &copy; 2017-2025 <a href="https://www.apache.org">The Apache Software Foundation</a>.</p>
<p>Licensed under the Apache <a href="https://www.apache.org/licenses/">license</a>, version 2.0</p>
<div style='max-width: 40em; margin: 0 auto'>
<p>Apache, Apache NetBeans, NetBeans, the Apache feather logo and the Apache NetBeans logo are trademarks of <a href="https://www.apache.org">The Apache Software Foundation</a>.</p>
<p>Oracle and Java are registered trademarks of Oracle and/or its affiliates.</p>
<p>The Apache NetBeans website conforms to the <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Apache Software Foundation Privacy Policy</a></p>
</div>
</div>
</div>
<script src="../../../../_/js/vendor/lunr.js"></script>
<script src="../../../../_/js/search-ui.js" id="search-ui-script" data-site-root-path="../../../.." data-snippet-length="100" data-stylesheet="../../../../_/css/search.css"></script>
<script async src="../../../../search-index.js"></script>
<script src="../../../../_/js/vendor/jquery.min.js"></script>
<script src="../../../../_/js/vendor/what-input.min.js"></script>
<script src="../../../../_/js/vendor/foundation.min.js"></script>
<script src="../../../../_/js/vendor/jquery.colorbox-min.js"></script>
<script src="../../../../_/js/netbeans.js"></script>
<script>
$(function(){ $(document).foundation(); });
</script>
<script src="../../../../_/js/vendor/highlight.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
});
});
</script>
</body>
</html>