繁体   English   中英

NetBeans + Scala + Maven

[英]NetBeans + Scala + Maven

我是 Scala 的新手,对 Java 也比较陌生。 我似乎无法通过 Scala 使用 IDE。 我正在使用纯文本编辑器和 sbt,效果很好。 但我想要代码提示,让 IDE 通过在 maven 中搜索来帮助我解析类。

我有用于 NetBeans 的 Scala 插件,但它使用 ant。 代码提示有效,但它不像使用 java/maven 那样为我解析类。

有没有办法使用 Maven 或 SBT 将 NetBeans 与 Scala 一起使用?

我不是 NetBeans 用户,但我想使用 maven 设置对其进行测试,对我而言,它与以下 pom 文件配合良好。

它使用ScalaTest进行单元测试。

我刚刚通过选择Open project...加载了这个项目,并指向了 pom 文件。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.stackoverflow.Q13337089</groupId>
    <artifactId>scala</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>${project.artifactId}-${project.version}</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <scala.version>2.9.2</scala.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_2.9.2</artifactId>
            <version>2.0.M4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <id>scala-compile</id>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-make:transitive</arg>
                                <arg>-dependencyfile</arg>
                                <arg>${project.build.directory}/.scala_dependencies</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <!-- Disable the default-test by putting it in phase none -->
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>1.0-M2</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                    <junitxml>.</junitxml>
                    <filereports>WDF TestSuite.txt</filereports>
                    <stdout>W</stdout> <!-- Skip coloring output -->
                </configuration>
                <executions>
                    <execution>
                        <id>scala-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

https://github.com/dcaoyuan/nbscala#readme在某些方面应该包括将 scala 支持与 maven 项目桥接的代码。 netbeans 模块在源代码中,不确定它是否是二进制文件。

这对我有用。 首先安装 netbeans > 7.4 从netbeans 插件网站第二次安装 scala 插件,按照说明添加插件。 第三创建一个Maven项目。 新建项目-> Maven -> 来自原型的项目。 然后选择“scala archetype simple”,然后选择“Next”和“finish”。

我在 Scala IDE 和 Eclipse 上玩得更开心了。 如果您只是想让一个项目进行下去,这就是您真正需要的。

现在还有一个用于 eclipse 的 sbt 插件(尽管我没有打扰使用它,因为 sbt 的 eclipse 插件可以很好地生成 eclipse 项目文件)。

如果您想从 sbt 构建文件进入 eclipse,那么我可以告诉您,我使用 Lift 进行了 webapp 开发(从 sbt 构建模板开始),并且我根据这些说明进行了设置,其中包括将其集成到 eclipse 中:

http://scala-ide.org/docs/tutorials/lift24scalaide20/index.html

实际上,顶级教程目录有关于使用 Scala IDE 进行 Play、Android devel 和其他操作的说明。

暂无
暂无

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

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