i'm using netbeans for writing a webapp + filter.
I want to generate a jar file (to place in tomcat/lib folder) for the sake of the filter.
when i compile the project, it generates war file.
is there a way to tell netbeans to generate a jar file instead?
You can add something like this to your build.xml:
<target name="-post-compile">
<jar destfile="${basedir}/dist/my_web_app.jar">
<fileset dir="${basedir}/build/web/WEB-INF/classes">
</fileset>
</jar>
</target>
Which will build you a jar alongside your war.
EDIT: See Ravindra's answer below for a slight improvement to this method.
An enhancement to @DeadPassive answer - You can get the web app name using the variable ${ant.project.name}
<target name="-post-compile">
<jar destfile="${basedir}/dist/${ant.project.name}.jar">
<fileset dir="${basedir}/build/web/WEB-INF/classes">
</fileset>
</jar>
</target>
也许修改netbeans使用的build.xml,在生成的jar上添加复制任务。
Create a separate project to generate your .jar file. In that case also I think you have to create the .jar using terminal. You can't create a .jar file for a web project using netbeans IDE, as far as I know.
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.