简体   繁体   English

如何在intellij想法中通过maven集成编译scala源代码?

[英]How to compile scala sources via maven integration in intellij idea?

I am learning circumflex orm and using maven with idea for the first time. 我正在学习抑扬症,并且第一次使用有想法的maven。 I expected that my sources in src will compile to build directory. 我希望我在src源代码将编译为build目录。 But it doesn't happen. 但它不会发生。 And if I specify sourceDirectory and outputDirectory like ${basedir}/src or ${project.basedir}/build I get intellij idea's inspections that such folders doesn't exist (sic!) 如果我指定sourceDirectoryoutputDirectory${basedir}/src${project.basedir}/build我得到intellij idea的检查,这些文件夹不存在(原文如此!)

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>C2Probe</groupId>
    <artifactId>C2Probe</artifactId>
    <version>1.0</version>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <outputDirectory>build</outputDirectory>

        <plugins>
            <plugin>
                <groupId>ru.circumflex</groupId>
                <artifactId>maven-cx-plugin</artifactId>
                <version>${cx.version}</version>
                <executions>
                    <execution>
                        <id>configure</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>cfg</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <properties>
        <cx.version>1.1</cx.version>
        <orm.connection.driver>org.postgresql.Driver</orm.connection.driver>
        <orm.connection.url>jdbc:postgresql:mydb</orm.connection.url>
        <orm.connection.username>myuser</orm.connection.username>
        <orm.connection.password>mypass</orm.connection.password>
    </properties>
    <dependencies>
        <dependency>
            <groupId>ru.circumflex</groupId>
            <artifactId>circumflex-orm</artifactId>
            <version>${cx.version}</version>
        </dependency>
    </dependencies>
</project>

What should I do to compile my sources? 我该怎么做才能编译我的资源?

<build>
    <sourceDirectory>src/main/scala</sourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>greet.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
</build>

Thanks http://www.nearinfinity.com/blogs/bryan_weber/scala_and_maven_with_maven.html for good tutorial. 感谢http://www.nearinfinity.com/blogs/bryan_weber/scala_and_maven_with_maven.html以获得良好的教程。

The Maven convention is that the compiled classes are put into target/classes . Maven约定是将已编译的类放入target/classes Unless you have a very good reason to do it differently, it is better (and much less painful) to stick to the convention. 除非你有充分的理由以不同的方式做到这一点,否则遵守惯例会更好(并且更不痛苦)。

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

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