我的項目結構是這樣的: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編譯解決了這個問題。
添加回答
舉報
0/150
提交
取消