简体   繁体   English

如何在NetBeans IDE中将Scala和Java文件一起编译?

[英]how to compile scala and java files to together in netbeans IDE?

I have checked all the related questions about this issue. 我已经检查了有关此问题的所有相关问题。 The issue i have is, i have scala code and java code in same netbeans project. 我的问题是,我在同一netbeans项目中有scala代码和java代码。 The home env for scala is set. 设置了scala的home env。 I use windows system for the development. 我使用Windows系统进行开发。 I know that the build.xml of the netbeans project needs to be changed, to compile scala code first and then compile the java code. 我知道需要更改netbeans项目的build.xml,以便首先编译scala代码,然后再编译java代码。 But i couldnt find much of example to do this on netbeans IDE. 但是我找不到在netbeans IDE上执行此操作的很多示例。

I use the netbeans sbt plugin (nbsbt). 我使用netbeans sbt插件(nbsbt)。 It takes care of this transparently. 它会透明地处理此问题。

Only tangentially related, but Intellij Idea using pom (maven) projects handles this with no issues whatsoever. 仅与切向相关,但使用pom(maven)项目的Intellij Idea可以毫无问题地处理此问题。 You just create a src/main/scala dir alongside your srce/main/java and use the Scala complier plug-in: 您只需在srce / main / java旁边创建一个src / main / scala目录,然后使用Scala编译器插件:

        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <executions>
                <execution>
                    <id>compile</id>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                    <phase>compile</phase>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                    <phase>test-compile</phase>
                </execution>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I offer this only for those who may be pondering NetBeans vs. Idea for Scala development. 我仅向可能正在考虑NetBeans与Scala开发理念的用户提供此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM