
Eclipse Gw Yang Indah
Jadi gini.. ehm…
Bangun tidur kok rasanya langsung pengen coding *bohong*
ok.. ini catetan gw hari ini, dapet ilmu baru dan gw catet daripada lupa
Nyampe kantor, buka fesbuk bentar, cuap2 ini itu, dan tergoda buka forum spring, disitu lagi iseng aja liat2, dan ada yang nanya gimana belajar spring dari awal, dan dikasih link nya ke sini :
http://static.springframework.org/docs/Spring-MVC-step-by-step/part1.html
hm.. hm..hm.. gw liat2 dan ew.. ada yang deploy aplikasi pake ant di bagian situ, dan gw belom pernah deploy bikin script di ant dan deploy pake ant, akhirnya pengen nyoba, gw buat aplikasi kecil aja sesuai dengan yang di contohkan di part 1 itu, dan mulai konsen ke konfigurasi ‘ant’ nya.
Gak ada klik kanan deploy undeploy, tapi untuk deploy, kita bikin script ant nya dulu.
Btw supaya script ini bisa berjalan, maka perlu dilakukan set up di environment variable di komputer yang kita gunakan, yaitu kita perlu set Variable (klik kanan di MyComputer->Properties->Advance->Environment Variable):
JAVA_HOME = [home direktori JDK]
ANT_HOME = [home direktori ant]
CATALINA_HOME = [home direktori app server tomcat]
Asumsi aplikasi atau project kita udah ada dengan nama project = “springproject”, dan tinggal bikin konfigurasi ant nya saja :
<?xml version="1.0" encoding="UTF-8"?>
<project name="springproject" basedir="." default="usage">
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="springproject"/>
<property name="test.dir" value="test"/>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="buildtest" depends="build" description="build test application">
<junit printsummary="on"
fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Tests.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed} njrid!!
</fail>
</target>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build The Application"/>
<echo message="deploy --> Deploy Application As Directory"/>
<echo message="deploywar --> Deploy application as a war file"/>
<echo message="install --> Install application in tomcat"/>
<echo message="reload --> reload application in tomcat"/>
<echo message="start --> start application in tomcat"/>
<echo message="stop --> stop application in tomcat"/>
<echo message="list --> list tomcat application"/>
<echo message=""/>
</target>
<target name="build" description="compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build" description="deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="deploy application as a war file">
<war destfile="${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<!-- End Tomcat tasks -->
</project>
gw gak copy paste doank, yang konfigurasi tomcatnya itu copy paste kok
, dan gw butuh waktu kurang lebih 30 menit sampai satu jam untuk memahami alur2 di code itu, itupun gw nanya2 sama si arap, cuz memang ada beberapa error waktu di build
Di atas di setting classpath nya, trus fungsi2 deploy, build, dll dalam satu script yaitu build.xml, gw taruh build.xml ini di : springproject/build.xml
Gak perlu di jelaskan syntax2nya, cuz code2 itu sangat readable menurut gw, hehehehe..
Kemudian munculkan tab ant di eclipse, dengan cara window->show view->ant
Dan script ant yang barusan gw bikin gw tambahkan ke tab ant tersebut, kalo udah, di klik 2x aja dan otomatis terbuild, dan bisa di expand di file build.xml tersebut yang udah ada di tab ant, dan akan muncul fungsi2 yang kita bikin tadi, ada deploy, build, deploywar, dll.
hohoho.. jangan lupa bikin file “build.properties” bro, karena file ini penting untuk konfigurasi ke appserver yang kita gunakan (dalam hal ini adalah tomcat) berikut isi dari file : build.properties
#Ant Properties to build springproject
appserver.home=C:/Program Files/Apache Software Foundation/Tomcat 6.0
#for Tomcat 5 use $appserver.home}/server/lib
#for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/lib
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=admin
tomcat.manager.password=
username dan password dari tomcat menyesuaikan, yang digunakan saat penulisan blog ini adalah konfigurasi default.
ok, cukup sekian perolehan hari ini.
lanjut ntar kalo ada penemuan baru






iki mbahas opo tho..???
@escoret alias om pepeng
iyo ki mas, mboh aku yo rak reti nulis opo, mung urek2an tok
=))
hahahahaha
hasilnya kok gak ditampilin Boss….
tapi keren juga… semangatnya….
lha itu hasilnya gan yang ada gambarnya..
hahahaha..
thx udah mampir, salam kenal