Wednesday, October 12, 2011

Maven Hectic Work...

I am developing web applications using maven... As a developer cleaning,building, stoping tomcat, placing war file, starting tomcat and opening browser takes 50% time in  a day.. Mostly coding wont take that much time. Each time ill make change i have to build,copy etc...

I love developing But these kind of hectic work make me feel lazy...

Hurray.. !!!

I found a solution for this... BATCH file..

I created a batch file which does all my work.. i am free.. What i have to do is .. Type coding Run the batch file and see the changes.. Sounds nice..

My code is...


@ECHO off
cls
:start
ECHO.
ECHO 1. Install
ProjName1
ECHO 2. Buid ProjName2
ECHO 3. Buid ProjName3
ECHO 4. Delete Files In Tomcat
ECHO 5. Copy Files To tomcat
ECHO 6. Start tomcat
ECHO 7. Stop tomcat
ECHO 8. Run
ProjName
ECHO 9. Exit
set /p choice=Type your choice.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto
ProjName1
if '%choice%'=='2' goto ProjName2
if '%choice%'=='3' goto ProjName3
if '%choice%'=='4' goto delete
if '%choice%'=='5' goto copy
if '%choice%'=='6' goto runtomcat
if '%choice%'=='7' goto stoptomcat
if '%choice%'=='8' goto Run
if '%choice%'=='9' goto end
ECHO "%choice%" is not valid please try again
ECHO.
goto start


:
ProjName1
ECHO Going to Build and Install ProjName
ECHO Please Wait..............
CD /D D:\
ProjName\trunk\ProjName
call mvn clean install

ECHO Shall i proceed ???
PAUSE

goto start


:
ProjName2
ECHO Going to Build ProjName
ECHO Please Wait..............
CD /D D:\
ProjName\trunk\ProjName
call mvn clean package

ECHO Shall i proceed ???
PAUSE

goto start


:
ProjName3
ECHO Going to Build ProjName
ECHO Please Wait..............
CD /D D:\
ProjName\trunk\server\ProjName
call mvn clean package

ECHO Shall i proceed ???
PAUSE


goto start

:delete

ECHO Going to Delete Existing files in tomcat
ECHO Please Wait..............

DEL C:\apache-tomcat-7.0.14\apache-tomcat-7.0.14\webapps\*.war
rmdir /s /q "C:\apache-tomcat-7.0.14\apache-tomcat-7.0.14\webapps\
ProjName"
rmdir /s /q "C:\apache-tomcat-7.0.14\apache-tomcat-7.0.14\webapps\
ProjName"
goto start

:copy
ECHO Going to Copy war files to tomcat
xcopy /s D:\ProjName\trunk\server\engine\target\ProjName.war C:\apache-tomcat-7.0.14\webapps
xcopy /s D:\
ProjName\trunk\framework\target\ProjName.war C:\apache-tomcat-7.0.14\webapps
goto start

:runtomcat

ECHO Going to start tomcat
call "C:\apache-tomcat-7.0.14\bin\startup.bat"
goto start

:stoptomcat

ECHO Going to stop tomcat
call "C:\apache-tomcat-7.0.14\bin\shutdown.bat"
goto start


:run

ECHO Going to open firefox browser with URL
start /d "C:\Program Files\Mozilla Firefox" firefox.exe http://localhost:8080/ProjName
goto end

:end
pause
exit


Happy Coding :)

No comments:

Post a Comment