Issues with scala-tools.org

  have a scala project using maven. When I was using only scala classes, there was no problem with the maven plugin. But now, I'm getting errors when trying to compile:

[WARNING] C:\java\workspace\mcare\src\main\scala\com\fb\mcare\config\AppConfig.scala:2: error: object springframework is not a member of package org [WARNING] import org.springframework.context.annotation.Configuration read more scala training



The Scala plugin extends the Java plugin to add support for Scala projects. It can deal with Scala code, mixed Scala and Java code, and even pure Java code (although we don’t necessarily recommend to use it for the latter). The plugin supports joint compilation, which allows you to freely mix and match Scala and Java code, with dependencies in both directions. For example, a Scala class can extend a Java class that in turn extends a Scala class. This makes it possible to use the best language for the job, and to rewrite any class in the other language if needed.read more scala training

Note that if you want to benefit from the API / implementation separation, you can also apply the java-library plugin to your Scala project.

Usage

To use the Scala plugin, include the following in your build script:

Example 1. Using the Scala plugin
GroovyKotlin
build.gradle
plugins {
    id 'scala'
}

Tasks

The Scala plugin adds the following tasks to the project. Information about altering the dependencies to Java compile tasks are found here.

compileScala — ScalaCompile

Depends oncompileJava

Compiles production Scala source files.

compileTestScala — ScalaCompile

Depends oncompileTestJava

Compiles test Scala source files.

compileSourceSetScala — ScalaCompile

Depends oncompileSourceSetJava

Compiles the given source set’s Scala source files.

scaladoc — ScalaDoc

Generates API documentation for the production Scala source files.

The ScalaCompile and ScalaDoc tasks can also leverage the Java toolchain support.

The Scala plugin adds the following dependencies to tasks added by the Java plugin.

Table 1. Scala plugin - additional task dependencies
Task nameDepends on

classes

compileScala

testClasses

compileTestScala

sourceSetClasses

compileSour

Project layout

The Scala plugin assumes the project layout shown below. All the Scala source directories can contain Scala and Java code. The Java source directories may only contain Java source code. None of these directories need to exist or have anything in them; the Scala plugin will simply compile whatever it finds.

The ScalaCompile and ScalaDoc tasks consume Scala code in two ways: on their classpath, and on their scalaClasspath. The former is used to locate classes referenced by the source code, and will typically contain scala-library along with other libraries. The latter is used to load and execute the Scala compiler and Scaladoc tool, respectively, and should only contain the scala-compiler library and its dependencies.

Unless a task’s scalaClasspath is configured explicitly, the Scala (base) plugin will try to infer it from the task’s classpath. This is done as follows:read more scala training

  • If a scala-library jar is found on classpath, and the project has at least one repository declared, a corresponding scala-compiler repository dependency will be added to scalaClasspath.

  • Otherwise, execution of the task will fail with a message saying that scalaClasspath could not be inferred.read more scala training


Comments

  1. Your website is very beautiful or Articles. I love it thank you for sharing for everyone. Key Performance Indicators Sample for Cloud BPM

    ReplyDelete

Post a Comment