2017-02-03 134 views
1

今天我在我的macbook上安裝了intelliJ ceylon IDE。編譯我的項目時,我收到以下消息錫蘭運行:未找到模塊默認/未版本

/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java "-Dceylon.system.repo=/Users/Laust/Library/ApplicationSupport/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/repo" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Users/Laust/Library/Application Support/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/lib/ceylon-bootstrap.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain com.redhat.ceylon.launcher.Bootstrap run --run main default/unversioned 
ceylon run: Module default/unversioned not found in the following repositories: 
/Users/Laust/Library/Application Support/IdeaIC2016. 
3/CeylonIDEA/classes/embeddedDist/repo 
/Users/Laust/.ceylon/cache 
https://modules.ceylon-lang.org/repo/1 
[Maven] Aether 
[NPM] npm 

Process finished with exit code 1 

該代碼在我的另一臺計算機(Windows 7)上執行得很好。

文件夾 '模塊' 包含以下內容:

default 
    default.car 
    default.car.sha1 
    default.src 
    default.src.sha1 

和我的構建配置looks as follows

這是我的代碼(在文件源/ main.ceylon)

shared void main() { 
    print("Generating pretty sweet g-code:"); 

    {Gcommand+} myGcommands = { 
     G00(Vector3(0.0, 0.0, 0.0)), 
     G00(Vector3(9.0, 0.0, 0.0)), 
     G00(Vector3(9.0, 9.0, 0.0)), 
     G00(Vector3(0.0, 9.0, 0.0)), 
     G00(Vector3(0.0, 0.0, 0.0)) 
    }; 

    GcodeProgram myGcodeProgram = GcodeProgram(*myGcommands); 

    print(myGcodeProgram.toString()); 
} 

"A carthesian coordinate class" 
alias X => Float; 
alias Y => Float; 
alias Z => Float; 
class Vector3(shared X x, shared Y y, shared Z z) { 
} 

"An abstract spec class for all G-code command classes" 
abstract class Gcommand() { 
    shared formal String toString(); 
} 

"G-code command for moving in a straight line at rapid speed" 
class G00(Vector3 endPoint) extends Gcommand() { 
    toString() => "G0 " + "X" + endPoint.x.string 
         + "Y" + endPoint.y.string 
         + "Z" + endPoint.z.string + "\n"; 
} 

class GcodeProgram(Gcommand+ gcommands) { 

    variable String stringifiedGcodeProgram = ""; 

    shared String toString() { 
     for (gcommand in gcommands) { 
      stringifiedGcodeProgram = stringifiedGcodeProgram + gcommand.toString(); 
     } 
    return stringifiedGcodeProgram; 
    } 
} 

回答

3

您提供的屏幕截圖顯示運行配置不基於任何IntelliJ模塊(Use classpath of module設置爲[none])。這意味着配置將而不是運行在modules目錄所在的項目文件夾中。該目錄包含已編譯的代碼,當您要求它運行default模塊時,ceylon run將查找該目錄。

一般來說,您應該避免手動創建運行配置。通過單擊可運行函數名稱旁邊的綠色箭頭,Ceylon IDE將自動創建並配置正確的運行配置。

Run Ceylon function

要解決現有的運行配置,只需選擇一個包含標記Use classpath of module領域代碼中的IntelliJ模塊。

另請參閱getting started guide以獲取有關如何開始使用IntelliJ Ceylon IDE的更多信息。

+1

如果您選擇自動爲您創建新的,正確的運行配置,請務必事後刪除舊的,錯誤的運行配置(或者之前,以免混淆它們)。在'運行' - >'編輯配置'中這樣做。 – loldrup

0

這可能是用的IntelliJ插件無法正確處理「默認」模塊中的錯誤。我們傾向於不使用默認模塊,因爲它們比普通模塊更有限。

嘗試創建一個模塊並將代碼移動到它。這將最有可能解決這個問題。如果是這樣,那麼你可以打開一個問題來修復這個bug:https://github.com/ceylon/ceylon-ide-intellij/issues/new

+0

這個解釋對我來說似乎頗具推測性。看起來更可能是項目配置的問題。 –

0

this question中,第一個(也是唯一的)答案告訴你如何創建一個新的模塊。

我有一些意見認爲答案:

  • 一個新項目開始的時候,你也許並不需要爲用戶的模塊複雜的嵌套命名層次。如果您在模塊名稱中使用句點(例如,my.ceylon.example),那麼您會得到這個結果,所以我建議您堅持使用一個簡單的名稱,例如main
  • 當你創建你的新模塊時,你會(除其他之外)被要求指定一個'可運行單元名稱'。此字段的目的是告訴IntelliJ啓動程序時應該執行哪些模塊的類。換句話說,這成爲您程序的入口點。一個合適的名稱可能(也)是main
  • 錫蘭項目分爲模塊,模塊分爲包,包分爲班級和頂層功能。在創建模塊時,將在該模塊下自動創建一個包。你的代碼文件在這個模塊下的路徑是'source/moduleName/packageName'。創建新模塊時,您無法指定模塊中第一個包的名稱。相反,軟件包的名稱與您的模塊名稱相同。因此,名爲'main'的模塊將具有此路徑:source/main/main作爲其代碼文件的路徑。
  • 在您的新模塊文件夾(例如source/main/main)中將創建三個新文件。找到以前選擇的'可運行單元名稱'後命名的文件。 您的代碼應該放入此文件。另外,你的代碼應該有一個與你選擇的'Runnable單元名稱'同名的類。
  • 答案中使用了「runnable unit」這個奇特術語,他只是指一個包含Ceylon代碼的文件。
  • 在嘗試運行新模塊之前,請記得刪除包含舊的「默認」模塊的文件。
  • 模塊名稱不能以大寫字母開頭。
  • modules/是編譯代碼的輸出目錄。項目建成時,它會自動從source/中的代碼重新創建。
1

在這裏的項目設置似乎有些東西搞砸了。需要注意的是正在搜索回購名單:

Module default/unversioned not found in the following repositories: 
/Users/Laust/Library/Application Support/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/repo 
/Users/Laust/.ceylon/cache 
https://modules.ceylon-lang.org/repo/1 
[Maven] Aether 
[NPM] npm 

我希望看到的形式your-project-dir/modules的回購在該列表中的第二項,但它不存在。

也就是說,ceylon run沒有在編譯.car所在的modules目錄中查找。所以問題是爲什麼回購從列表中缺失。

你在Project Structure> Modules> Ceylon> Repositories中看到了什麼?