
{"id":2257,"date":"2022-11-20T01:57:54","date_gmt":"2022-11-19T17:57:54","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=2257"},"modified":"2022-11-21T08:39:07","modified_gmt":"2022-11-21T00:39:07","slug":"%e4%bd%bf%e7%94%a8-gradle-%e6%9e%84%e5%bb%ba-java-%e5%a4%9a%e6%a8%a1%e5%9d%97%e9%a1%b9%e7%9b%ae%ef%bc%88%e4%be%8b%e5%9b%9b%ef%bc%89","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=2257","title":{"rendered":"\u4f7f\u7528 Gradle \u6784\u5efa Java \u591a\u6a21\u5757\u9879\u76ee\uff08\u4f8b\u56db\uff09"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-6a02180899313\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a02180899313\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#1_%E7%A4%BA%E4%BE%8B1%EF%BC%9A%E5%90%84%E5%AD%90%E9%A1%B9%E7%9B%AE%E5%8D%95%E7%8B%AC%E9%85%8D%E7%BD%AE\" >1. \u793a\u4f8b1\uff1a\u5404\u5b50\u9879\u76ee\u5355\u72ec\u914d\u7f6e<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#11_%E5%88%9B%E5%BB%BA%E4%B8%BB%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95\" >1.1. \u521b\u5efa\u4e3b\u9879\u76ee\u76ee\u5f55<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#12_%E8%BF%9B%E5%85%A5%E4%B8%BB%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95\" >1.2.  \u8fdb\u5165\u4e3b\u9879\u76ee\u76ee\u5f55<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#13_%E5%88%9B%E5%BB%BA_settingsgradle_%E4%B8%8E_buildgradle%E6%96%87%E4%BB%B6\" >1.3. \u521b\u5efa settings.gradle \u4e0e build.gradle\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#14_%E8%BF%90%E8%A1%8C_gradle_wrapper_%E5%91%BD%E4%BB%A4\" >1.4. \u8fd0\u884c gradle wrapper \u547d\u4ee4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#15_%E5%88%9B%E5%BB%BA%E5%AD%90%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95\" >1.5. \u521b\u5efa\u5b50\u9879\u76ee\u76ee\u5f55<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#16_%E5%AD%90%E9%A1%B9%E7%9B%AEchild1%E7%9A%84%E9%85%8D%E7%BD%AE\" >1.6. \u5b50\u9879\u76eechild1\u7684\u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#17_%E5%AD%90%E9%A1%B9%E7%9B%AEchild2%E7%9A%84%E9%85%8D%E7%BD%AE\" >1.7. \u5b50\u9879\u76eechild2\u7684\u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#18_%E4%B8%BB%E9%A1%B9%E7%9B%AE_settingsgradle_%E9%85%8D%E7%BD%AE\" >1.8. \u4e3b\u9879\u76ee settings.gradle \u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#19_%E6%9C%80%E7%BB%88%E7%9A%84%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B\" >1.9. \u6700\u7ec8\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#110_%E6%9F%A5%E7%9C%8B%E4%BB%BB%E5%8A%A1%E4%BB%A5%E5%8F%8A%E6%89%A7%E8%A1%8Crun%E4%BB%BB%E5%8A%A1\" >1.10. \u67e5\u770b\u4efb\u52a1\u4ee5\u53ca\u6267\u884crun\u4efb\u52a1<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#2_%E7%A4%BA%E4%BE%8B2%EF%BC%9A%E9%9B%86%E4%B8%AD%E9%85%8D%E7%BD%AE%E5%AD%90%E9%A1%B9%E7%9B%AE\" >2. \u793a\u4f8b2\uff1a\u96c6\u4e2d\u914d\u7f6e\u5b50\u9879\u76ee<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#21_%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B\" >2.1. \u9879\u76ee\u7ed3\u6784\u5982\u4e0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#22_%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84_settingsgradle_%E5%86%85%E5%AE%B9\" >2.2. \u6839\u76ee\u5f55\u4e0b\u7684 settings.gradle \u5185\u5bb9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#23_%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84_buildgradle_%E5%86%85%E5%AE%B9\" >2.3. \u6839\u76ee\u5f55\u4e0b\u7684 build.gradle \u5185\u5bb9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#24_%E6%89%A7%E8%A1%8C_gradlew_build_%E4%B8%8E_gradlew_run_%E5%91%BD%E4%BB%A4\" >2.4. \u6267\u884c gradlew build \u4e0e gradlew run \u547d\u4ee4<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#3_%E7%A4%BA%E4%BE%8B3%EF%BC%9A%E5%90%8C%E6%97%B6%E9%85%8D%E7%BD%AE%E5%AD%90%E9%A1%B9%E7%9B%AE%E5%92%8C%E6%A0%B9%E9%A1%B9%E7%9B%AE\" >3. \u793a\u4f8b3\uff1a\u540c\u65f6\u914d\u7f6e\u5b50\u9879\u76ee\u548c\u6839\u9879\u76ee<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#31_%E5%9C%A8%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E5%A2%9E%E5%8A%A0%E4%BA%86_src_%E7%9B%AE%E5%BD%95%EF%BC%8C%E4%BD%9C%E4%B8%BA%E6%A0%B9%E9%A1%B9%E7%9B%AE%E7%9A%84%E5%86%85%E5%AE%B9\" >3.1. \u5728\u6839\u76ee\u5f55\u4e0b\u589e\u52a0\u4e86 src \u76ee\u5f55\uff0c\u4f5c\u4e3a\u6839\u9879\u76ee\u7684\u5185\u5bb9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#32_%E5%9C%A8%E4%B8%BB%E9%A1%B9%E7%9B%AE%E4%B8%AD%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAjava%E7%B1%BB\" >3.2. \u5728\u4e3b\u9879\u76ee\u4e2d\u521b\u5efa\u4e00\u4e2ajava\u7c7b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#33_%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B\" >3.3. \u9879\u76ee\u7ed3\u6784\u5982\u4e0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#34_%E4%B8%BB%E9%A1%B9%E7%9B%AE%E4%B8%8B%E7%9A%84_settingsgradle_%E5%86%85%E5%AE%B9\" >3.4. \u4e3b\u9879\u76ee\u4e0b\u7684 settings.gradle \u5185\u5bb9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#35_%E4%B8%BB%E9%A1%B9%E7%9B%AE%E4%B8%8B%E7%9A%84_buildgradle_%E5%86%85%E5%AE%B9\" >3.5. \u4e3b\u9879\u76ee\u4e0b\u7684 build.gradle \u5185\u5bb9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#36_%E8%BF%90%E8%A1%8C_gradlew_tasks_%E5%91%BD%E4%BB%A4\" >3.6 \u8fd0\u884c gradlew tasks \u547d\u4ee4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#37_%E6%89%A7%E8%A1%8C_gradlew_build_%E4%B8%8E_gradlew_run_%E5%91%BD%E4%BB%A4\" >3.7. \u6267\u884c gradlew build \u4e0e gradlew run \u547d\u4ee4<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#%E9%99%84%E5%BD%95\" >\u9644\u5f55<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#%E9%99%84%E5%BD%95A_%E7%9B%B8%E5%85%B3%E8%81%94%E7%9A%84%E6%96%87%E7%AB%A0\" >\u9644\u5f55A. \u76f8\u5173\u8054\u7684\u6587\u7ae0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"http:\/\/dba.qishuo.xin\/?p=2257\/#%E9%99%84%E5%BD%95B_%E5%8F%82%E8%80%83\" >\u9644\u5f55B. \u53c2\u8003<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<p><strong>\u73af\u5883\u63cf\u8ff0<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u63cf\u8ff0\u9879<\/th>\n<th style=\"text-align: left;\">\u5185\u5bb9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">\u64cd\u4f5c\u7cfb\u7edf<\/td>\n<td style=\"text-align: left;\">CentOS Linux release 7.8.2003 (Core)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">java\u7248\u672c<\/td>\n<td style=\"text-align: left;\">java version &quot;1.8.0_161&quot;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">IDEA\u7248\u672c<\/td>\n<td style=\"text-align: left;\">2022.2.2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">Gradle\u7248\u672c<\/td>\n<td style=\"text-align: left;\">7.5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span class=\"ez-toc-section\" id=\"1_%E7%A4%BA%E4%BE%8B1%EF%BC%9A%E5%90%84%E5%AD%90%E9%A1%B9%E7%9B%AE%E5%8D%95%E7%8B%AC%E9%85%8D%E7%BD%AE\"><\/span>1. \u793a\u4f8b1\uff1a\u5404\u5b50\u9879\u76ee\u5355\u72ec\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"11_%E5%88%9B%E5%BB%BA%E4%B8%BB%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95\"><\/span>1.1. \u521b\u5efa\u4e3b\u9879\u76ee\u76ee\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">mkdir multiModule<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"12_%E8%BF%9B%E5%85%A5%E4%B8%BB%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95\"><\/span>1.2.  \u8fdb\u5165\u4e3b\u9879\u76ee\u76ee\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">cd multiModule<\/code><\/pre>\n<p><span style='color:red'>\u4ee5\u4e0b\u64cd\u4f5c\u5747\u5728\u8be5\u76ee\u5f55\u4e0b\u5b8c\u6210\u3002<\/span><\/p>\n<h4><span class=\"ez-toc-section\" id=\"13_%E5%88%9B%E5%BB%BA_settingsgradle_%E4%B8%8E_buildgradle%E6%96%87%E4%BB%B6\"><\/span>1.3. \u521b\u5efa settings.gradle \u4e0e build.gradle\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">touch .\/settings.gradle\ntouch .\/build.gradle<\/code><\/pre>\n<p><strong><span style='color:purple'>\u5176\u4e2d build.gradle \u6587\u4ef6\u5185\u5bb9\u4e3a\u7a7a\u3002<\/span><\/strong><\/p>\n<h4><span class=\"ez-toc-section\" id=\"14_%E8%BF%90%E8%A1%8C_gradle_wrapper_%E5%91%BD%E4%BB%A4\"><\/span>1.4. \u8fd0\u884c gradle wrapper \u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">gradle wrapper<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"15_%E5%88%9B%E5%BB%BA%E5%AD%90%E9%A1%B9%E7%9B%AE%E7%9B%AE%E5%BD%95\"><\/span>1.5. \u521b\u5efa\u5b50\u9879\u76ee\u76ee\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\"># \u521b\u5efa\u5b50\u9879\u76ee child1\nmkdir -p .\/child1\/src\/main\/java\/xin\/qishuo\/child1\/\n# \u521b\u5efa\u5b50\u9879\u76ee child2\nmkdir -p .\/child2\/src\/main\/java\/xin\/qishuo\/child2\/<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"16_%E5%AD%90%E9%A1%B9%E7%9B%AEchild1%E7%9A%84%E9%85%8D%E7%BD%AE\"><\/span>1.6. \u5b50\u9879\u76eechild1\u7684\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>1\uff09\u521b\u5efa\u4e00\u4e2ajava\u7c7b<\/p>\n<pre><code class=\"language-shell\">vim .\/child1\/src\/main\/java\/xin\/qishuo\/child1\/Calculate.java<\/code><\/pre>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u5185\u5bb9\u5982\u4e0b<\/font><\/summary>\n<pre><code class=\"language-cpp\">\npackage xin.qishuo.child1;\n\npublic class Calculate {\n\n    public static int add(int a, int b) {\n        return a+b;\n    }\n\n}\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<p>2\uff09\u521b\u5efa <code>build.gradle<\/code> \u6587\u4ef6<\/p>\n<pre><code class=\"language-shell\">vim .\/child1\/build.gradle<\/code><\/pre>\n<p>\u5176\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">plugins {\n  id &#039;java&#039;\n}\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    \/\/ Use JUnit Jupiter for testing. junit\u6d4b\u8bd5\u5305\n    testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n}<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"17_%E5%AD%90%E9%A1%B9%E7%9B%AEchild2%E7%9A%84%E9%85%8D%E7%BD%AE\"><\/span>1.7. \u5b50\u9879\u76eechild2\u7684\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>1\uff09\u521b\u5efa\u4e00\u4e2ajava\u7c7b<\/p>\n<pre><code class=\"language-shell\">vim .\/child2\/src\/main\/java\/xin\/qishuo\/child2\/CalculateService.java<\/code><\/pre>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u5185\u5bb9\u5982\u4e0b<\/font><\/summary>\n<pre><code class=\"language-cpp\">\npackage xin.qishuo.child2;\n\nimport xin.qishuo.child1.Calculate; \/\/ \u6ce8\u610f\uff0c\u8fd9\u4e2a\u662f child1 \u4e2d\u7684\u7c7b\n\npublic class CalculateService {\n\n    public static void main(String[] args) {\n        int result = Calculate.add(1, 2);\n        System.out.println(result);\n    }\n\n}\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<p>2\uff09\u521b\u5efa <code>build.gradle<\/code> \u6587\u4ef6<\/p>\n<pre><code class=\"language-shell\">vim .\/child2\/build.gradle<\/code><\/pre>\n<p>\u5176\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">plugins {\n  id &#039;java&#039;\n  id &#039;application&#039;\n}\n\nrepositories {\n  mavenCentral()\n}\n\napplication {\n  mainClass = &#039;xin.qishuo.child2.CalculateService&#039;\n}\n\ndependencies {\n    \/\/ \u58f0\u660e child2 \u5bf9 child1 \u7684\u4f9d\u8d56\n    implementation project(&#039;:child1&#039;)\n    \/\/ Use JUnit Jupiter for testing. junit\u6d4b\u8bd5\u5305\n    testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n}<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"18_%E4%B8%BB%E9%A1%B9%E7%9B%AE_settingsgradle_%E9%85%8D%E7%BD%AE\"><\/span>1.8. \u4e3b\u9879\u76ee settings.gradle \u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">vim .\/settings.gradle<\/code><\/pre>\n<p>\u5176\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">rootProject.name = &#039;multiModule&#039;\ninclude &#039;child1&#039;\ninclude &#039;child2&#039;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"19_%E6%9C%80%E7%BB%88%E7%9A%84%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B\"><\/span>1.9. \u6700\u7ec8\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u9879\u76ee\u76ee\u5f55\u7ed3\u6784<\/font><\/summary>\n<pre><code class=\"language-cpp\">\n.\n\u251c\u2500\u2500 build.gradle\n\u251c\u2500\u2500 child1\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 build.gradle\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 main\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 java\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 xin\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 qishuo\n\u2502\u00a0\u00a0                     \u2514\u2500\u2500 child1\n\u2502\u00a0\u00a0                         \u2514\u2500\u2500 Calculate.java\n\u251c\u2500\u2500 child2\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 build.gradle\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 main\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 java\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 xin\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 qishuo\n\u2502\u00a0\u00a0                     \u2514\u2500\u2500 child2\n\u2502\u00a0\u00a0                         \u2514\u2500\u2500 CalculateService.java\n\u251c\u2500\u2500 gradle\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 wrapper\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 gradle-wrapper.jar\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 gradle-wrapper.properties\n\u251c\u2500\u2500 gradle.properties\n\u251c\u2500\u2500 gradlew\n\u251c\u2500\u2500 gradlew.bat\n\u2514\u2500\u2500 settings.gradle\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<h4><span class=\"ez-toc-section\" id=\"110_%E6%9F%A5%E7%9C%8B%E4%BB%BB%E5%8A%A1%E4%BB%A5%E5%8F%8A%E6%89%A7%E8%A1%8Crun%E4%BB%BB%E5%8A%A1\"><\/span>1.10. \u67e5\u770b\u4efb\u52a1\u4ee5\u53ca\u6267\u884crun\u4efb\u52a1<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">.\/gradlew tasks --all<\/code><\/pre>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u8be6\u7ec6\u5185\u5bb9<\/font><\/summary>\n<pre><code class=\"language-cpp\">\n[java@etdbmysql multiModule]$ .\/gradlew tasks --all\n\n> Task :tasks\n\n------------------------------------------------------------\nTasks runnable from root project 'multiModule'\n------------------------------------------------------------\n\nApplication tasks\n-----------------\nchild2:run - Runs this project as a JVM application\n\nBuild tasks\n-----------\nchild1:assemble - Assembles the outputs of this project.\nchild2:assemble - Assembles the outputs of this project.\nchild1:build - Assembles and tests this project.\nchild2:build - Assembles and tests this project.\nchild1:buildDependents - Assembles and tests this project and all projects that depend on it.\nchild2:buildDependents - Assembles and tests this project and all projects that depend on it.\nchild1:buildNeeded - Assembles and tests this project and all projects it depends on.\nchild2:buildNeeded - Assembles and tests this project and all projects it depends on.\nchild1:classes - Assembles main classes.\nchild2:classes - Assembles main classes.\nchild1:clean - Deletes the build directory.\nchild2:clean - Deletes the build directory.\nchild1:jar - Assembles a jar archive containing the main classes.\nchild2:jar - Assembles a jar archive containing the main classes.\nchild1:testClasses - Assembles test classes.\nchild2:testClasses - Assembles test classes.\n\nBuild Setup tasks\n-----------------\ninit - Initializes a new Gradle build.\nwrapper - Generates Gradle wrapper files.\n\nDistribution tasks\n------------------\nchild2:assembleDist - Assembles the main distributions\nchild2:distTar - Bundles the project as a distribution.\nchild2:distZip - Bundles the project as a distribution.\nchild2:installDist - Installs the project as a distribution as-is.\n\nDocumentation tasks\n-------------------\nchild1:javadoc - Generates Javadoc API documentation for the main source code.\nchild2:javadoc - Generates Javadoc API documentation for the main source code.\n\nHelp tasks\n----------\nbuildEnvironment - Displays all buildscript dependencies declared in root project 'multiModule'.\nchild1:buildEnvironment - Displays all buildscript dependencies declared in project ':child1'.\nchild2:buildEnvironment - Displays all buildscript dependencies declared in project ':child2'.\ndependencies - Displays all dependencies declared in root project 'multiModule'.\nchild1:dependencies - Displays all dependencies declared in project ':child1'.\nchild2:dependencies - Displays all dependencies declared in project ':child2'.\ndependencyInsight - Displays the insight into a specific dependency in root project 'multiModule'.\nchild1:dependencyInsight - Displays the insight into a specific dependency in project ':child1'.\nchild2:dependencyInsight - Displays the insight into a specific dependency in project ':child2'.\nhelp - Displays a help message.\nchild1:help - Displays a help message.\nchild2:help - Displays a help message.\njavaToolchains - Displays the detected java toolchains.\nchild1:javaToolchains - Displays the detected java toolchains.\nchild2:javaToolchains - Displays the detected java toolchains.\noutgoingVariants - Displays the outgoing variants of root project 'multiModule'.\nchild1:outgoingVariants - Displays the outgoing variants of project ':child1'.\nchild2:outgoingVariants - Displays the outgoing variants of project ':child2'.\nprojects - Displays the sub-projects of root project 'multiModule'.\nchild1:projects - Displays the sub-projects of project ':child1'.\nchild2:projects - Displays the sub-projects of project ':child2'.\nproperties - Displays the properties of root project 'multiModule'.\nchild1:properties - Displays the properties of project ':child1'.\nchild2:properties - Displays the properties of project ':child2'.\nresolvableConfigurations - Displays the configurations that can be resolved in root project 'multiModule'.\nchild1:resolvableConfigurations - Displays the configurations that can be resolved in project ':child1'.\nchild2:resolvableConfigurations - Displays the configurations that can be resolved in project ':child2'.\ntasks - Displays the tasks runnable from root project 'multiModule' (some of the displayed tasks may belong to subprojects).\nchild1:tasks - Displays the tasks runnable from project ':child1'.\nchild2:tasks - Displays the tasks runnable from project ':child2'.\n\nVerification tasks\n------------------\nchild1:check - Runs all checks.\nchild2:check - Runs all checks.\nchild1:test - Runs the test suite.\nchild2:test - Runs the test suite.\n\nOther tasks\n-----------\nchild1:compileJava - Compiles main Java source.\nchild2:compileJava - Compiles main Java source.\nchild1:compileTestJava - Compiles test Java source.\nchild2:compileTestJava - Compiles test Java source.\ncomponents - Displays the components produced by root project 'multiModule'. [deprecated]\nchild1:components - Displays the components produced by project ':child1'. [deprecated]\nchild2:components - Displays the components produced by project ':child2'. [deprecated]\ndependentComponents - Displays the dependent components of components in root project 'multiModule'. [deprecated]\nchild1:dependentComponents - Displays the dependent components of components in project ':child1'. [deprecated]\nchild2:dependentComponents - Displays the dependent components of components in project ':child2'. [deprecated]\nmodel - Displays the configuration model of root project 'multiModule'. [deprecated]\nchild1:model - Displays the configuration model of project ':child1'. [deprecated]\nchild2:model - Displays the configuration model of project ':child2'. [deprecated]\nprepareKotlinBuildScriptModel\nchild1:processResources - Processes main resources.\nchild2:processResources - Processes main resources.\nchild1:processTestResources - Processes test resources.\nchild2:processTestResources - Processes test resources.\nchild2:startScripts - Creates OS specific scripts to run the project as a JVM application.\n\nBUILD SUCCESSFUL in 655ms\n1 actionable task: 1 executed\n<\/code>\n<\/pre>\n<\/details>\n<pre><code class=\"language-shell\">.\/gradlew run<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2022\/11\/image-1668875955739.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2022\/11\/image-1668875955739.png\" alt=\"file\" \/><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_%E7%A4%BA%E4%BE%8B2%EF%BC%9A%E9%9B%86%E4%B8%AD%E9%85%8D%E7%BD%AE%E5%AD%90%E9%A1%B9%E7%9B%AE\"><\/span>2. \u793a\u4f8b2\uff1a\u96c6\u4e2d\u914d\u7f6e\u5b50\u9879\u76ee<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style='color:red'>\u4f7f\u7528\u793a\u4f8b1\u4e2d <code>1.1. ~ 1.7<\/code> \u7684\u914d\u7f6e\uff0c\u4f46\u662f child1 \u548c child2 \u4e2d\u6ca1\u6709 build.gradle \u6587\u4ef6\u3002<\/span><\/p>\n<h4><span class=\"ez-toc-section\" id=\"21_%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B\"><\/span>2.1. \u9879\u76ee\u7ed3\u6784\u5982\u4e0b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u9879\u76ee\u76ee\u5f55\u7ed3\u6784<\/font><\/summary>\n<pre><code class=\"language-cpp\">\n.\n\u251c\u2500\u2500 build.gradle\n\u251c\u2500\u2500 child1\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 main\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 java\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 xin\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 qishuo\n\u2502\u00a0\u00a0                     \u2514\u2500\u2500 child1\n\u2502\u00a0\u00a0                         \u2514\u2500\u2500 Calculate.java\n\u251c\u2500\u2500 child2\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 main\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 java\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 xin\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 qishuo\n\u2502\u00a0\u00a0                     \u2514\u2500\u2500 child2\n\u2502\u00a0\u00a0                         \u2514\u2500\u2500 CalculateService.java\n\u251c\u2500\u2500 gradle\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 wrapper\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 gradle-wrapper.jar\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 gradle-wrapper.properties\n\u251c\u2500\u2500 gradlew\n\u251c\u2500\u2500 gradlew.bat\n\u2514\u2500\u2500 settings.gradle\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<h4><span class=\"ez-toc-section\" id=\"22_%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84_settingsgradle_%E5%86%85%E5%AE%B9\"><\/span>2.2. \u6839\u76ee\u5f55\u4e0b\u7684 settings.gradle \u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">rootProject.name = &#039;multiModule&#039;\ninclude &#039;child1&#039;\ninclude &#039;child2&#039;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"23_%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84_buildgradle_%E5%86%85%E5%AE%B9\"><\/span>2.3. \u6839\u76ee\u5f55\u4e0b\u7684 build.gradle \u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">subprojects { \/\/ \u7ed9\u6240\u6709\u7684\u5b50\u9879\u76ee\u8fdb\u884c\u914d\u7f6e\n  apply plugin: &#039;java&#039;\n\n  repositories {\n    mavenCentral()\n  }\n}\n\n\/\/ \u914d\u7f6e child1 \u5b50\u9879\u76ee\nproject(&quot;:child1&quot;) {\n  dependencies {\n    testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n  }\n}\n\n\/\/ \u914d\u7f6e child2 \u5b50\u9879\u76ee\nproject(&quot;:child2&quot;) {\n  apply plugin: &#039;application&#039;\n\n  dependencies {\n     implementation project(&#039;:child1&#039;) \/\/ \u58f0\u660e\u5bf9 child1 \u7684\u4f9d\u8d56\n     testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n  }\n\n  application {\n    mainClass = &#039;xin.qishuo.child2.CalculateService&#039;\n  }\n}<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"24_%E6%89%A7%E8%A1%8C_gradlew_build_%E4%B8%8E_gradlew_run_%E5%91%BD%E4%BB%A4\"><\/span>2.4. \u6267\u884c gradlew build \u4e0e gradlew run \u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2022\/11\/image-1668878775433.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2022\/11\/image-1668878775433.png\" alt=\"file\" \/><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_%E7%A4%BA%E4%BE%8B3%EF%BC%9A%E5%90%8C%E6%97%B6%E9%85%8D%E7%BD%AE%E5%AD%90%E9%A1%B9%E7%9B%AE%E5%92%8C%E6%A0%B9%E9%A1%B9%E7%9B%AE\"><\/span>3. \u793a\u4f8b3\uff1a\u540c\u65f6\u914d\u7f6e\u5b50\u9879\u76ee\u548c\u6839\u9879\u76ee<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style='color:red'>\u4f7f\u7528\u793a\u4f8b1\u4e2d <code>1.1. ~ 1.7<\/code> \u7684\u914d\u7f6e\uff0c\u4f46\u662f child1 \u548c child2 \u4e2d\u6ca1\u6709 build.gradle \u6587\u4ef6\u3002<\/span><\/p>\n<h4><span class=\"ez-toc-section\" id=\"31_%E5%9C%A8%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E5%A2%9E%E5%8A%A0%E4%BA%86_src_%E7%9B%AE%E5%BD%95%EF%BC%8C%E4%BD%9C%E4%B8%BA%E6%A0%B9%E9%A1%B9%E7%9B%AE%E7%9A%84%E5%86%85%E5%AE%B9\"><\/span>3.1. \u5728\u6839\u76ee\u5f55\u4e0b\u589e\u52a0\u4e86 src \u76ee\u5f55\uff0c\u4f5c\u4e3a\u6839\u9879\u76ee\u7684\u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">mkdir -p .\/src\/main\/java\/xin\/qishuo\/<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"32_%E5%9C%A8%E4%B8%BB%E9%A1%B9%E7%9B%AE%E4%B8%AD%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAjava%E7%B1%BB\"><\/span>3.2. \u5728\u4e3b\u9879\u76ee\u4e2d\u521b\u5efa\u4e00\u4e2ajava\u7c7b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">vim .\/src\/main\/java\/xin\/qishuo\/Main.java<\/code><\/pre>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u5185\u5bb9\u5982\u4e0b<\/font><\/summary>\n<pre><code class=\"language-cpp\">\npackage xin.qishuo;\n\nimport xin.qishuo.child1.Calculate; \/\/ \u8fd9\u662f child1 \u9879\u76ee\u4e2d\u7684\u7c7b\n\npublic class Main {\n\n    public static void main(String[] args) {\n        int result = Calculate.add(2, 2);\n        System.out.println(result);\n    }\n}\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<h4><span class=\"ez-toc-section\" id=\"33_%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B\"><\/span>3.3. \u9879\u76ee\u7ed3\u6784\u5982\u4e0b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<details>\n<summary><font size=\"2\" color=\"orange\">\u9879\u76ee\u76ee\u5f55\u7ed3\u6784<\/font><\/summary>\n<pre><code class=\"language-cpp\">\n.\n\u251c\u2500\u2500 build.gradle\n\u251c\u2500\u2500 child1\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 main\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 java\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 xin\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 qishuo\n\u2502\u00a0\u00a0                     \u2514\u2500\u2500 child1\n\u2502\u00a0\u00a0                         \u2514\u2500\u2500 Calculate.java\n\u251c\u2500\u2500 child2\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 src\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 main\n\u2502\u00a0\u00a0         \u2514\u2500\u2500 java\n\u2502\u00a0\u00a0             \u2514\u2500\u2500 xin\n\u2502\u00a0\u00a0                 \u2514\u2500\u2500 qishuo\n\u2502\u00a0\u00a0                     \u2514\u2500\u2500 child2\n\u2502\u00a0\u00a0                         \u2514\u2500\u2500 CalculateService.java\n\u251c\u2500\u2500 gradle\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 wrapper\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 gradle-wrapper.jar\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 gradle-wrapper.properties\n\u251c\u2500\u2500 gradle.properties\n\u251c\u2500\u2500 gradlew\n\u251c\u2500\u2500 gradlew.bat\n\u251c\u2500\u2500 settings.gradle\n\u2514\u2500\u2500 src\n    \u2514\u2500\u2500 main\n        \u2514\u2500\u2500 java\n            \u2514\u2500\u2500 xin\n                \u2514\u2500\u2500 qishuo\n                    \u2514\u2500\u2500 Main.java\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<h4><span class=\"ez-toc-section\" id=\"34_%E4%B8%BB%E9%A1%B9%E7%9B%AE%E4%B8%8B%E7%9A%84_settingsgradle_%E5%86%85%E5%AE%B9\"><\/span>3.4. \u4e3b\u9879\u76ee\u4e0b\u7684 settings.gradle \u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">rootProject.name = &#039;multiModule&#039;\ninclude &#039;child1&#039;\ninclude &#039;child2&#039;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"35_%E4%B8%BB%E9%A1%B9%E7%9B%AE%E4%B8%8B%E7%9A%84_buildgradle_%E5%86%85%E5%AE%B9\"><\/span>3.5. \u4e3b\u9879\u76ee\u4e0b\u7684 build.gradle \u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">apply plugin: &#039;java&#039;\napply plugin: &#039;application&#039;\n\nsubprojects { \/\/ \u7ed9\u6240\u6709\u7684\u5b50\u9879\u76ee\u8fdb\u884c\u914d\u7f6e\n  apply plugin: &#039;java&#039;\n\n  repositories {\n    mavenCentral()\n  }\n}\n\n\/\/ \u914d\u7f6e child1 \u5b50\u9879\u76ee\nproject(&quot;:child1&quot;) {\n  dependencies {\n    testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n  }\n}\n\n\/\/ \u914d\u7f6e child2 \u5b50\u9879\u76ee\nproject(&quot;:child2&quot;) {\n  apply plugin: &#039;application&#039;\n\n  dependencies {\n     implementation project(&#039;:child1&#039;) \/\/ \u58f0\u660e\u5bf9 child1 \u7684\u4f9d\u8d56\n     testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n  }\n\n  application {\n    mainClass = &#039;xin.qishuo.child2.CalculateService&#039;\n  }\n}\n\n\/\/ \u914d\u7f6e\u6839\u9879\u76ee(rootProject)\ndependencies {\n  implementation project(&#039;:child1&#039;) \/\/ \u58f0\u660e\u5bf9 child1 \u7684\u4f9d\u8d56\n  testImplementation &#039;org.junit.jupiter:junit-jupiter:5.9.1&#039;\n}\n\napplication {\n    mainClass = &#039;xin.qishuo.Main&#039;\n}<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"36_%E8%BF%90%E8%A1%8C_gradlew_tasks_%E5%91%BD%E4%BB%A4\"><\/span>3.6 \u8fd0\u884c gradlew tasks \u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-shell\">.\/gradlew tasks --all<\/code><\/pre>\n<details>\n<summary><font size=\"2\" color=\"orange\">Task\u8be6\u7ec6\u5185\u5bb9<\/font><\/summary>\n<pre><code class=\"language-cpp\">\n> Task :tasks\n\n------------------------------------------------------------\nTasks runnable from root project 'multiModule'\n------------------------------------------------------------\n\nApplication tasks\n-----------------\nrun - Runs this project as a JVM application\nchild2:run - Runs this project as a JVM application\n\nBuild tasks\n-----------\nassemble - Assembles the outputs of this project.\nchild1:assemble - Assembles the outputs of this project.\nchild2:assemble - Assembles the outputs of this project.\nbuild - Assembles and tests this project.\nchild1:build - Assembles and tests this project.\nchild2:build - Assembles and tests this project.\nbuildDependents - Assembles and tests this project and all projects that depend on it.\nchild1:buildDependents - Assembles and tests this project and all projects that depend on it.\nchild2:buildDependents - Assembles and tests this project and all projects that depend on it.\nbuildNeeded - Assembles and tests this project and all projects it depends on.\nchild1:buildNeeded - Assembles and tests this project and all projects it depends on.\nchild2:buildNeeded - Assembles and tests this project and all projects it depends on.\nclasses - Assembles main classes.\nchild1:classes - Assembles main classes.\nchild2:classes - Assembles main classes.\nclean - Deletes the build directory.\nchild1:clean - Deletes the build directory.\nchild2:clean - Deletes the build directory.\njar - Assembles a jar archive containing the main classes.\nchild1:jar - Assembles a jar archive containing the main classes.\nchild2:jar - Assembles a jar archive containing the main classes.\ntestClasses - Assembles test classes.\nchild1:testClasses - Assembles test classes.\nchild2:testClasses - Assembles test classes.\n\nBuild Setup tasks\n-----------------\ninit - Initializes a new Gradle build.\nwrapper - Generates Gradle wrapper files.\n\nDistribution tasks\n------------------\nassembleDist - Assembles the main distributions\nchild2:assembleDist - Assembles the main distributions\ndistTar - Bundles the project as a distribution.\nchild2:distTar - Bundles the project as a distribution.\ndistZip - Bundles the project as a distribution.\nchild2:distZip - Bundles the project as a distribution.\ninstallDist - Installs the project as a distribution as-is.\nchild2:installDist - Installs the project as a distribution as-is.\n\nDocumentation tasks\n-------------------\njavadoc - Generates Javadoc API documentation for the main source code.\nchild1:javadoc - Generates Javadoc API documentation for the main source code.\nchild2:javadoc - Generates Javadoc API documentation for the main source code.\n\nHelp tasks\n----------\nbuildEnvironment - Displays all buildscript dependencies declared in root project 'multiModule'.\nchild1:buildEnvironment - Displays all buildscript dependencies declared in project ':child1'.\nchild2:buildEnvironment - Displays all buildscript dependencies declared in project ':child2'.\ndependencies - Displays all dependencies declared in root project 'multiModule'.\nchild1:dependencies - Displays all dependencies declared in project ':child1'.\nchild2:dependencies - Displays all dependencies declared in project ':child2'.\ndependencyInsight - Displays the insight into a specific dependency in root project 'multiModule'.\nchild1:dependencyInsight - Displays the insight into a specific dependency in project ':child1'.\nchild2:dependencyInsight - Displays the insight into a specific dependency in project ':child2'.\nhelp - Displays a help message.\nchild1:help - Displays a help message.\nchild2:help - Displays a help message.\njavaToolchains - Displays the detected java toolchains.\nchild1:javaToolchains - Displays the detected java toolchains.\nchild2:javaToolchains - Displays the detected java toolchains.\noutgoingVariants - Displays the outgoing variants of root project 'multiModule'.\nchild1:outgoingVariants - Displays the outgoing variants of project ':child1'.\nchild2:outgoingVariants - Displays the outgoing variants of project ':child2'.\nprojects - Displays the sub-projects of root project 'multiModule'.\nchild1:projects - Displays the sub-projects of project ':child1'.\nchild2:projects - Displays the sub-projects of project ':child2'.\nproperties - Displays the properties of root project 'multiModule'.\nchild1:properties - Displays the properties of project ':child1'.\nchild2:properties - Displays the properties of project ':child2'.\nresolvableConfigurations - Displays the configurations that can be resolved in root project 'multiModule'.\nchild1:resolvableConfigurations - Displays the configurations that can be resolved in project ':child1'.\nchild2:resolvableConfigurations - Displays the configurations that can be resolved in project ':child2'.\ntasks - Displays the tasks runnable from root project 'multiModule' (some of the displayed tasks may belong to subprojects).\nchild1:tasks - Displays the tasks runnable from project ':child1'.\nchild2:tasks - Displays the tasks runnable from project ':child2'.\n\nVerification tasks\n------------------\ncheck - Runs all checks.\nchild1:check - Runs all checks.\nchild2:check - Runs all checks.\ntest - Runs the test suite.\nchild1:test - Runs the test suite.\nchild2:test - Runs the test suite.\n\nOther tasks\n-----------\ncompileJava - Compiles main Java source.\nchild1:compileJava - Compiles main Java source.\nchild2:compileJava - Compiles main Java source.\ncompileTestJava - Compiles test Java source.\nchild1:compileTestJava - Compiles test Java source.\nchild2:compileTestJava - Compiles test Java source.\ncomponents - Displays the components produced by root project 'multiModule'. [deprecated]\nchild1:components - Displays the components produced by project ':child1'. [deprecated]\nchild2:components - Displays the components produced by project ':child2'. [deprecated]\ndependentComponents - Displays the dependent components of components in root project 'multiModule'. [deprecated]\nchild1:dependentComponents - Displays the dependent components of components in project ':child1'. [deprecated]\nchild2:dependentComponents - Displays the dependent components of components in project ':child2'. [deprecated]\nmodel - Displays the configuration model of root project 'multiModule'. [deprecated]\nchild1:model - Displays the configuration model of project ':child1'. [deprecated]\nchild2:model - Displays the configuration model of project ':child2'. [deprecated]\nprepareKotlinBuildScriptModel\nprocessResources - Processes main resources.\nchild1:processResources - Processes main resources.\nchild2:processResources - Processes main resources.\nprocessTestResources - Processes test resources.\nchild1:processTestResources - Processes test resources.\nchild2:processTestResources - Processes test resources.\nstartScripts - Creates OS specific scripts to run the project as a JVM application.\nchild2:startScripts - Creates OS specific scripts to run the project as a JVM application.\n\nRules\n-----\nPattern: clean\u300aTaskName\u300b: Cleans the output files of a task.\nPattern: build\u300aConfigurationName\u300b: Assembles the artifacts of a configuration.\n\nBUILD SUCCESSFUL in 716ms\n1 actionable task: 1 executed\n<\/code>\n<\/pre>\n<\/details>\n<p><\/p>\n<h4><span class=\"ez-toc-section\" id=\"37_%E6%89%A7%E8%A1%8C_gradlew_build_%E4%B8%8E_gradlew_run_%E5%91%BD%E4%BB%A4\"><\/span>3.7. \u6267\u884c gradlew build \u4e0e gradlew run \u547d\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2022\/11\/image-1668880596243.png\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2022\/11\/image-1668880596243.png\" alt=\"file\" \/><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95\"><\/span>\u9644\u5f55<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95A_%E7%9B%B8%E5%85%B3%E8%81%94%E7%9A%84%E6%96%87%E7%AB%A0\"><\/span>\u9644\u5f55A. \u76f8\u5173\u8054\u7684\u6587\u7ae0<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\n<p><a target=\"_blank\" href=\"http:\/\/dba.qishuo.xin\/?p=1982\" title=\"Linux\u4e0b\u5b89\u88c5\u5e76\u914d\u7f6eGradle\">Linux\u4e0b\u5b89\u88c5\u5e76\u914d\u7f6eGradle<\/a><\/p>\n<\/li>\n<li>\n<p><a target=\"_blank\" href=\"http:\/\/dba.qishuo.xin\/?p=2126\" title=\"\u4f7f\u7528 Gradle \u5feb\u901f\u6784\u5efa Java \u9879\u76ee\uff08\u4f8b\u4e00\uff09\">\u4f7f\u7528 Gradle \u5feb\u901f\u6784\u5efa Java \u9879\u76ee\uff08\u4f8b\u4e00\uff09<\/a><\/p>\n<\/li>\n<li>\n<p><a target=\"_blank\" href=\"http:\/\/dba.qishuo.xin\/?p=2082\" title=\"\u4f7f\u7528 Gradle \u5feb\u901f\u6784\u5efa Java \u9879\u76ee\uff08\u4f8b\u4e8c\uff09\">\u4f7f\u7528 Gradle \u5feb\u901f\u6784\u5efa Java \u9879\u76ee\uff08\u4f8b\u4e8c\uff09<\/a><\/p>\n<\/li>\n<li>\n<p><a target=\"_blank\" href=\"http:\/\/dba.qishuo.xin\/?p=2198\" title=\"\u5728IDEA\u4e2d\u4f7f\u7528 Gradle \u6784\u5efa Java \u9879\u76ee\uff08\u4f8b\u4e09\uff09\">\u5728IDEA\u4e2d\u4f7f\u7528 Gradle \u6784\u5efa Java \u9879\u76ee\uff08\u4f8b\u4e09\uff09<\/a><\/p>\n<\/li>\n<li>\n<p><a target=\"_blank\" href=\"http:\/\/dba.qishuo.xin\/?p=2293\" title=\"\u5728IDEA\u4e2d\u4f7f\u7528 Gradle \u6784\u5efa Java Spring Boot\u9879\u76ee\uff08\u4f8b\u4e94\uff09\">\u5728IDEA\u4e2d\u4f7f\u7528 Gradle \u6784\u5efa Java Spring Boot\u9879\u76ee\uff08\u4f8b\u4e94\uff09<\/a><\/p>\n<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95B_%E5%8F%82%E8%80%83\"><\/span>\u9644\u5f55B. \u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Gradle: \u521b\u5efa\u542b\u6709\u591a\u6a21\u5757\uff08\u5373\u591a\u4e2a\u5b50\u9879\u76ee\uff09\u7684\u9879\u76ee\uff1a<br \/>\n<a target=\"_blank\" href=\"https:\/\/www.letianbiji.com\/gradle\/gradle-sub-projects.html\">https:\/\/www.letianbiji.com\/gradle\/gradle-sub-projects.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u63cf\u8ff0 \u63cf\u8ff0\u9879 \u5185\u5bb9 \u64cd\u4f5c\u7cfb\u7edf CentOS L&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[178],"tags":[223],"class_list":["post-2257","post","type-post","status-publish","format-standard","hentry","category-java","tag-gradle"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/2257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2257"}],"version-history":[{"count":20,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/2257\/revisions"}],"predecessor-version":[{"id":2328,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/2257\/revisions\/2328"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2257"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}