{"id":3347,"date":"2014-09-18T00:33:28","date_gmt":"2014-09-17T15:33:28","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=3347"},"modified":"2025-03-12T11:28:44","modified_gmt":"2025-03-12T02:28:44","slug":"groovy%e3%82%84%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2014\/09\/18\/groovy%e3%82%84%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b%ef%bc%81\/","title":{"rendered":"Groovy\u3084\u3063\u3066\u307f\u308b\uff01"},"content":{"rendered":"<p>1.\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\nbrew\u3067\u3044\u308c\u308b\u3088\u308agvm\u304c\u6d41\u884c\u3068\u66f8\u3044\u3066\u3042\u3063\u305f\u306e\u3067\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre lang=\"shell\" line=\"1\">curl -s get.gvmtool.net | bash<\/pre>\n<p>\u3053\u308c\u3092\u8a2d\u5b9a\u3057\u306a\u3055\u3044\u3063\u3066\u66f8\u3044\u3066\u3042\u3063\u305f\u306e\u3067\u8a2d\u5b9a\u3059\u308b<\/p>\n<pre lang=\"shell\" line=\"1\">export GROOVY_HOME=\/usr\/local\/opt\/groovy\/libexec<\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b9f\u884c<\/p>\n<pre lang=\"shell\" line=\"1\">gvm install groovy<\/pre>\n<p>2.\u958b\u767a\u74b0\u5883<\/p>\n<p>Eclipse\u306bGroovy-Eclipse\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5165\u308c\u307e\u3059\u3002<\/p>\n<p>http:\/\/dist.springsource.org\/milestone\/GRECLIPSE\/e4.4\/<\/p>\n<p>3.\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3059\u308b\u3060\u3051\u306e\u30b3\u30fc\u30c9<\/p>\n<pre lang=\"groovy\">\r\npackage com.lancard.yuichi\r\n\r\nclass FileRead {\r\n\r\nstatic main(args) {\r\nnew File(args[0]).eachLine {\r\nprintln it\r\n}\r\n}\r\n\r\n}\r\n<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066try catch\u3067\u56f2\u3093\u3067finally\u3067close\u3055\u308c\u3066\u3063\u3066\u3044\u3046\u3002\u3059\u3054\u3044\u30fb\u30fb\u3002<br \/>\n\u300cit\u300d\u306f\u5404\u884c\u306e\u5185\u5bb9\u306e\u6697\u9ed9\u306e\u5909\u6570\u3089\u3057\u3044\u3002<\/p>\n<p>4.\u30af\u30ed\u30fc\u30b8\u30e3\u3082\u4f7f\u3048\u308b<\/p>\n<pre lang=\"groovy\">\r\npackage com.lancard.yuichi\r\n\r\nimport groovy.lang.Closure;\r\n\r\nclass Add {\r\n\r\nstatic main(args) {\r\nClosure add = add()\r\nadd.call()\/\/1\r\nadd.call()\/\/2\r\nadd.call()\/\/3\r\nadd.call()\/\/4\r\n}\r\n\r\nstatic Closure add(){\r\ndef x = 0\r\nClosure closure = {\r\nx++\r\nprintln x\r\n}\r\nclosure;\r\n}\r\n\r\n}\r\n<\/pre>\n<p>5.\u56de\u6570\u6307\u5b9a\u3067\u30af\u30ed\u30fc\u30b8\u30e3\u5b9f\u884c<\/p>\n<pre lang=\"groovy\">\r\npackage com.lancard.yuichi\r\n\r\nclass Times {\r\n\r\nstatic main(args) {\r\n3.times {\r\nprintln it\r\n}\r\n\/\/0 1 2\r\n}\r\n\r\n}\r\n<\/pre>\n<p>\u8272\u3005\u7c21\u5358\u3067\u9762\u767d\u3044\uff01<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F3347&#038;t=Groovy%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B%EF%BC%81&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F3347&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=Groovy%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B%EF%BC%81\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F3347&#038;text=Groovy%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B%EF%BC%81\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F3347&#038;title=Groovy%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B%EF%BC%81\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=Groovy%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B%EF%BC%81&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F3347\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Groovy%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%82%8B%EF%BC%81&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F3347\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>1.\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb brew\u3067\u3044\u308c\u308b\u3088\u308agvm\u304c\u6d41\u884c\u3068\u66f8\u3044\u3066\u3042\u3063\u305f\u306e\u3067\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb curl -s get.gvmtool.net | bash \u3053\u308c\u3092\u8a2d\u5b9a\u3057\u306a\u3055\u3044\u3063\u3066\u66f8\u3044\u3066\u3042\u3063\u305f\u306e\u3067\u8a2d\u5b9a\u3059\u308b export G [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-3347","post","type-post","status-publish","format-standard","hentry","category-groovy"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/3347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=3347"}],"version-history":[{"count":8,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/3347\/revisions"}],"predecessor-version":[{"id":3355,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/3347\/revisions\/3355"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=3347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=3347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=3347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}