问题描述
我有一个用 netbeans 开发的 Java 应用程序.我想创建一个重新编译项目的批处理文件,并将生成的 jar 文件与一些文档一起打包到一个 zip 文件中并生成一个安装程序.
I have a java application develeped in netbeans. I want to create a batchfile that recompiles the project and packs the resulting jar files along with some documentation to a zip file and generate an installer.
安装程序的打包和生成没有问题,但我不知道如何从命令行/批处理文件自动编译 - 每当我更改源代码中的某些内容时,我必须手动单击 netbeans 中的清理和构建"然后运行我的批处理文件.
The packing and generation of the installer is no problem, but I dont know how to automate the compilation from commandline/batchfile - whenever I change something in the source-code I have to manually click on "Clean and Build" inside netbeans and run my batchfile afterwards.
我必须在批处理文件中添加什么才能从 netbeans 内部执行与清理和构建"相同的操作?
What do I have to add to the batchfile to do the same as "Clean and Build" from inside netbeans?
推荐答案
我发现自己该做什么:
- 确保 ant 在您的路径中(例如,我将 C:\Programme\NetBeans 6.9.1\java\ant\bin 添加到我的 PATH 环境中)
- 确保您的 JAVA_HOME 设置正确
- 在您的 netbeans 项目目录中执行ant clean"和ant jar"
我使用的批处理文件:
SET JAVA_HOME=C:\Programme\Java\jdk1.6.0_12
call ant deps-clean
call ant clean
call ant jar
pause
cp -r doc dist
cp -r scripts dist
cp -r examples dist
cp -r crypt dist
cp -r db dist
cp -r license dist
rm dist/README.TXT
cp README.TXT dist
echo package creation %date:~-4,4%_%date:~-7,2%_%date:~0,2% >> dist/README.TXT
cd win_service
RCEDIT.exe /C wizard.exe
RCEDIT.exe /I wizard.exe my_app.ico
RCEDIT.exe /N wizard.exe pre_wizard.ini
RCEDIT.exe /C my_app_service.exe
RCEDIT.exe /I my_app_service.exe my_app.ico
RCEDIT.exe /N my_app_service.exe pre_my_app_service.ini
cp my_app_service.ini ../dist
cp my_app_service.exe ../dist
cp wizard.exe ../dist
cp wizard.ini ../dist
cp service*.bat ../dist
cp *.nsi ../dist
cp *.nsh ../dist
cp my_app.log ../dist
cd ..
cd dist
mkdir windows
cp *.jar windows
cp -r lib windows
cp -r crypt windows
cp -r db windows
cp examples\empty_settings.ini windows\settings_example.ini
mv *.exe windows
mv *.ini windows
mv *.bat windows
mv *.nsi windows
mv *.nsh windows
mv my_app.log windows
cd windows
my_app.nsi
mv my_appInstaller.exe ../my_appInstaller_gpl.exe
rm lib\jdbc-mysql.jar
my_app.nsi
mv my_appInstaller.exe ../my_appInstaller.exe
cd ..
rm -rf my_app
mkdir my_app
mv *.jar my_app
mv lib my_app
mv crypt my_app
mv db my_app
mv examples\empty_settings.ini my_app\settings.ini
ren my_app 9880
mkdir my_app
mv 9880 my_app
7z a -r -tzip my_app_gpl.zip doc license examples scripts my_app README.txt my_appInstaller_gpl.exe
rm my_app\9880\lib\jdbc-mysql.jar
7z a -r -tzip my_app.zip doc license examples scripts my_app README.txt my_appInstaller.exe
cd ..
pause
这篇关于如何从命令行重新编译 netbeans 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!