I have a project which has both scala and java code which I am currently managing in eclipse using the scala IDE plugin. At present the directory structure is organized such that some packages have both java and scala code in them. There are scala classes which depend on java classes and there are other java classes which depend on the scala classes. The plugin handles all of this transparently – I believe (but I’m not 100% sure) that the scala compiler compiles both the java and scala code together which is how the cross dependencies are handled. I did find some references to compiling mixed projects using Maven e.g. here but the ones I saw talking about separating the java and scala into two separate source trees. Maven attempts to compile the scala code first which fails because of the dependencies on the java code. Likewise, if the java code were compiled first it would also fail as the dependencies go both ways. Is there a way to have Maven compile all the code together like the eclipse plugin? I’d also like to have the ability to generate an eclipse project without doing too much manual fix-up afterwards if possible.
質問する
2943 次
1 に答える
5
The usual Maven directory structure is
src/
main/
java/
com/foo/mypackage/
scala/
com/foo/mypackage/
If you set things up this way then for sure you can have cross dependencies between your Java and Scala code. See the maven-scala-plugin or scala-maven-plugin pages on the topic.
I would not recommend putting Java and Scala code in the same directory.
于 2012-08-30T02:50:13.093 に答える