My mixed Scala/Java Maven project doesn't compile -
i have mixed scala/java project doesn't compile well.
the problem arises when java code trying call scala code in same package.
of course, have standard layout:
- src/main/java
- src/main/scala
- src/test/java
- src/test/scala
i've looked @ other similar stackoverflow questions this question little outdated. other question doesn't either.
i have followed scala-maven-plugin documentation page.
<build> <pluginmanagement> <plugins> <plugin> <groupid>net.alchim31.maven</groupid> <artifactid>scala-maven-plugin</artifactid> <version>3.1.6</version> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.0.2</version> </plugin> </plugins> </pluginmanagement> <plugins> <plugin> <groupid>net.alchim31.maven</groupid> <artifactid>scala-maven-plugin</artifactid> <executions> <execution> <id>scala-compile-first</id> <phase>process-resources</phase> <goals> <goal>add-source</goal> <goal>compile</goal> </goals> </execution> <execution> <id>scala-test-compile</id> <phase>process-test-resources</phase> <goals> <goal>testcompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <executions> <execution> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
i have tried unsuccessfully follow blog post.
idea project scala plugin imported pom.xml can compile , run project successfully.
what right way of doing it? java code gets compiled twice? first scala plugin , java plugin?.
here working example of pom.xml :
<?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>stackoverflow</groupid> <artifactid>q24448582</artifactid> <version>1.0-snapshot</version> <properties> <scala.version>2.10.3</scala.version> </properties> <dependencies> <dependency> <groupid>org.scala-lang</groupid> <artifactid>scala-library</artifactid> <version>${scala.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.scala-tools</groupid> <artifactid>maven-scala-plugin</artifactid> <version>2.15.2</version> <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> </plugins> </build> </project>
Comments
Post a Comment