18915


自分が作った以下のスパムフィルターを別のsbtプロジェクトでも使用したいと思ってるのですが、intellijでこれをモジュールとして追加して依存関係を設定するとエディタ上ではちゃんと使えるように見えるのですが、  
<https://github.com/lamrongol/JapaneseTwitterSpamFilter>

実際に実行しようとすると以下の様なエラーが出ます。

[code]

    Error:scalac: missing or invalid dependency detected while loading class file 'JapaneseSpamFilter.class'.
    Could not access term apache in package org,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
    A full rebuild may help if 'JapaneseSpamFilter.class' was compiled against an incompatible version of org.
    Error:scalac: missing or invalid dependency detected while loading class file 'JapaneseSpamFilter.class'.
    Could not access term spark in value org.apache,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
    A full rebuild may help if 'JapaneseSpamFilter.class' was compiled against an incompatible version of org.apache.
    Error:scalac: missing or invalid dependency detected while loading class file 'JapaneseSpamFilter.class'.
    Could not access term mllib in value org.spark,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
    A full rebuild may help if 'JapaneseSpamFilter.class' was compiled against an incompatible version of org.spark.
    Error:scalac: missing or invalid dependency detected while loading class file 'JapaneseSpamFilter.class'.
    Could not access term atilika in package com,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
    A full rebuild may help if 'JapaneseSpamFilter.class' was compiled against an incompatible version of com.
    Error:scalac: missing or invalid dependency detected while loading class file 'JapaneseSpamFilter.class'.
    Could not access term kuromoji in value com.atilika,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
    A full rebuild may help if 'JapaneseSpamFilter.class' was compiled against an incompatible version of com.atilika.
    
[/code]

どうやらスパムフィルターで使用しているKuromojiなどのライブラリが存在しないと言っているようなのですが、スパムフィルターのbuild.sbtで記述したライブラリをインポート先でもまた書かなければいけないのでしょうか。

依存ライブラリも含めてインポートするにはどうしたら良いでしょうか？

追記:  
[scala - How to reference external sbt project from another sbt project? -
Stack Overflow](https://stackoverflow.com/questions/11653435/how-to-reference-
external-sbt-project-from-another-sbt-project "scala - How to reference
external sbt project from another sbt project? - Stack
Overflow")を参考にprojectフォルダ内にBuild.scalaファイルを作って以下のように記述したのですが、

[code]

    object ScalaSampleBuild extends Build {
      lazy val root = Project(
        id = "TestScalaProject", //Your project name
        base = file(".")
      ).dependsOn(spamFilterProject)
    
      //lazy val spamFilterProject = ProjectRef(file("..\\..\\..\\TwitterAnalysis\\SpamFilter"), "SpamFilter")
      lazy val spamFilterProject = RootProject(file("C:\\workspaces\\TwitterAnalysis\\SpamFilter"))
    }
    
[/code]

今度は以下の様なエラーが出てできませんでした。

[code]

    Error:Unresolved dependencies:
        default#spamfilter_2.10;1.0: not found
    See complete log in C:\Users\admin\.IdeaIC15\system\log\sbt.last.log
    
[/code]


CC BY-SA 3.0
2015-11-14T22:42:43.013
18827
2015-11-16T22:09:51.173
2017-05-23T12:38:56.467
-1
816
question
scala sbt
sbtプロジェクトで別のsbtモジュールをインポートする方法


解決しました。build.sbtに以下のように書けばいいようです。

[code]

    lazy val spamFilter = RootProject(file("C:\\workspaces\\TwitterAnalysis\\SpamFilter"))
    
    val main = Project(id = "TestScalaProject", base =file(".")).dependsOn(spamFilter)
    
[/code]

「RootProject(file("C:\workspaces\TwitterAnalysis\SpamFilter"))」と「id =
"TestScalaProject"」のところは自分のプロジェクトに合わせて変更する必要があります。また、sbtキャッシュを削除したりintellijプロジェクトを構築しなおしたりする必要があることもあるようです。

参考リンク  
<https://stackoverflow.com/a/32857624/3809427>


CC BY-SA 3.0
2015-11-16T22:09:51.173
18915
2015-11-16T22:09:51.173
2017-05-23T12:38:56.083
-1
816
18827
answer