봉 블로그

Cypal Studio 를 사용한 GWT 개발환경구축 본문

개발환경/Eclipse

Cypal Studio 를 사용한 GWT 개발환경구축

idkbj 2009. 8. 12. 16:15
Cypal Studio Eclipse Plugin을 사용한 GWT 개발환경 구축

Eclipse 3.4.* (JEE Developers 용), GWT 1.5.3 기준

참고 :
http://www.cypal.in/studiodocs

Requirements

GWT를 위한 Cypal Studio 는 JEE Developers 용 Eclipse IDE를 필요로한다 . 먼저 Eclipse를 설치하고 Google Web Toolkit을 download 후 압축해제한다.


Installation

Cypal Studio를 다운로드 후 <Eclipse home>/dropins/Cypal/plugins 폴더에 압축을 해제한다. Eclipse를 실행하고 Window->Preferences->Cypal Studio 에서 GWT home 에 Google Web Toolkit 설치 폴더를 설정하면 끝.

이제 프로젝트 생성후 코딩만 하면 된다.


http://www.cypal.in/Preferences.png/Preferences-full;init:.png

GWT 프로젝트 생성

먼저 Dynamic Web Project 선택후, 아래 그림처럼 Configuration 을 Cypal Studio for GWT로 설정하는것이 중요.
Target Runtime은 필요없음 None으로 설정.(안그러면 컴파일 안됨) 
Dynamic Web Module version은 2.4으로 설정. (그외 버전에서는 Cypal Studio for GWT 이 안됨)
참고로 기존에 Dynamic Web Project를 GWT 프로젝트로 변경하는 부분은 해당 사이트 문서대로안됨. 신규로 만드는게 좋음.


GWT 샘플예제 돌려보기 (Playing with GWT Samples)

 File->New->Examples->GWT->GWT Samples. 을 선택하면 아래 화면이 나타난다.
여러가지 샘플과 실행할 프로젝트를 선택할수 있다. 화면과 같이 설정후 Finish를 누르면 별도의 샘플소스가 임포트된다.

샘플을 실행해보고 싶다면 아래 "Running/Debugging a GWT Application(Host mode)" 을 참고하시 바란다.

모듈 생성하기

메뉴 File->New->Other->Cypal Studio-> Module 를 통해서 신규 모듈을 추가할수 있다. 패키지와 모듈명을 입력후 Finish를 클릭하면 모듈과 관련된 파일들이 자동으로 생성된다.

주의: The theme selection should be done only if you are using GWT 1.5 or later) If you are using GWT 1.4 or earlier, please unselect all the themes.

http://www.cypal.in/NewCypalStudioModule1.5.png/NewCypalStudioModule1.5-full;init:.png

Running/Debugging a GWT Application (Host mode)

Gwt Application을 Host mode에서 실행 또는 디버깅하는 방법은 2가지가 있다. 먼저 아래와 같이
메뉴 Run -> Run Configurations 창이나 Run -> Debug Configurations 창을 이용하거나
http://www.cypal.in/RunningaGWTApp1.png/RunningaGWTApp1-full;init:.png

 다음과 같이 모듈파일(*.gwt.xml) 컨텍스트 메뉴에서  Run As -> GWT Hosted Mode Application로 실행할수 있다.

http://www.cypal.in/RunningaGWTApp2.png/RunningaGWTApp2-full;init:.png

Invoking GWT Compiler

GWT를 Host mode 가 아닌 서버모드에서 실행하려면 자바소스를 자바스크립트로 컴파일해서 was를 통해 실행해야
한다.

GWT Compiler 는  Clean build (Project->Clean) 를 통해 자동으로 실행되어 컴파일 작업을 수행한다.The files generated by GWT Compiler 는 기본적으로 <Project root>/build/gwtOutput 위치에 컴파일된 파일들을 위치시킨다. 이 컴파일 위치는 Window->Preferences->Cypal Studio 에서 수정할수 있다. <Project root>/WebContent로 설정하면 적당할듯...


Adding a Remote Service

You can select File->New->Other->Cypal Studio -> Remote Service. Select the module to which you want to add the RemoteService. Type the name and uri for the service and click Finish. Now the artifacts for the remote service will be generated. Entries will be added to web.xml and gwt.xml 

http://www.cypal.in/CreatingRPC.png/CreatingRPC-full;init:.png

Adding a Remote Service method

You can open the RemoteService interface and add/change/delete methods in it. You need to provide the implementation of those methods in RemoteServiceImpl class. But thanks to Cypal Studio for GWT, you don't have to do anything in RemoteServiceAsync. Cypal Studio for GWT will automatically update the corresponding Async file whenever a RemoteService interface is changed.

Calling a method using Remote Service

The utility class in the Remote service should help you in making the remote call.

MyRemoteServiceAsync async = MyRemoteService.Util.getInstance(); async.makeRemoteCall(param1, param2, callback);

Deploying to external servers

You can add the project to any external server (JBoss, Weblogic, Websphere, ...) configured in the Server's view, just as the way you used to deploy a normal Dynamic Web Application. Cypal Studio for GWT will take care of calling the GWT compiler whenever you are doing a publish on that server. 

http://www.cypal.in/ExternalServer.png/ExternalServer-full;init:.png

Creating a WAR file

Select File->Export->Export as war. The WAR will be created with the files that are generated by the GWT compiler in the location <Project root>/build/gwtOutput (or a location specified by you in the Preference Page)

You have to do a clean build on the Project before exporting as WAR file. Project->Clean and select the project for which you want to create the WAR file.

http://www.cypal.in/ExportWAR.png/ExportWAR-full;init:.png

You can do the same through in the command line by running the following command

java -jar org.eclipse.equinox.launcher_<version>.jar -application in.cypal.studio.gwt.core.ExportWar -data <workspace> -project <project name> -dest <destination file>

Upgrading from GWT 1.4 to GWT 1.5

Starting from 1.5 version, GWT Compiler supports Java 1.5. So you can make use of all the language features like annotation, generics, auto boxing, in your client code. To take advantage of these features, right click your Project->Properties->Project Facets->Modify Project. In that dialog, change Java from 1.4 to 5.0 and Cypals GWT Facet from 1.0 to 1.5

(You would need RC 6 or later version of Cypal Studio for GWT) 

Installing & Using with Ganymede (Eclipse 3.4) 

Ganymede's P2 has changed the way plugins are installed. If you are using Ganymede, do not unzip the files into the plugins directory. Rather unzip the plugin jars into <Eclipse home>/dropins/Cypal/plugins You have to manually create the Cypal and plugins directories.