In the IntelliJ Scala plugin, can I use scala -compiler.jar extracted via <dependency> in `pom.xml`?

In IntelliJ, I created an empty Maven project and added to pom.xml :

 <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-compiler</artifactId> <version>2.11.0-M3</version> <scope>compile</scope> </dependency> 

Then I went to "Project Settings" β†’ "Modules" β†’ + β†’ Scala, and in the drop-down menu - Maven: org.scala-lang:scala-compiler:2.11.0-M3 . I get an error message:

 Compiler library: no scala-library*.jar found 

Of course, scala-library-2.11.0-M3.jar is included in the number of dependencies (transitively), but it is not stored in the same folder as scala-compiler-2.11.0-M3.jar , which seems to confuse the Scala plugin .

Is it possible to use scala-compiler*.jar loaded from the pom.xml dependency? Perhaps manually specifying where to find each JAR?

Prior to this, I used scala-compiler*.jar , downloaded through Project Settings β†’ Libraries β†’ + β†’ From Maven. This seems to work because IntelliJ uses all loaded JARs in the same folder as the Scala plugin assumes. Just for aesthetic reasons, I would like to know if this can be done using pom.xml .

+4
source share
1 answer

You do not need a scala-compiler as a dependency to be able to build a scala project (either using maven on the command line, or by creating from Build | Make Project in IntelliJ).

This is a very simple pom.xml that I use for scala projects, where I don't have scala at all, and just point IntelliJ to that pom, and then I can compile and run any scala code directly from inside IntelliJ.

 <?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</groupId> <artifactId>scala-app</artifactId> <version>1.0-SNAPSHOT</version> <name>${project.artifactId}-${project.version}</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <scala.version>2.10.1</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>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> </plugins> </build> </project> 
+9
source

Source: https://habr.com/ru/post/1483906/


All Articles