{"id":716,"date":"2018-06-14T19:52:39","date_gmt":"2018-06-14T10:52:39","guid":{"rendered":"https:\/\/www.nukoneko.info\/blog\/?p=716"},"modified":"2018-08-16T01:54:48","modified_gmt":"2018-08-15T16:54:48","slug":"java-non-android-%e3%81%a7-dagger2%e3%82%92%e4%bd%bf%e3%81%86%e6%99%82%e3%81%ab%e5%be%ae%e5%a6%99%e3%81%ab%e3%83%8f%e3%83%9e%e3%81%a3%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.nukoneko.info\/blog\/?p=716","title":{"rendered":"Dagger2\u3092\u4f7f\u3046\u6642\u306b\u5fae\u5999\u306b\u30cf\u30de\u3063\u305f"},"content":{"rendered":"<p>Dagger \u3067\u81ea\u52d5\u751f\u6210\u3055\u308c\u308b\u306f\u305a\u306e\u30af\u30e9\u30b9\u304c\u306a\u3044\u3068\u3044\u3046\u554f\u984c\u306b\u906d\u9047\u3057\u305f\u3002<\/p>\n<p>\u52d5\u304f\u3082\u306e\u3092  <strong><a href=\"https:\/\/gist.github.com\/Atsumi3\/50f29a09408f4a98683f9f88289365fb\">Gist<\/a><\/strong> \u306b\u4e0a\u3052\u307e\u3057\u305f\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u74b0\u5883<\/h2>\n<ul>\n<li>IntelliJ IDEA 2018.1.5<\/li>\n<li>Gradle 4.4<\/li>\n<\/ul>\n<h2>\u8a73\u7d30<\/h2>\n<h3>\u4ee5\u4e0b\u306e <a href=\"https:\/\/github.com\/google\/dagger\">\u516c\u5f0f<\/a> \u306e\u8a18\u8ff0\u3092\u8a66\u3057\u3066\u3082\u52d5\u304b\u306a\u304b\u3063\u305f  (\u4f55\u304b\u81ea\u5206\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ Add plugin https:\/\/plugins.gradle.org\/plugin\/net.ltgt.apt\nplugins {\n  id net.ltgt.apt version 0.10\n}\n\n\/\/ Add Dagger dependencies\ndependencies {\n  compile com.google.dagger:dagger:2.x\n  apt com.google.dagger:dagger-compiler:2.x\n}\n<\/pre>\n<p>out\/production\/classes\/generated \u306b\u4f55\u3082\u306a\u3044\u306e\u3067\u3001<br \/>\n\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d7\u30ed\u30bb\u30c3\u30b5\u30fc\u304c\u3046\u307e\u304f\u52d5\u3044\u3066\u3044\u306a\u3044\u611f\u304c\u3042\u3063\u305f\u3002<\/p>\n<p>\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001 AnnotationProcessor \u304c\u7121\u52b9\u306b\u306a\u3063\u3066\u3044\u305f\u305f\u3081 \u6709\u52b9 \u306b\u3057\u305f\u3002<br \/>\n\u203b [Build, Execution, Deployment] -> [Compiler] -> [Annotation Processors]  -><br \/>\n Enable annotation processing \u3092\u6709\u52b9\u306b\u3002<\/p>\n<p><a href=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/572d7edd86d8c8e196f565e4e3666683.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/572d7edd86d8c8e196f565e4e3666683.png\" alt=\"\" width=\"970\" height=\"713\" class=\"aligncenter size-full wp-image-719\" srcset=\"https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/572d7edd86d8c8e196f565e4e3666683.png 970w, https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/572d7edd86d8c8e196f565e4e3666683-300x221.png 300w, https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/572d7edd86d8c8e196f565e4e3666683-768x565.png 768w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<p>&#8230;  \u304c\u89e3\u6c7a\u305b\u305a\u3002<\/p>\n<p>\u518d\u5ea6\u516c\u5f0f\u306eGitHub \u3092\u898b\u305f\u6240\u3001maven \u306e\u8a18\u8ff0 \u306edagger-compiler \u306b <strong><scope>provided<\/scope><\/strong> \u306e\u6307\u5b9a\u304c\u898b\u3064\u304b\u3063\u305f\u3002<\/p>\n<p>gradle \u306e\u8a18\u8ff0\u7684\u306b\u3082\u53e4\u3044\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u306b\u3057\u305f\u3089 <strong>\u52d5\u3044\u305f<\/strong><br \/>\n\u203b compileOnly \u306f provided \u306e\u65b0\u3057\u3044\u8a18\u8ff0\u65b9\u6cd5<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nplugins {\n    id java\n}\n\ndependencies {\n    implementation com.google.dagger:dagger:2.16\n    compileOnly com.google.dagger:dagger-compiler:2.16\n}\n\n<\/pre>\n<p>\u7121\u4e8b\u306b \u751f\u6210\u3055\u308c\u305f\u3002  &#8230;\u304c\u3002<\/p>\n<h3>Dagger \u306b\u3088\u308a\u4f5c\u3089\u308c\u305f\u30af\u30e9\u30b9\u304c\u53c2\u7167\u3067\u304d\u306a\u3044<\/h3>\n<p><a href=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/4de0719231ea2db1c387b1ae13b44513.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/4de0719231ea2db1c387b1ae13b44513.png\" alt=\"\" width=\"418\" height=\"357\" class=\"aligncenter size-full wp-image-721\" srcset=\"https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/4de0719231ea2db1c387b1ae13b44513.png 418w, https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/4de0719231ea2db1c387b1ae13b44513-300x256.png 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/a><\/p>\n<p>\u3053\u3061\u3089\u306f\u3001Annotation Processor \u306b\u3088\u308a\u4f5c\u3089\u308c\u308b\u30af\u30e9\u30b9\u306e\u51fa\u529b\u5148\u3092\u3001\u30bd\u30fc\u30b9\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306b \u5909\u66f4\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u89e3\u6c7a\u3057\u305f\u3002<br \/>\n\u203b \u753b\u50cf\u306e [Module content root] \u3092\u9078\u629e<\/p>\n<p><a href=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/0b46a0aab63e0559748d58a3f74800a7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/0b46a0aab63e0559748d58a3f74800a7.png\" alt=\"\" width=\"644\" height=\"347\" class=\"aligncenter size-full wp-image-722\" srcset=\"https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/0b46a0aab63e0559748d58a3f74800a7.png 644w, https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/0b46a0aab63e0559748d58a3f74800a7-300x162.png 300w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/f37c92c77948336694faa395efae8059.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/f37c92c77948336694faa395efae8059.png\" alt=\"\" width=\"420\" height=\"367\" class=\"aligncenter size-full wp-image-723\" srcset=\"https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/f37c92c77948336694faa395efae8059.png 420w, https:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/f37c92c77948336694faa395efae8059-300x262.png 300w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><\/a><\/p>\n<p>\u30de\u30fc\u30af\u3082\u5909\u3048\u307e\u3057\u3087\u3046\u3002<br \/>\n[generated \u53f3\u30af\u30ea\u30c3\u30af] -> [Mark Directory as] -> [Generated Source Root]<\/p>\n<p><a href=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/a9e98bdee562436e8ef839ac91e2269d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.nukoneko.info\/blog_d\/wp-content\/uploads\/2018\/06\/a9e98bdee562436e8ef839ac91e2269d.png\" alt=\"\" width=\"276\" height=\"186\" class=\"aligncenter size-full wp-image-726\" \/><\/a><\/p>\n<h1>\u6700\u5f8c\u306b<\/h1>\n<p>Dagger \u697d\u3057\u307f\u305f\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dagger \u3067\u81ea\u52d5\u751f\u6210\u3055\u308c\u308b\u306f\u305a\u306e\u30af\u30e9\u30b9\u304c\u306a\u3044\u3068\u3044\u3046\u554f\u984c\u306b\u906d\u9047\u3057\u305f\u3002 \u52d5\u304f\u3082\u306e\u3092 Gist \u306b\u4e0a\u3052\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,41,40,31,46,44],"tags":[],"class_list":["post-716","post","type-post","status-publish","format-standard","hentry","category-android-2","category-android-studio","category-editor","category-java","category-os","category-pl"],"_links":{"self":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=716"}],"version-history":[{"count":7,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/716\/revisions"}],"predecessor-version":[{"id":729,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/716\/revisions\/729"}],"wp:attachment":[{"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nukoneko.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}