2

Maven プロジェクトで Scala を段階的にコンパイルしたいと考えています。

現在、Scala は何も変更されていなくてもコンパイルされます。

scala-maven-plugin を試してみましたが、段階的にまったく機能しないようです。

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0">
    <artifactId>example</artifactId>

    <build>
        <plugins>
            <plugin>
                <artifactId>scala-maven-plugin</artifactId>
                <configuration>
                    <recompileMode>incremental</recompileMode>
                    <scalaVersion>2.11.7</scalaVersion>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <groupId>net.alchim31.maven</groupId>
                <version>3.2.2</version>
            </plugin>
        </plugins>
    </build>

    <groupId>example</groupId>

    <modelVersion>4.0.0</modelVersion>

    <name>example</name>

    <version>0.0-SNAPSHOT</version>
</project>

src/main/scala/example/Foo.scala

package example

class Foo {
  val foo = None
}

Maven バージョン:

$ mvn --version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T10:37:52-07:00)
Maven home: /usr/share/maven3
Java version: 1.8.0_45-internal, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-65-generic", arch: "amd64", family: "unix"

その後:

$ mvn compile
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building example 0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/paul/dev/example/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ example ---
[INFO] No sources to compile
[INFO] 
[INFO] --- scala-maven-plugin:3.2.2:compile (default) @ example ---
[INFO] Using incremental compilation
[INFO] Compiling 1 Scala source to /home/paul/dev/example/target/classes...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.090 s
[INFO] Finished at: 2015-10-15T18:22:34-07:00
[INFO] Final Memory: 23M/412M
[INFO] ------------------------------------------------------------------------
$ mvn compile
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building example 0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/paul/dev/stash-conditions-test/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ example ---
[INFO] No sources to compile
[INFO] 
[INFO] --- scala-maven-plugin:3.2.2:compile (default) @ example ---
[INFO] Using incremental compilation
[INFO] Compiling 1 Scala source to /home/paul/dev/stash-conditions-test/target/classes...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.661 s
[INFO] Finished at: 2015-10-15T18:22:39-07:00
[INFO] Final Memory: 23M/418M
[INFO] ------------------------------------------------------------------------

毎回まとめます!

変更された場合にのみ Scala をコンパイルする Maven プロジェクトを取得するにはどうすればよいですか?

4

2 に答える 2

1

mvn scala:ccを試してみてください。ここの指示を参照してくださいhttp://davidb.github.io/scala-maven-plugin/example_cc.html

于 2015-11-11T10:07:35.447 に答える