Netbeans will create the Ant script for you, it uses Ant to build anyway. But if you want to get the war file, just build your project. The .war file will be located in /yournetbeanshomedirectory/yourproject/dist/yourwar.war
You can check out the ant build script it uses by looking at the build.xml file in your project directory. Might help you feel a little more comfortable using ant to do builds.
It is in the dist folder inside of the project, but only if "Compress WAR File" in the project settings dialog ( build / packaging) ist checked. Before I checked this checkbox there was no dist folder.
This worked for me:
1.Right click pom.xml
2.Run Maven > Goals
3.Edit maven goals
Results: war build in /target folder
Packaging webapp
Assembling webapp [WeatherDashboard] in [C:\Users\julian.mojico\Documents\NetBeansProjects\WeatherDashboard\target\WeatherDashboard-1.0-SNAPSHOT]
Processing war project
Webapp assembled in [672 msecs]
Building war: C:\Users\julian.mojico\Documents\NetBeansProjects\WeatherDashboard\target\WeatherDashboard-1.0-SNAPSHOT.war
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 1:41.633s
Finished at: Tue Sep 05 09:41:27 ART 2017
Final Memory: 18M/97M
------------------------------------------------------------------------
As DPA says, the easiest way to generate a war file of your project is through the IDE. Open the Files tab from your left hand panel, right click on the build.xml file and tell it what type of ant target you want to run.
Just check in you projects properties >build ->packaging WAR file compress.
I had to right-click the build.xml file and choose "run". Only then would the .war file be created.
Simplest way is to Check the Output - Build tab: It would display the location of war file.
It will have something like:
Installing D:\Project\target\Tool.war to C:\Users\myname.m2\repository\com\tool\1.0\Tool-1.0.war
If NetBeans haven't created your dist
folder, execute the do-dist
ant target:
In commandline navigate to the directory of your project, the one containing a build.xml file
> ant do-dist
If ant runs fine (most likely), your dist
folder will be created, containing the .war
file.
Right click your project, hit "Clean and Build". Netbeans does the rest.
under the dist directory of your app, you should find a pretty looking .war all ready for deployment.
Source: Stackoverflow.com