分類
eclipse plugins

使用 Command Line 執行 Eclipse Format

避免違反 code standard,在 git push 之前,我一定小心翼翼的檢查每個要 push 的 java code 是否有執行 format(為了去除討厭的空白)。
但 eclipse ide 沒辦法針對多數檔案一併執行 format 動作,但改成command line來執行 format 動作就沒這個問題。
 
幾個步驟:
1.準備 eclipse 可執行檔,這個可執行檔就是你每天在寫程式開的eclipse 執行檔。
2.準備 org.eclipse.jdt.core.prefs 檔案,這個檔案紀錄你設定的format格式,檔案位置在專案根目錄下的 .settings/ 。
3.使用以下指令啟動

/path/of/eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config /path/of/org.eclipse.jdt.core.prefs /path/of/file/you/want/to/format

Note:
/path/of/eclipse :eclipse 可執行檔路徑
/path/of/org.eclipse.jdt.core.prefs:org.eclipse.jdt.core.prefs 檔案路徑
/path/of/file/you/want/to/format:想要format 的檔案路徑,你可以指定檔案所在資料夾,formatter會幫你一併format 所有的檔案。
 
執行輸出

Configuration Name: /path/of/org.eclipse.jdt.core.prefs
Starting format job ...
Formatting: /path/of/file/you/want/to/format
Done.

 
 
 
 

分類
eclipse plugins

安裝並使用 ObjectAid

ObjectAid 可以讓 code 產生對應的 uml。對於理解 Software Architecture 有相當程度的幫助。
 
1. Install ObjectAid
open eclipse(Kepler) -> Help -> install new software -> add -> type name : ObjectAid ,
type Location : http://www.objectaid.com/update ->  press next
 
2. Run ObjectAid
open eclipse(Kepler) -> select StarNetXMPPTransportBundle -> create ObjectAid UML Diagram ->
drag class from package explorer to objectAid UML Diagram
 

分類
eclipse plugins

安裝並使用 AceJump

AceJump 可以幫助在eclipse Editor 中快速移動,使用這個插件基本上不再需要滑鼠移動了。
 
1.安裝AceJump
open eclipse(Kepler) -> Help -> install new software -> add -> type name : AceJump ,
type Location : http://tobiasmelcher.github.io/acejumpeclipse/ -> press next
 
2.Run AceJump
open eclipse(Kepler) -> press “ctrl + ,” in Editor -> type which char your want to move in Editor ->
type hint char
 
3. config AceJump HotKey
Window -> Preferences -> General -> Key -> find AceJump

分類
eclipse plugins

安裝並使用 EclEmma 計算測試覆蓋率

1.Install EclEmma
open eclipse(Kepler) -> Help -> install new software -> add -> type name : EclEmma,
type Location : http://update.eclemma.org/ ->  press next
 
2.Run EclEmma
open eclipse(Kepler) -> right click project on Package Explorer -> Coverages As -> JUit Test
 
3.view unit test coverage
open eclipse(Kepler) -> open coverage view

分類
eclipse plugins

安裝Metrics plugin on eclipse(Kepler)

1. Install Metrics:

open eclipse(Kepler) -> Help -> install new software -> add -> type name : Metrics ,
type Location : http://metrics.sourceforge.net/update -> select metrics and press next
 

2. How to use Metrics

in eclipse Package explorer -> right click project -> Properties -> Metrics -> click Enable Metrics -> Apply -> Ok
 

分類
eclipse plugins

安裝PMD plugin on eclipse(Kepler)

1. Install PMD:

open eclipse(Kepler) -> Help -> install new software -> add -> type name : PMD ,
type Location : http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/ -> select PMD for eclipse 4 and press next

分類
eclipse plugins

CheckStyle error : Unable to instantiate RedundantThrows

Description:

Run “check code with checkstyle” and show follow message

cannot initialize module TreeWalker - Unable to instantiate 'RedundantThrows' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotation.RedundantThrows,
...

 

Solution:

edit checkstyle config xml and comment follow tag

...
<!--<module name="RedundantThrows">
      <property name="suppressLoadErrors" value="true"/>
</module>-->
...

 
 

分類
eclipse plugins

安裝並設定CheckStyle plugin on eclipse(Kepler)

1. Install CheckStyle:

open eclipse(Kepler) -> Help -> install new software -> add -> type name : CheckStyle ,
type Location : http://eclipse-cs.sourceforge.net/update -> select checkstyle and press next
 

2. Config CheckStyle(option)

open eclipse -> Window -> preferences -> checkstyle -> config checkstyle settings
 

3. Create customize checkstyle rule(option)

open eclipse -> Window -> preferences -> checkstyle -> copy default rule
-> adjust rule for customize config file