ãã¡ã¤ã«ãããããã¾ããã®ã¯Groovyã®ã»ãã便å©ã
æè¿ä»äºã§ã¬ã¬ã·ã¼ã³ã¼ãã®ãå®ãããã¦ããã ãã©ï¼ã¬ã¬ã·ã¼è¨ãã ããã£ã¦å¤§äºãªäºãã³ã¼ããè¨å®ãã¡ã¤ã«ã«ããæ®ããã¦ãªãã¦ï¼çµæ§æ¶ç®ãªæãããã¦ããã©ãã«ã人ãèªããããã«è¨å®ãã¡ã¤ã«ãå¯è¦åãããã¨æãï¼Groovyã§ã¡ããã¡ããå¼ã£ã¦ã¿ããã
Groovyã®ãã¡ã¤ã«æä½ã¯å¼·åãªã®ã ããã©ï¼ãã°ãã使ããªãã¨ãã£ã¨ããéã«æ§æãå¿ããã®ã§ï¼ããã«æ®ãã¦ããã
ãã³ãã¯ä»ã«ããããããã£ã¦ããã©ï¼ãã¡ã¤ã«ããã£ããèªã¿è¾¼ãã®ã¨æ¸ãåºãã³ã¼ããè¨ããä¾ç¤ºããã®ã¯ï¼ç¹å®ã®ãã£ã¬ã¯ããªåã«ããããããã£ãã¡ã¤ã«ãä¸æ¬ã§èªã¿è¾¼ãã®ã¨ï¼ã³ã¬ã¯ã·ã§ã³ãèµ°æ»ãã¦ã£ã¦ï¼è¦ç´ ãã¨ã«ãã¡ã¤ã«ãæ¸ãåºãã£ã¦ã®ã
ã³ã¼ããç»åã ããªã®ãã¢ã¬ãªã®ã§ï¼ãã£ã¡ã«è²¼ãç´ãã¦ãããã
class GroovyTest extends GroovyTestCase { def M = [:] void setUp() { new File("./master").eachFileMatch(~/.*properties/) { f -> def prop = new Properties() prop.load f.newInputStream() M[f.name.replaceAll(~/.properties$/, "")] = prop } } void testHogeHoge() { [ "aaa", "bbb", "ccc" ].each { item -> new File("./report/${item}.html").withPrintWriter { w -> w.println """ <h1>${item} - ${M.foo[item]}</h1> : """ } } } }
LLç±æ¥ã®æ¹ã
ã«ã¯ãã ãããªãã ï¼ãçãªå
容ã ã¨æããï¼Javaç±æ¥ã®äººããè¦ã¦ãããããããé¢åèããã»ã©ã§ããªããããã¨ãæãããã©ï¼ããã¯ããï¼ãã£ã±ããã®æ軽ãã¯ä¾¿å©ã ãã
極ãã¤ãã¯ï¼Javaãå¼ã³åºãããã¨ããã¡ã¤ã«åºåä¾ã§ã¯å ´å½ããçãªã³ã¬ã¯ã·ã§ã³ä½¿ã£ã¦ããã©ï¼å®éã«ã¯ã¬ã¬ã·ã¼ã³ã¼ãï¼ãã¡ãã£ã¨ãããã£ã¦ï¼ã«è¨å®ãã¡ã¤ã«ããã¼ã¹ãã¦å¾ãã³ã¬ã¯ã·ã§ã³ã使ã£ã¦ããã
ãã ï¼ãã®ãJavaã¨æ··ãããã£ã¦ã®ã¯IntelliJ使ã£ã¦ããããããã£ã¦æ°ãããã®ã§ï¼[IDEA]ã¿ã°ãä»ãã¦ããEclipseãNetBeansã®Groovyãã©ã°ã¤ã³ãã©ããã¯ç¥ãããã©ï¼AntãMavenã§Javaã«Groovyæ··ããã®ã¯ï¼ã¡ããã¨ããæéã ï¼ã¨æãï¼ãã§ãIntelliJã®å ´åï¼æéã©ãããä½ãèããã«Java+Groovyæ··å¨ç°å¢ãä½ãã¡ããã®ã§ï¼ãã¡ãã£ã¨ãããã¨ã¯Groovyã§ãã£ã¦ã®ããããæµæããªããããã¼ç°¡åã
ããããã¾ã§ï¼IntelliJ以å¤ã§åããäºå
¨ç¶èãã¦ãªããã©ãã
ï¼ä»ãã¨ãï¼èªå以å¤ã®äººã使ãäºç¡ãããæ°ã«ãã¦ãªããã©ã:-P
ã¡ãªã¿ã«ï¼å ã®ä¾ã§ã¯HTMLãåºåãã¦ããã©ï¼å®éã«ã¯æ¡å¼µåã".html.xls"ã«ãã¦HTMLãã¼ãã«ãExcelã«éããã¦ãããã¨ã¯ï¼ã¡ããã£ã¨æä½æ¥ã§å å·¥ãã¦ã¹ã¼ã好ã¿ã®å¸³ç¥¨ã«ãããããã¾ãã
ps.
ã¬ã¬ã·ã¼ã³ã¼ãã®è§£æãï¼Excelæ¹ç¼ãªï¼ããã¥ã¡ã³ãã¼ã·ã§ã³ãï¼å·¥å¤«æ¬¡ç¬¬ã§çµæ§æ¥½ããã:-)