Gradleã£ã¦ãªã«ï¼
ç°¡åã«è¨ãã°Maven2ã®ãããªãã®ã§ããã
ãããããæ§ã
ãªæ©è½ããã©ã°ã¤ã³ã¨ãã¦ç¨æããã¦ãããã«ããã¼ã«ã§ãã
åæã«é¸ãã 主ãªç¹å¾´ã®ããã3ã¯âã
- è¨å®ãã¡ã¤ã«ãXMLã§ã¯ãªããGroovyã«ããDSLã§æ¸ã(build.gradleãã¡ã¤ã«)
- Groovyã³ã¼ããå«ãããã¸ã§ã¯ãã®è¨å®ãé常ã«ç°¡å
- Maven2ã®ãã£ã¬ã¯ããªæ§æãè¸è¥²ãã¦ããã®ã§ãMaven2ã¨ã®åå± ãå¯è½
ã¨ãã£ãæãã§ãã¨ãããããã£ããã¨æµãã¦ããã¾ã
å ¥æã»ã¤ã³ã¹ãã¼ã«ãªã©
âãã¦ã³ãã¼ãã¯ãã¡ãããã©ããã
å±éãããã£ã¬ã¯ããªãGRADLE_HOMEç°å¢å¤æ°ã«æå®ãã¦ãPATHã«$GRADLE_HOME/binéãã ãã®ãããããã¤ã³ã¹ãã¼ã«æ¹æ³ã§ãã
$ gradle --version ------------------------------------------------------------ Gradle 0.9-20091103023134+0900 ------------------------------------------------------------ Gradle buildtime: 2009å¹´11æ3æ¥ 2æ31å34ç§ JST Groovy: 1.6.4 Ant: Apache Ant version 1.7.0 compiled on December 13 2006 Ivy: 2.1.0-rc2 Java: 1.6.0_15 JVM: 14.1-b02-90 JVM Vendor: Apple Inc. OS Name: Mac OS X
ãªã©ã¨è¡¨ç¤ºãããã°OK.
ã¿ã¹ã¯ã®å®è¡ã®ä»æ¹
$ gradle -t
ã¨ããã°ãç¾å¨å®è¡å¯è½ãªã¿ã¹ã¯ã表示ããã¾ãã
ä¾ãã°:cleanã¨ã:testã®ãããªãã©ã¼ãããã§è¡¨ç¤ºããã¾ããããããã
$ gradle clean $ gradle test
ã®ããã«å®è¡ã§ãã¾ããã³ãã³ã¯ããã¾ããã
ãã¡ãããMavenãªã©ã¨åããä¸åº¦ã«è¤æ°ã®ã¿ã¹ã¯ãæå®ã§ãã¾ãã
$ gradle clean test
Groovyããã¸ã§ã¯ãã®åºæ¬æ§æ
ãã£ã¬ã¯ããªã¯Mavenã¨åãè¦ç´ã«å¾ãã¾ãã
ããªãã¡ããããªæãã
APP_PROJECT_ROOT |-- build.gradle âè¨å®ãã¡ã¤ã« |-- build/ âGradleãçæããå種ãã¡ã¤ã« `-- src |-- main âãããã¯ãç¨ | |-- groovy/ â*.groovyãã¡ã¤ã«ãæ ¼ç´ (*.javaãæ··å¨ããããã¨ãå¯è½) | |-- java/ â*.javaãã¡ã¤ã«ãæ ¼ç´ | `-- resources/ âãªã½ã¼ã¹ãã¡ã¤ã«ãæ ¼ç´ `-- test âãã¹ãç¨ |-- groovy/ â*.groovyãã¡ã¤ã«ãæ ¼ç´ (*.javaãæ··å¨ããããã¨ãå¯è½) |-- java/ â*.javaãã¡ã¤ã«ãæ ¼ç´ `-- resources/ âãªã½ã¼ã¹ãã¡ã¤ã«ãæ ¼ç´
Groovyããã¸ã§ã¯ãã®è¨å®ãã¡ã¤ã«ã®ãµã³ãã«
以ä¸ã®å 容ã®build.gradleãã¡ã¤ã«ãããã¸ã§ã¯ãã«ã¼ããã£ã¬ã¯ããªã«ç½®ãã¦ããã°OK.
groovyã®ãã¼ã¸ã§ã³ã¯ã好ããªãã¼ã¸ã§ã³ã§ã
usePlugin 'groovy' repositories { mavenCentral() } dependencies { groovy group:'org.codehaus.groovy', name:'groovy', version:'1.7-beta-2' testCompile group: 'junit', name: 'junit', version: '4.7' // Javaã®ãã¹ãã³ã¼ããæ¸ãå ´åã¯å¿ è¦ }
dependenciesã«è¨è¼ããã©ã¤ãã©ãªã¯ãIvyã使ã£ã¦èªåçã«åå¾ãã¾ãã
ãã¡ãããMavenãªãã¸ããªä¸ã®ã©ã¤ãã©ãªãåå¾ã§ãã¾ãã
GroovyTestCaseãç¶æ¿ãã¦ãã¹ããæ¸ãã ãã§ããã°ãGroovyã®ä¸ã«å¿
è¦ãªJUnitã®ã©ã¤ãã©ãªä¸å¼ãå«ã¾ããã®ã§ãä¾åã©ã¤ãã©ãªã®junitã¯ä¸è¦ã§ããgroovyã ãã§Ok.
src/test/javaã«ãã¹ãã³ã¼ããæ¸ãã¤ãããªããä¸è¨ã®ããã«junitãå¿
è¦ã§ãã
ãã¦ãä¸è¨ã®è¨å®ã§ãgradle testãå®è¡ããã¨ãsrc/test/groovy, src/test/javaã®ãã¹ã¦ã®ãã¹ããå®è¡ãã¦ããã¾ããç´ æµã§ãã
ãã£ã¨è©³ãã
å²ã¨åãå ¥ã£ã¦ãããã¥ã¡ã³ããããã®ã§ããããèªã¿ã¾ãããã
è±èªã§ããã©ããããªã«é£ãããªãã¨æãã¾ãã
ãµã³ãã«ã¨ãè¦ãã°ä½ã¨ãªããããã¾ããã
ã¨ãã£ãã¨ããã§ãã²ã¨ã¾ãã
2010/10/14追è¨
ãªãã ãä¸å¹´ãçµã£ã¦æè¿ãã¯ããã¤ãã¯ãããããªã®ã§ããããåã«æ³¨ææ¸ããã°ã
usePlugin 'groovy'
ã¨ãã宣è¨ã¯ããéå»ã®ãã®ã«ãªããç¾ç¶ã§ã¯âã¨æ¸ãããã«ãªã£ã¦ã¾ãã
apply plugin:'groovy'
ã注æãã ããã