我的項(xiàng)目結(jié)構(gòu)是這樣的: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構(gòu)建此項(xiàng)目時(shí),它會生成以下輸出結(jié)構(gòu):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這一切都在預(yù)料之中。我定義了一個(gè)運(yùn)行黃瓜測試的任務(wù),它看起來像這樣: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 } }}當(dāng)我執(zhí)行此任務(wù)時(shí),找不到我的類,也找不到功能。顯然,這是由于未正確設(shè)置類路徑。如果我使用 運(yùn)行任務(wù)--info,我可以看到類路徑是使用我指示的參數(shù)設(shè)置的,但是out它包含build目錄而不是目錄。
1 回答

暮色呼如
TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊
好吧,原來問題不在于 Gradle,而在于 IntelliJ IDEA。IDEA 覆蓋了標(biāo)準(zhǔn)的 gradle 路徑,并將輸出保存在與 gradle 預(yù)期不同的路徑中。然后,當(dāng)下一個(gè) gradle 任務(wù)運(yùn)行時(shí),輸出不在那里。直接使用gradle而不是IDEA編譯解決了這個(gè)問題。
添加回答
舉報(bào)
0/150
提交
取消