亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Gradle 在運行任務時設置了錯誤的(意外的?)類路徑

Gradle 在運行任務時設置了錯誤的(意外的?)類路徑

素胚勾勒不出你 2021-06-10 14:13:08
我的項目結構是這樣的:projectRoot  +-src     +-main     |   +-java     |   |   +-package/java files go here     |   +-resources     |       +-config     |           +-files go here     +-test         +-java         |   +-package/java files go here         +-resources             +-config             |   +-files go here             +-features                 +-files go here構建此項目時,它會生成以下輸出結構:projectRoot  +-out      +-production      |     +-classes      |     |   +-package/classes in here      |     +-resources      |         +-config      |             +-files in here      +-test            +-classes            |   +-package/classes in here            +-resources                +-config                |   +-files in here                +-features                    +-files in here這一切都在預料之中。我定義了一個運行黃瓜測試的任務,它看起來像這樣:task runCucumber() {    doLast {        javaexec {            main = "cucumber.api.cli.Main"            args += ['--plugin', 'pretty', '--plugin', 'html:out/reports/cucumber/', '--plugin', 'json:out/reports/cucumber/report.json',                     '--glue', 'com.example.mypackage.cucumber', 'classpath:features'                     , '--tags', 'not @ignore']            systemProperties['http.keepAlive'] = 'false'            systemProperties['http.maxRedirects'] = '20'            systemProperties['env'] = System.getProperty("env")            systemProperties['envType'] = System.getProperty("envType")            classpath = configurations.cucumber + configurations.compile + configurations.testCompile + sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath        }    }}當我執行此任務時,找不到我的類,也找不到功能。顯然,這是由于未正確設置類路徑。如果我使用 運行任務--info,我可以看到類路徑是使用我指示的參數設置的,但是out它包含build目錄而不是目錄。
查看完整描述

1 回答

?
暮色呼如

TA貢獻1853條經驗 獲得超9個贊

好吧,原來問題不在于 Gradle,而在于 IntelliJ IDEA。IDEA 覆蓋了標準的 gradle 路徑,并將輸出保存在與 gradle 預期不同的路徑中。然后,當下一個 gradle 任務運行時,輸出不在那里。直接使用gradle而不是IDEA編譯解決了這個問題。


查看完整回答
反對 回復 2021-06-23
  • 1 回答
  • 0 關注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號