Gradle Wrapper ãã«ã¹ã¿ã ãã¦ã¿ã
ä»å¹´ãæ®ããããã¨ãªãã¾ããããä»å¹´æåã¨ãªãã¨ã³ããªã¼ã¯ã G*アドベントカレンダー 2014ãã®ç¬¬24æ¥ç®ã®è¨äºã§ãã
æ©ããã®ã§ Gradle ãã¯ããã¦ãããã¾ããªãï¼å¹´ãçµã¨ãã¨ãã¦ãã¾ãã ä»å¹´ã¯é·å¹´ã®æ²é¡ã§ãã£ãæ¥åã¸ã®å°å ¥ã«ãæåããé常ã«å å®ããä¸å¹´ã«ãªãã¾ããã
ããã§ä»åã¯æ¥åã§å®éã«ä½¿ã£ã¦ã¿ã¦ãã¨ã£ã¦ã便å©ã ã£ãæ©è½ã®ä¸ã¤ ãã«ã¹ã¿ã Gradle Wrapperã ï¼å®ã¯æ£å¼åã¯ä¸æ...ï¼ ãç´¹ä»ãããã¨æãã¾ãã
ããã¤ãã®ããã¸ã§ã¯ã㧠Gradle ã使ã£ã¦ããã¨ããã¤ãã決ã¾ãã® Gradle ã¹ã¯ãªãããæ¸ãã¦ãããã¨ã«æ°ã¥ããããã Ant ã Maven ãããè¨è¿°éãå°ãªãã¦æ¸ãã¨ã¯ãããã¡ãã£ã¨æ°ãæ» å ¥ãï¼ãã¨ãããã¾ããã...
ä¾ãã°ãJava ã®ã¨ã³ã³ã¼ãã£ã³ã°ã UTF-8 ã«ããå ´å
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }ã®ãããªã¹ã¯ãªãããããã¸ã§ã¯ããç«ã¡ä¸ãã度㫠build.gradle ã«æ¸ããªãã¨ãããªããã§ãã ããã ããªãã¾ã ããããããªã®ãããããããã¨...
ã¨è¨ããã¨ã§â¦
ãããªã¨ãã¯ãGradle Wrapper ãã£ã¹ããªãã¥ã¼ã·ã§ã³ï¼gradlew ãå®è¡ããã¨åæã«ãã¦ã³ãã¼ãããã Gradleï¼ã«ãinit ã¹ã¯ãªããããçµã¿åãããã«ã¹ã¿ã ãã£ã¹ããªãã¥ã¼ã·ã§ã³ãä½ã£ã¦ãã¾ãã¾ãããã
ã¡ãªã¿ã«ãinit ã¹ã¯ãªããã㯠build.gradle ãå®è¡ããåã«ãäºãæå®ã®ãã£ã¬ã¯ããªã«é
ç½®ãã¦ããã Gradle ã¹ã¯ãªãããå®è¡ãã¦ãããã¨ãã便å©ãªæ©è½ã§ããï¼è©³ç´°ã¯こちらï¼
ãGradle Wrapperãã¨çµã¿åããã¦ä½¿ãå ´å㯠Gradle Wrapper ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã® init.d é
ä¸ã«å®è¡ããããinit ã¹ã¯ãªããããé
ç½®ãã¦ããã ã㧠OK ã§ãã
ã§ã¯ãæ©éãJavaã®ã¨ã³ã³ã¼ãã£ã³ã°ã UTF-8 ã«å¤æ´ããã«ã¹ã¿ã ãã£ã¹ããªãã¥ã¼ã·ã§ã³ãä½æãã¦ã¿ã¾ãããã
ã¾ãã以ä¸ã® URL ãã Gradle Wrapper ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã®ãZIP ãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ãé©å½ãªå ´æã«è§£åãã¾ãã
http://services.gradle.org/distributions/gradle-2.2.1-bin.zip
ãã¼ã¸ã§ã³çªå·ã¯ 使ç¨ãããã¢ãã«åããã¦å¤æ´ãã¦ãã ããã
ä»å使ç¨ãããã¼ã¸ã§ã³ã¯ ææ°çã® 2.2.1 ã§ãã
ZIP ãã¡ã¤ã«ã解åããã¨
gradle-2.2.1 |-- bin/ |-- init.d/ |-- lib/ |-- media/ |-- LICENSE |-- NOTICE |-- changelog.txt `-- getting-started.htmlã®ãããªæ§æã«ãªã£ã¦ã¾ãã
次ã«ã解åãããã£ã¬ã¯ããªç´ä¸ã® init.d é ä¸ã«
allprojects { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } }ã®ããã«è¨è¿°ãã Gradle ãã¡ã¤ã«ï¼ãã¼ã¹åã¯ä»»æï¼ãä½æãã¾ãã
ä»å㯠ã³ã³ãã¤ã«ã«ã¤ãã¦ã®è¨å®ãè¨è¿°ãã Gradle ãã¡ã¤ã«ãªã®ã§ compile.gradle ã¨ãã¦ããã¾ãã
ã¡ãªã¿ã« init.d é ä¸ã«é ç½®ãã Gradle ãã¡ã¤ã«ã¯è¾æ¸é ã§å®è¡ããããããªã®ã§ãè¤æ°ãã¡ã¤ã«ãä½æããå ´åã¯å®è¡ãããé çªã«ãªãããã«ããæãã§ãã¡ã¤ã«åãä»ãã¾ãããã
æå¾ã«ãããä¸åº¦ ZIP ãã¡ã¤ã«ã«ã¢ã¼ã«ã¤ãããªããã°ãã«ã¹ã¿ã ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã®åºæ¥ä¸ããã§ãã
ä½æãã ZIP ãã¡ã¤ã«ã¯ ã©ãããã¦ã³ãã¼ãå¯è½ãªå ´æã«ç½®ãã¦ããã¾ãããã
ãã¨ã¯ ã«ã¹ã¿ã ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã使ãããããã¸ã§ã¯ãã® build.gradle ã«
wrapper { distributionUrl = 'http://xxx.xxx.xxx/xxxx/gradle-2.2.1-xx.zip' }ã®ããã« ZIPãã¡ã¤ã«ã®ãã¦ã³ãã¼ãURLãæå®ãã¦ããã¤ãã®ããã«
gradle wrapperãå®è¡ããã ãã§ãã ãã¡ãããä½æããããã¡ã¤ã«ã¯ VCS ã«ã³ããããã¦ããã¾ãããã ãã㧠åããã¸ã§ã¯ãã® build.gradle ã«
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }ã®ãããªã決ã¾ãã®ã¹ã¯ãªãããè¨è¿°ããªãã¦ãã
./gradlew build㧠UTF-8 ã§æ¸ããã Java ãã¡ã¤ã«ãã³ã³ãã¤ã«ã§ããããã«ãªããã§ãã
ã©ãã§ããï¼
ãã£ãããã ã㧠ãã¤ãä½ãèããã«æ¸ãã¦ãã ã決ã¾ãã® Gradle ã¹ã¯ãªãããã解æ¾ããããªãã¦ä¾¿å©ãããªãã§ããï¼
ãããã¿ãªãããæ¥é åããããªæ©ã¿ããããã¦ããããã§ãããããã²ã試ããã ããã
ææ¥ã¯ãããã大ããªã® touchez_du_bois ããã§ãã
ããã§ã¯ãã¿ãªããè¯ãã¯ãªã¹ãã¹ã!!
Gradle Watch Plugin ãä½ã£ã¦ã¿ã
ä»å¹´ãæ®ããããã¨ãªãã¾ããããä»å¹´æåã¨ãªãã¨ã³ããªã¼ã¯ ãG* Advent Calendar 2013ãã®12æ¥ç®ã§ãã
çãã Gradle 使ã£ã¦ã¾ããï¼
èªåã¯ã¨è¨ãã¨â¦
æ®å¿µãªãããä»å¹´ãæ¥åã¸ã®æ¬æ ¼å°å
¥ã¯ã§ããªãã£ãã®ã§ã
æ¥å¹´ããã¯å°å
¥ãããã¨ããææ°è¾¼ã¿ãè¾¼ãã¦ãGradle ãã©ã°ã¤ã³ãä½ã£ã¦ã¿ã¾ããã
ä»åä½æãã Gradle ãã©ã°ã¤ã³ã§ãããç°¡åã«è¨ã£ã¦ãã¾ã㨠grunt-contrib-watch ã®ãããªãã©ã°ã¤ã³ã§ããã¨ããããã¯ãªã§ãã
grunt-contrib-watch 㯠ãã¡ã¤ã«ãå¤æ´ãããã¿ã¤ãã³ã°ã§ä»»æã®ã¿ã¹ã¯ãå®è¡ãã Grunt ï¼JavaScript 製ãã«ããã¼ã«ï¼ç¨ã®ãã©ã°ã¤ã³ã§ãã
æè¿ãG* ã¤ãªããï¼ã§ Grunt ã«ãå°ãæãåºãå§ãã¦ããã®ã§ãããï¼ã¾ã ãGradle ããæ¬æ ¼å°å
¥ã§ãã¦ããªãã®ã«ï¼
ãã®ä¸ã§ã grunt-contrib-watch ãã©ã°ã¤ã³ãã¨ã£ã¦ã便å©ã
æ©éãGradle ã§ãåããã©ã°ã¤ã³ããªããæ¢ãã¦ã¿ãã®ã§ãããæ®å¿µãªããè¦ã¤ãããã¨ãã§ãã¾ããã§ããã
Java ããã°ã©ã㯠IDE åæã ãããããã£ããã©ã°ã¤ã³ã®éè¦ã¯ãªãã®ããªã¨ã
æãã¾ãããããããªãã¨ã¯æ°ã«ããããªããªãä½ã£ã¡ããã°ããããããã¨è¨ããã¨ã§ãããã£ã¨ä½ã£ã¦ã¿ã¾ããã
ãã©ã°ã¤ã³ã®ä½¿ãæ¹ã®åã«ãã¾ãã¯ããããã¨è¨ã訳â¦
æéããªãã¦ããªãé©å½ãªä½ãã«ãªã£ã¦ãã¾ããï¼ä»å¾ãã¡ããã¨ãã¦ããäºå®ï¼
ã¾ããJava7 ã® NIO.2 ã使ã£ã¦ããã®ã§ Java7 以ä¸ã§ãªãã¨åãã¾ããã
ãã¡ãããè¯ãåã®çãã㯠Java6 ã¨ã使ã£ã¦ãªãã§ãããã
ããããã¦ãè¯ãåã¯ãããã§ã« Java8 使ã£ã¦ãã®ããªï¼
ãã¨ãMac OS X 使ã£ã¦ãã¿ãªãããï¼ç§ããã®ä¸äººã§ããï¼æ®å¿µãªãããWatchService
ã®ãã¡ã¤ã«æ´æ°ã®éç¥ãé
ãã®ã§ãåä½ãã¢ãµãã¨ãã¦ãã¦ã¡ãã£ã¨ã¤ã©ã£ã¨ãã¾ãã
ã¨è¨ããã¨ã§ãGradle Watch Plugin ã®ä½¿ãæ¹ã§ãã ã¨ã£ã¦ãç°¡åã§ãã
ã¾ãããã®ãã©ã°ã¤ã³ãå©ç¨ãããããã¸ã§ã¯ãã® build.gradle ã«
buildscript { repositories { maven { url 'http://bluepapa32.github.io/maven/' } } dependencies { classpath 'com.bluepapa32.gradle.plugins:gradle-watch-plugin:0.1.0' } } apply plugin: 'watch'ã追å ãã¦ãGradle Watch Plugin ãé©ç¨ãã¾ãããã¨ã¯
watch { java { files files('src/main/java') tasks 'compileJava' } resources { files fileTree(dir: 'src/main/resources', // FileTree ã§æå® include: '**/*.properties') tasks 'processResources' } hoge { files files('foo/bar', 'foo/boo/hoo.txt') // è¤æ°ã®ãã£ã¬ã¯ããªãç£è¦ tasks 'hogehoge', 'hugohugo' // è¤æ°ã®ã¿ã¹ã¯ãå®è¡ } }㨠watch ãããã¯å ã« ä»»æã®ååãä»ãããããã¯ï¼watch ãããã¯å ã§ã¦ãã¼ã¯ã§ããã°ä½ã§ãå¯ï¼ãå®ç¾©ãã¦ããã®ãããã¯å ã«
åå | 説æ | å |
---|---|---|
files | ç£è¦ããããã£ã¬ã¯ã㪠ã¾ã㯠ãã¡ã¤ã« | FileCollection |
tasks | ãã¡ã¤ã«ãå¤æ´ãããéã«å®è¡ããã¿ã¹ã¯ | String[] |
gradle watchã¨å®è¡ããã ãã§ã常é§ããã»ã¹ããã¡ã¤ã«ãç£è¦ãã¦ãå¤æ´ããã£ãã¿ã¤ãã³ã°ã§æå®ããã¿ã¹ã¯ãå®è¡ãã¦ãããããã«ãªãã¾ãã
ä¸ã®ä¾ã®å ´åãsrc/main/java é ä¸ã®ãã¡ã¤ã«ãæ´æ°ããã㨠compileJava ã¿ã¹ã¯ãå®è¡ãããsrc/main/resources é ä¸ã® ããããã£ãã¡ã¤ã«ãæ´æ°ããã㨠processResources ã¿ã¹ã¯ãå®è¡ããã¾ãã
ãããèå³ãããã°ããã²ä½¿ã£ã¦ã¿ã¦ãã ããã
ã¡ãªã¿ã«ã½ã¼ã¹ã¯ GitHub ã«å
¬éãã¦ãã¾ãã
ãã£ãããªã®ã§ãä»åãã©ã°ã¤ã³ãä½æããã«ããããããã¤ãæ°ããæ©è½ã使ã£ã¦ã¿ãã®ã§ç°¡åã«ç´¹ä»ãããã¨æãã¾ãã
ãã®åã«ãGradle ãã©ã°ã¤ã³ã®åºæ¬çãªä½ãæ¹ã§ããã
ä»å使ã£ã¦ã¿ãæ°ããæ©è½ï¼ããæ°æ©è½ã§ã¯ãªãããããã¾ããã...ï¼ã¯
ã®2ã¤ã§ããextension ãªãã¸ã§ã¯ã
ã¾ããextension ãªãã¸ã§ã¯ãã§ããããã£ããè¨ãã¨ç¬èªã§DSLãæ¡å¼µã§ããä»çµã¿ã§ãã
ä¾ãã°ãä¸è¨ã® watch ãããã¯ã¯ ãã®æ©è½ã使ã£ã¦è¿½å ãããã®ã§ãã
æ´ã« ä»åã®å ´åãwatch ãããã¯å é¨ã§èªç±ã«ãããã¯ã追å ã§ããã®ã§ããããã 㯠NamedDomainObjectContainer ã¨ããã¯ã©ã¹ã使ã£ã¦å®ç¾ãã¦ãã¾ãã
以ä¸ããããå®ç¾ãã¦ããã³ã¼ãã§ãããã£ãããã ãã§ããã¨ã£ã¦ãç°¡åã§ãããclass WatchPlugin implements Plugin<Project> { void apply(Project project) { project.extensions.watch = project.container(WatchTarget) { name -> project.extensions.create(name, WatchTarget, name) } ... } }
NamedDomainObjectContainer 㯠Project ã¯ã©ã¹ã® container ã¡ã½ããã§çæãããã¨ãã§ãã¾ãã
ä»åã®å ´å watch ã NamedDomainObjectContainer ã«å¯¾å¿ãã¦ãã¾ãã
container ã¡ã½ããã®å¼æ°ã«æå®ãã¦ããåã NamedDomainObjectContainerå
ã®è¦ç´ ã®åã
ãã®å¾ãã®ã¯ãã¼ã¸ã£ãå®éã« NamedDomainObjectContainer å
ã®è¦ç´ ãçæããé¨åã«ãªãã¾ãã
ä»åã®å ´åãwatch ãããã¯å
ã® java, resources, hoge ãé çªã« name å¤æ°ã§åãåãã
ã¯ãã¼ã¸ã£å
㧠WatchTarget ãçæãã¦ãã¾ãã
ãã¡ããçæããã WatchTarget ã«ã¯ files ã tasks ã§å®ç¾©ããå¤ãåæã«è¨å®ããã¾ãã
ãã£ãããã ãã§èªç±ã«DSLãæ¡å¼µã§ãããªãã¦ã便å©ãªä¸ã®ä¸ã«ãªãã¾ãããã
Gradle tooling API
ããä¸ã¤å©ç¨ããæ©è½ã Gradle tooling API ã§ãã
ProjectConnection connection = GradleConnector.newConnector() .forProjectDirectory(new File("someProjectFolder")) .connect(); try { connection.newBuild().forTasks("taskA", "taskB").run(); } finally { connection.close(); }ã®ããã«æ¸ãã ãã§ãGradle以å¤ã®ï¼ä¾ãã° IDE ã¿ãããªï¼ã¢ããªã±ã¼ã·ã§ã³ããç´æ¥ Gradle ã®ã¿ã¹ã¯ãå®è¡ã§ããããã«ãªãã¨ãã便å©ãªæ©è½ã§ãã
ä»å㯠Gradle ãã©ã°ã¤ã³ããå®è¡ãã¦ããã®ã§ã¢ã¬ã§ããâ¦
ã¨è¨ããã¨ã§â¦
ä»å¹´ã®å¬ä¼ã¿ã¯ ã¿ãªããã Gradle ãã©ã°ã¤ã³ãä½ã£ã¦ã¿ã¦ã¯ãããã§ããããï¼
ææ¥ã¯ ãã® ããããã ãåã³ç»å ´ã§ãã
ããã§ã¯ å°ãæ©ãã§ãã è¯ãã¯ãªã¹ãã¹ãï¼ï¼
GroovyFX 㧠GUI ã¢ããªã±ã¼ã·ã§ã³éçºãã¯ããããï¼ï¼
ä»å¹´ããã¨ãããã¨ãªãã¾ããããä»å¹´æåã¨ãªãï¼ããã å¤å ä»å¹´æå¾ã«ãªãã§ãããï¼è¨å¿µãã¹ãã¨ã³ããªã¼ã¯ ãG* Advent Calendar 2012ãã®21æ¥ç®ã§ãã
æ¨å¹´ã¯ãã£ããåºé
ãã¦å¯ããæãããã¾ããããä»å¹´ã¯éã«åãã¾ãããï¼ï¼
ã§ãæ©éã§ãã...
çãã Gradle 使ã£ã¦ã¾ããï¼
(GroovyFX ã®è©±ã¯ã¡ãã£ã¨ããã¨ãã¦...)
èªåã¯ã¨ããã¨...
Gradle ã®æ£å¼çããªãªã¼ã¹ãããã«ãé¢ããããä»å¹´ãæ¬æ ¼çã«å°å
¥ãããã¨ãã§ãããã¡ãã£ã¨ãããããã¿ã¤ã ããã¸ã§ã¯ãã®ãã«ãããã¼ã«ã¨ãã¦å©ç¨ããç¨åº¦ã¨ããæ®å¿µãªçµæã«...
ã¨ã¯è¨ã æ³¥èãç¾å ´ã§ã¯ ã¡ãã£ã¨ãããã¼ã«ã¨ããã®ãçµæ§å¤§äºãªãã§ãããã
ã§ã ãããå¨ãã«ã使ã£ã¦ããããã¨ãã㨠ãã³ãã³ãã©ã¤ã³ ã¯ã¡ãã£ã¨...ã ã¨ããã㨠ããããã¾ãããï¼
ãã㧠GroovyFX ã§ããï¼ï¼
GroovyFX ãªã ã¨ã£ã¦ãç°¡åã« GUI ãã¼ã«ãä½ãã¡ãããã§ãã
GroovyFX ã£ã¦ä½ï¼ ã¨ãã人ã®ããã« ç°¡åã«è¨ãã¨
ãGroovy 㧠JavaFX 2.x ãç°¡åã«æ±ãããã® ã©ã¤ãã©ãª
ã§ãã(ååã®ã¾ãã¾ã§ãã...)
詳細ã¯こちら
ãã¡ãã GroovyFX ã ãã§ã OK ã§ãããGradle ã§æ´ã«å¿«é©ã«... ã®ãããªç»é¢ã表示ããã ãã§ããã°
hellofx |-- src/main/groovy/ | `-- hellofx/Main.groovy `-- build.gradleã®ãã㪠ãã£ã¬ã¯ããªæ§æã§
Main.groovy
package hellofx import static groovyx.javafx.GroovyFX.start start { stage(title: 'Hello, GroovyFX', visible: true) { scene(fill: BLACK, width: 500, height: 250) { hbox(padding: 60) { text(text: 'Groovy', font: '80pt sanserif') { fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN]) } text(text: 'FX', font: '80pt sanserif') { fill linearGradient(endX: 0, stops: [CYAN, DODGERBLUE]) effect dropShadow(color: DODGERBLUE, radius: 25, spread: 0.25) } } } } }
build.gradle
apply plugin: 'groovy' apply from: 'http://repository-javafx-gradle-plugin.forge.cloudbees.com/snapshot/javafx.plugin' repositories { mavenCentral() } dependencies { groovy 'org.codehaus.groovy:groovy-all:2.0.5' groovy 'org.codehaus.groovyfx:groovyfx:0.3.1' }ã®ãããªï¼ã¤ã®ãã¡ã¤ã«ãç¨æãã¦
gradle runã¨å®è¡ããã ãã§ãï¼ï¼
ãã£ãããã ã㧠GUI ã¢ããªã±ã¼ã·ã§ã³ãä½ãããªãã¦ããæ代ã«ãªã£ããã®ã§ãã
ããã使ããªãæã¯ãªãã§ãããã
# ãã¡ãããçãã JDK 7u10 ã¯ã¤ã³ã¹ãã¼ã«ãã¦ã¾ãããï¼ï¼ JRE ã§ã¯ãã¡ã§ããã
# ããã¤ã³ã¹ãã¼ã«ãã¦ããªãã¨ããæ¹ã¯ ã¾ã㯠JDK ãã¤ã³ã¹ãã¼ã«ãã¾ãããï¼ï¼
# ãã£ãããã¨ãã¡ãã Gradle ã...
æ´ã«
gradle buildã¨å®è¡ããã° build/distributions é ä¸ã«
- JAR å½¢å¼
- JNLPå½¢å¼
- éçºç°å¢ã«ãã Windows ã®å ´å hellofx.exeãMac OS X ã®å ´å hellofx.app
ããã㯠Gradle JavaFX Plugin ã«ããå®ç¾ããã¦ãã¾ãã
æ®å¿µãªãã ä»ã®ã¨ãã å
¬å¼ãª JavaFX 2.x ç¨ã® ãã©ã°ã¤ã³ã¯ãªãããã§ããããã®ãã©ã°ã¤ã³ã¯ããªãããã§ããã
æ©ã å
¬å¼ãã©ã°ã¤ã³ã¨ãã¦æ¡ç¨ãããã¨ããã®ã§ãã...
ãã®ãã©ã°ã¤ã³ã¯
apply from: 'http://repository-javafx-gradle-plugin.forge.cloudbees.com/snapshot/javafx.plugin'ã追å ããã ãã§é©ç¨ãããJavaFX ã®ãã«ããå®è¡ã«å¿ è¦ãªè¨å®ãã¿ã¹ã¯ã追å ããã¾ãã
ãã®ãã©ã°ã¤ã³ãé©ç¨ããéã®ã¿ã¹ã¯ã¯ãããªæã...
Build tasks ----------- assemble - Assembles the outputs of this project. build - Assembles and tests this project. buildDependents - Assembles and tests this project and all projects that depend on it. buildNeeded - Assembles and tests this project and all projects it depends on. classes - Assembles the main classes. clean - Deletes the build directory. cssToBin - Converts CSS to Binary CSS. generateDebugKey - Generates the JAvaFX Debug Key. jar - Assembles a jar archive containing the main classes. jfxDeploy - Processes the JavaFX jars and generates webstart and native packages. jfxJar - Jars up the classes and adds JavaFX specific packaging. jfxSignJar - Signs the JavaFX jars the JavaFX way. packageClasses - Assembles the package classes. testClasses - Assembles the test classes. Documentation tasks ------------------- groovydoc - Generates Groovydoc API documentation for the main source code. javadoc - Generates Javadoc API documentation for the main source code. Execution tasks --------------- debug - Runs the applicaiton and sets up debugging on port 5005. run - Runs the application. Tools tasks ----------- scenicview - Adds the ScenicView agent to all Execution Tasks. Verification tasks ------------------ check - Runs all checks. test - Runs the unit tests.ã¡ãªã¿ã« ãã®ãã©ã°ã¤ã³ã§ã¯ å½åè¦ç´ã決ã¾ã£ã¦ã㦠ããã©ã«ãã§ã¯
<ããã¸ã§ã¯ãå>.Mainã ã¡ã¤ã³ã¯ã©ã¹ã«ãªãããã§ããä»åã®å ´å
hellofx.Mainã§ããã
ä»åä½æãããµã³ãã«ããã¸ã§ã¯ã㯠こちら ã§ãã
èå³ã®ããæ¹ã¯ã©ããï¼ï¼
ãã ZIP å½¢å¼ã§ãã¦ã³ãã¼ãããå ´å㯠解åå¾ã®ãã£ã¬ã¯ããªåã hellofx ã«å¤æ´ãã¦ãã ããã
æã£åãæ©ããGroovyFX ã試ãã¦ã¿ããã®ã®ãããã 㨠GroovyFX & JavaFX ã®ããããããã¥ããã®ã§ãããã¡ãã£ã¨ ããããããã®ãï¼ï¼
ã¨ãããã¨ã§ãGitHub ãããµã³ãã«ããã¸ã§ã¯ãããã¦ã³ãã¼ããã¦å®è¡ãã GUI ãã¼ã«ãä½æãã¦ã¿ã¾ããã
ãããªæã...
㧠ä»å GroovyFX ã試ãã¦ã¿ã¦ããã£ããã¨ã¯ ç°¡å㪠GUI ãã¼ã«ãä½æããç¨åº¦ã§ããã°ãGroovyFX ã® (ã¨è¨ããã Groovy ã®ããªï¼) å¼·åãªãã«ãã¼æ©è½ã使ã£ã¦å°éã«ç»é¢ãä½æããããã JavaFX 2.x ã® JavaFX Scene Builder ã使ã£ãæ¹ã楽ã£ã¦ãã¨ã§ããã
ä»ååã㦠JavaFX Scene Builder ã使ã£ã¦ã¿ãã®ã§ããããã ããªãããã§ããã
ç°¡åãªãã¼ã«ã®éçºããããªãããã㧠ååã§ã¯ãªãããª...
ãã®ãã¼ã«ã使ãã¡ãªãã㯠ãã¡ãããGUI ç»é¢ã§ ç»é¢ã®ãã¶ã¤ã³ãã§ãããã¨ãããã¨ãããã¾ããã
ãããããããããç»é¢ã®ãã¶ã¤ã³ã¨ã³ã³ããã¼ã«ãå®å
¨ã«åé¢ã§ãããã¨ãããã¨ã§ã¯ãªãã§ããããï¼
å®éã¯ãã®ãã¼ã«ã¨ãããã FXML ã使ãã¡ãªããã¨è¨ã£ãæ¹ãæ£ããã®ããããã¾ããã...
JavaFX Scene Builder ã使ãã°
- FXML ï¼JavaFX Scene Builder ã§ä½æãããXMLãã¡ã¤ã«ï¼
- CSS ï¼ãªãã¡ã¬ã³ã¹ã¯ こちらï¼
- Groovy(FX)
ããã£ã¦çµæ§ããããªãã§ããï¼ããã§ããªãæ·å± ãä¸ããã¨æããã§ãããã
㧠ä»åä½ã£ããã®ã¯ãããªæãã®æ§æã«ãªãã¾ãã
gradlefx |-- build.gradle `-- src `-- main |-- groovy | `-- gradlefx | |-- Controller.groovy | `-- Main.groovy `-- resources |-- gradlefx.css `-- gradlefx.fxml
詳ãã話ã¯ã¾ãã®æ©ä¼ã«ããã¨ãã¦...
ãã£ã ï¼(+1) ãã¡ã¤ã«ã§ GUI ãã¼ã«ãä½æã§ããã®ã§çããã ãã² ä½ãä½ã£ã¦ã¿ã¦ãã ããã
ä»åä½æãããµã³ãã«ããã¸ã§ã¯ã㯠こちら ã§ãã
èå³ã®ããæ¹ã¯ã©ããï¼ï¼
ãã ZIP å½¢å¼ã§ãã¦ã³ãã¼ãããå ´å㯠解åå¾ã®ãã£ã¬ã¯ããªåã gradlefx ã«å¤æ´ãã¦ãã ããã
G* Advent Calendar 2012 ã ããçµç¤ã«å·®ãæãã£ããã®ææã« ä»æ´ã§ã¯ããã¾ãã G* Advent Calendar 2012 ãã«ã¬ã³ãã¼å½¢å¼ã§åç
§ã§ãã GUI ã¢ããªã±ã¼ã·ã§ã³ãä½æãã¦ã¿ã¾ããã
èå³ã®ããæ¹ã¯ こちら ãã©ããï¼ï¼
ãã ZIP å½¢å¼ã§ãã¦ã³ãã¼ãããå ´å㯠解åå¾ã®ãã£ã¬ã¯ããªåã groovyfx ã«å¤æ´ãã¦ãã ããã
åæ¥ä»ã®åå è
ã®ãªã³ã¯ãã¯ãªãã¯ãã㨠ATND ã®ã³ã¡ã³ãã表示ããã¾ããã³ã¡ã³ãã®ãªã³ã¯ãæ¼ãã¨ãã©ã¦ã¶ã§ããã°ãã¿ãã¡ããã¾ãã
æéããªãã¦ããªãä¸éå端ãªããã§ãããGroovyFX ã®åå¼·ï¼WEB ãµã¼ãã¹é£æºãéåæå¦çããã©ã¦ã¶é£æº çã
ï¼ã«ã¯ããªãå½¹ã«ç«ã£ãã®ã§ ã¾ã ã¨ã·ã¨ãã¨ããããªã
ãããªãã«è¦å´ããã®ã§ãã¾ããæéãããã¨ãã« ããã°ã«ã¾ã¨ãã¦ãããã¨æãã¾ãã
ææ¥ã¯ ãããã [twitter:@kimukou_26] ããã§ããï¼ï¼
ã§ã¯ãã¿ãªãã ããã¯ãªã¹ãã¹ãï¼ï¼
Apache Solr ã 60 ç§ã§è©¦ãã¦ã¿ã
ä»åã Java ã§å
¨ææ¤ç´¢ã§ãã
åå㯠Apache Lucene ã試ãã¾ããã
ã検索エンジンの常識をApache Solrで身につけるã
ã¨ãããã¨ã§ Apache Solr ã®ãã¢ã試ãã¦ã¿ã¾ããã
ãã¡ãããä»åã誰ã§ã 60ç§ã§ ãã¢ã試ããããã« Gradle ã¹ã¯ãªãããä½ã£ã¦ã¿ã¾ããã
Solr ã Gradle ã使ãã° ãã£ã ï¼ã¹ããã + α ã§æ°è»½ã«è©¦ããã®ã§ã å ¨ææ¤ç´¢ã«å°ãã§ãèå³ã®ããæ¹ã¯ ãã²ã試ãã¦ã¿ã¦ãã ããã
- build.gradle ä½æ
- Solr èµ·å
- ã¤ã³ããã¯ã¹ä½æ
- å ¨ææ¤ç´¢ å®è¡
- Solr åæ¢
build.gradle ä½æ
ã¾ãã¯é©å½ãªãã£ã¬ã¯ããªã« 次ã®ã¹ã¯ãªããã build.gradle ã¨è¨ãååã§ä¿åãã¾ãã
以ä¸ã® ãview rawãã® ãªã³ã¯å
ãä¿åããã®ãç°¡åã§ãã
ãã¡ããä»åã ã¹ã¯ãªããã®è©³ç´°ã¯æãã¨è¨ããã¨ã§ãSolr ã楽ãã¿ã¾ãããã
Solr èµ·å
ã¾ã㯠ãããªã Solr ãèµ·åãã¦ã¿ã¾ãããã
gradle startãå®è¡ããã°ãååèµ·åæã« åæã«å¿ è¦ãªãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ã«ã¬ã³ããã£ã¬ã¯ããªã« å±éãã¾ãã
èªåã§ããããç°å¢ãä½ãå¿ è¦ã¯ããã¾ããã
ä»å㯠Solr ã®ãã¢ã試ãã ããªã®ã§ ãã¡ãã example ã«å«ã¾ãã¦ãã Jetty ã使ã£ã¦ãã¾ãã
ååèµ·åæ㯠å°ãæéããããã¾ããã"BUILD SUCCESS" ã¨è¡¨ç¤ºãããã° OK ã§ãã
ãã㧠Solr ãèµ·åãããã¯ããªã®ã§ 好ããªã ã å
¨ææ¤ç´¢ã楽ãã¿ã¾ãããã
æå§ãã« http://localhost:8983/solr/admin ã«ã¢ã¯ã»ã¹ãã¦ã¿ã¾ãããã
以ä¸ã®ãã㪠管çç»é¢ã表示ãããã¯ãã§ãã
ã¨è¨ã£ã¦ã ã¾ã ã¤ã³ããã¯ã¹ãä½æãã¦ããªãã®ã§æ¤ç´¢ãã¦ãä½ãããããã¾ããã ANALYSIS ãããã§éãã§ã¿ãã¨é¢ç½ãããããã¾ããã
ã¤ã³ããã¯ã¹ä½æ
ã§ã¯ æ©éã¤ã³ããã¯ã¹ãä½æãã¦ã¿ã¾ãããã
é常ã¯ãã㧠XML ãã¡ã¤ã«ãæã§ä½æã㦠Solr ã« POST ããã¨ããã®ãæ
£ä¾ã®ããã§ãã ãããªã®é¢åãªã®ã§
gradle indexãå®è¡ãã¾ãããã
ããã§ååã¨åæ§ã« lucene-core-3.5.0-sources.jar å ã®ã½ã¼ã¹ãã¡ã¤ã«ã®å 容ã Solr ã« POST ãã㦠ã¤ã³ããã¯ã¹ãä½æããã¾ãã
ä»å㯠solrj ã¨è¨ã Java ç¨ã®ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªã使ç¨ãã¦ããã®ã§
def server = new CommonsHttpSolrServer(serverurl) server.deleteByQuery("*:*") server.add(fileTree(dir: 'src').collect { f -> println f def doc = new SolrInputDocument() doc.addField( "id", f.path, 1.0f ) doc.addField( "text", f.text) return doc }) server.commit()ãå®è¡ãã¦ãSolr èµ·åæã« ããããã src é ä¸ã«å±éãã¦ããã lucene-core-3.5.0 ã®ã½ã¼ã¹ãã¡ã¤ã«ã®æ å ±ã Solr ã«éä¿¡ãã¦ãã¾ãã
ããã°ã£ã¦ XML ãªãã¦æ¸ããªããã£ã¦ ãã£ãããã ãã§å¤§éã®ã¤ã³ããã¯ã¹ãä½æã§ãããã§ããã¨ã¦ãç°¡åã§ããï¼ï¼
ããã å®é㯠HTTP ã§éä¿¡ãã¦ããã ãã§ãã®ã§ ã©ããªè¨èªããã§ãå©ç¨ã§ããã¨è¨ãã®ããã°ãããã
å ¨ææ¤ç´¢ å®è¡
æè§ãªã®ã§ ãã©ã¦ã¶ããæ¤ç´¢ãã¦ã¿ã¾ãããã
http://localhost:8983/solr/select?q=reader&rows=1000 ãã¯ãªãã¯ãã¦ã¿ã¦ãã ããã
ãã©ã¦ã¶ã« XML ã表示ãããã¯ãã§ãã
XML ã表示ãã¦ã ãªãããã³ã¨ããªãã®ã§
gradle ?readerãå®è¡ã㦠ååã¨åãããã«è©²å½ãããã¡ã¤ã«ã®ãã¹ãåºåãã¦ã¿ã¾ãããã
ä»åã®å ¨ææ¤ç´¢ã«å¿ è¦ãªã³ã¼ãã¯
def query = new SolrQuery(taskName[1..-1]).set("rows", 1000) new CommonsHttpSolrServer(serverurl).query(query).results.each { println it.getFieldValue("id") }ã®ï¼è¡ã ãã§ããã¨ã£ã¦ãç°¡åã§ããã
ãã£ãããã ã㧠Solr ã«ãªã¯ã¨ã¹ããæãã¦è¿ã£ã¦ããæ¤ç´¢çµæãå©ç¨ã§ãããã§ãã
Solr åæ¢
å ¨ææ¤ç´¢ãååæºå«ããã
gradle stop㧠Solr ãåæ¢ãã¦ããã¾ãããã
ãã¾ã Solr ãæºå«ã§ãã¾ãããï¼
Solr ã使ãã° ã¯ã©ã¤ã¢ã³ãå´ããå
¨ææ¤ç´¢ãåé¢ã§ããã®ã§éçºã楽ã«ã§ãããã§ãã
ãã¡ãããå
¨ææ¤ç´¢å´ã®ãã¥ã¼ãã³ã°çã¯ããããã¨å¤§å¤ããã§ãã...
ã¡ãªã¿ã«ä»åãæ¥æ¬èªã®æ¤ç´¢ã¯æ£ããã§ãã¾ããã
次å㯠æ¥æ¬èªãèæ
®ããæ¤ç´¢ã試ããããã«ãã¦ã¿ããããª...
Apache Lucene ã 60 ç§ã§è©¦ãã¦ã¿ã
ä»æ´ãªãã Java ã§å ¨ææ¤ç´¢ã§ããã¨ãããã Apache Lucene ã® ãã¢ã試ãã¦ã¿ããã¨æã£ãã®ã§ãããææ°ãªãªã¼ã¹ã® 3.5.0 ã®æ å ±ãè¦å½ãããªãã£ãã®ã§ããã®éã誰ã§ã 60ç§ã§ ãã¢ã試ããããã« Gradle ã¹ã¯ãªãããä½ã£ã¦ã¿ã¾ããã
ãã¢ã®ããã« ãããã èªåã§ãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ã解åãã¦ããããã¦ããã㦠ãªãã¦é¢åã§ãããã
Gradle ã使ãã° ãã£ã 3 ã¹ãããã§è©¦ãã¾ãã(ãã¡ãããä»æã®äººãã¡ã¯ æ¢ã« Gradle ã¯ã¤ã³ã¹ãã¼ã«æ¸ã¿ã§ããã...)
- build.gradle ä½æ
- ã¤ã³ããã¯ã¹ãã¡ã¤ã« ä½æ
- å ¨ææ¤ç´¢ å®è¡
build.gradle ä½æ
ã¾ã㯠é©å½ãªãã£ã¬ã¯ããªã« build.gradle ãä½æã㦠次ã®ã¹ã¯ãªãããã³ãã¼ãã¾ãããã
ä»å㯠Lucene ãã¡ã¤ã³ãªã®ã§ Gradle ã¹ã¯ãªããã®ç´°ãã説æã¯çç¥ãçµæ§ããã°ã£ããã§ããã©...
ã¤ã³ããã¯ã¹ãã¡ã¤ã« ä½æ
次㫠以ä¸ã®ã³ãã³ããå®è¡ãã¦å
¨ææ¤ç´¢ã®ããã®ã¤ã³ããã¯ã¹ãã¡ã¤ã«ãä½æãã¾ãããã
gradle index
ãã®ã³ãã³ããå®è¡ããã¨
- ãã¢ã®å®è¡ã«å¿ è¦ãªã©ã¤ãã©ãªã Maven ãªãã¸ããªããåå¾
- lucene-core-3.5.0-sources.jar ã Maven ãªãã¸ããªããåå¾ã㦠src ãã£ã¬ã¯ããªã«å±é
- src é ä¸ã®ã½ã¼ã¹ãã¡ã¤ã«ããã¨ã« ã¤ã³ããã¯ã¹ãã¡ã¤ã«çæ
ã®ãããªå¦çãå®è¡ããã¾ãã
å ¨ææ¤ç´¢ å®è¡
ãã¨ã¯ 以ä¸ã®ã³ãã³ãã®
gradle ?<query>
ä¾ãã° "reader" ãæ¤ç´¢ãããå ´å
gradle ?reader
ã®ããã«å®è¡ãã¾ããããè¤æ°ã®åèªãæå®ãããå ´åã¯
gradle ?'reader AND search'
ã®ããã«ã¯ã©ã¼ããã¾ããããmain é¢æ°ãå«ããã¡ã¤ã«ãæ¤ç´¢ããããªã
gradle ?'"public static void main("'
ã®ãããªæã㧠OK...
Gradle 使ãã° ãããªã«ç°¡åã«å
¨ææ¤ç´¢ã§ãã¡ãããã§ããã
ãªãä»ã¾ã§è©¦ããªãã£ããã ãããï¼
ä»åº¦ã¯ æ¥æ¬èªã®å
¨ææ¤ç´¢ã試ãã¦ã¿ããããªï¼
ãã¡ãã Gradle ã§...
Gradle ã§ã¡ã¼ã«ãéã£ã¦ã¿ã
Gradle ã§ã¡ã¼ã«ãéããã¨ããã ã¯ã©ã¹ãã¹é¢ä¿ã§ã¯ã¾ã£ã¦ãã¾ã£ãã®ã§ã¡ã¢ãã¦ãããã
ã©ããããant.mail ã使ãããã«ã¯ EmailTask (Ant ã®ã©ã¤ãã©ãª) ãèªã¿è¾¼ãã ã¯ã©ã¹ãã¼ãã«ç´æ¥ JavaMail é¢ä¿ã®ã©ã¤ãã©ãªã追å ãããããªãã£ã½ãã
ã¯ã©ã¹ãã¼ãã«ç´æ¥ JAR ãã¡ã¤ã«ã追å ã§ããã®ã Gradle(Groovy) ã®è¯ãã¨ããã§ãããã®ã ããã¡ã¼ã«ã§ã¡ãã£ã¨éç¥ããã ããªã®ã« ãããªã«æ¸ããªãã¨ãããªã®ã ãªãã ããªã...
æ©ãæ¨æºã§ãµãã¼ããã¦ã»ãããªã...
import org.apache.tools.ant.taskdefs.email.EmailTask configurations { sendmail } repositories { mavenCentral() } dependencies { sendmail 'javax.mail:mail:1.4.4' sendmail 'org.apache.ant:ant-javamail:1.8.2' } task mail << { configurations.sendmail.each { f -> EmailTask.class.classLoader.addURL(f.toURI().toURL()) } ant { mail(mailhost: "smtp.server.name", mailport: 25, subject: "ãã¹ã", message: "ããã«ã¡ã¯ãGradle!!", charset: "ISO-2022-JP") { from(address: "[email protected]") to(address: "[email protected]") } } }
Spockã§ããã¹ãã¹ã¤ã¼ããã¦ã¿ã
ãEclipse で複数の Specification を一括実行するãã§
å®ã¯ Spock ã«ã¯ Junit ã®ãã¹ãã¹ã¤ã¼ãã®ãããªæ©è½ã¯ããã¾ããããªãã¦ãã¨ãæ¸ãã¦ãã¾ãã¾ããã Spock ã§ã ã¡ããã¨ãã¹ãã¹ã¤ã¼ãã§ãã¾ãã
ã¤ã¾ããSpock èªèº«ã«ã¯ è¤æ°ã® Specification ãä¸æ¬ã§å®è¡ããæ©è½ã¯ãªãã®ã§ãã Eclipse で複数の Specification を一括実行する - bluepapa32’s Java Blog
ã¨è¨ãã®ã...
Spock ã® Specification ã¯
Junit4 ã®ä»çµã¿ã§åãã¦ããã®ã§ Junit4 ã®ãã¹ãã¹ã¤ã¼ãã¨åãããã«
package com.bluepapa32; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({ FooSpec.class, BarSpec.class, HogeSpec.class, }) public class AllSpecifications { }ã¨æ¸ãã° ã¡ããã¨ãã¹ãã¹ã¤ã¼ãã§ãããã§ããã
ã¡ãªã¿ã« ä¸è¨ã¯ Java ã§æ¸ãã¦ãã¾ãããGroovy ã§æ¸ãã°
package com.bluepapa32 import org.junit.runner.RunWith import org.junit.runners.Suite import org.junit.runners.Suite.SuiteClasses @RunWith(Suite) @SuiteClasses([FooSpec, BarSpec, HogeSpec]) class AllSpecifications {}ã¨ã¡ãã£ã¨ã ã楽ã§ãã¾ãã