简体   繁体   中英

How to package sources in a jar in Netbeans for maven projects?

When building maven projects (Java) in Netbeans, by default, sources are left out. How to package sources in a jar in Netbeans for maven projects?

Something like:

myproject.jar
myproject-sources.jar

You can do it in two ways.


First way - Project Properties

  1. Right click on the project > Properties
  2. Go to > Actions
  3. Either add a custom one (click Add custom... ) for a separate action or add it to an existing one (eg Build with dependencies) by selecting it.
  4. In the Execute Goals menu, add source:jar

项目属性>动作

Second way - Custom Goals

  1. Right click on the project > Custom > Goals
  2. In Goals: type source:jar
  3. To make this permanent, select the checkbox Remember as and give it a name.
  4. Run it: Right click on the project > Custom > the name you selected

自定义目标

运行自定义目标

Note: For both ways, when you type source, Netbeans suggest many options, try them for other cool options!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM