Scala backend

Warning

The Scala backend for ABS is very immature at this moment. Currently we only support a partial subset of the Core ABS language, and even that may have some nasty surprises.

If you decide to try it out and something breaks, you get to keep both of the pieces.

Generating Scala source from ABS

To generate Scala code from ABS in a ABS Maven project, include the following plugin declaration inside the <build><plugins>...</plugins></build> section of the pom.xml

<plugin>
  <groupId>eu.hats-project</groupId>
  <artifactId>abs-maven-plugin</artifactId>
  <version>1.0-SNAPSHOT</version>
  <executions>
    <execution>
      <goals>
            <goal>genscala</goal>
      </goals>
      <configuration>
        ... (see optional configuration for detail) ...
      </configuration>
    </execution>
  </executions>
</plugin>

Optional configuration goal genmaude

  • absSrcFolder, ABS source folder, default is $project.basedir/src/main/abs
  • absTestFolder, ABS test folder, default is $project.basedir/src/test/abs
  • outputDirectory, Directory where to write generated Scala code, default is $project.build.directory/generated-sources/abs
  • verbose, toggle verbosity, default is false
  • productName, build given product by applying deltas (productName is a string that is the qualified product ID)

To generate Scala code from the source of the ABS Maven project, invoke the 'generate-sources' goal

mvn generate-sources

Compiling the generated source files

Note that the genscala mojo does not compile the generated source files. If you wish to compile the generated code, you need to add the Maven Scala plugin to the POM and configure it accordingly:

<repositories>
  <repository>
    <id>scala-tools.org</id>
    <name>Scala-tools Maven2 Repository</name>
    <url>http://scala-tools.org/repo-releases</url>
  </repository>
</repositories>

<properties>
  <scala.version>2.9.1</scala.version>
</properties>

<pluginRepositories>
  <pluginRepository>
    <id>scala-tools.org</id>
    <name>Scala-tools Maven2 Repository</name>
    <url>http://scala-tools.org/repo-releases</url>
  </pluginRepository>
</pluginRepositories>
  
<build>
  <plugins>
    <plugin>
      <groupId>org.scala-tools</groupId>
      <artifactId>maven-scala-plugin</artifactId>
      <version>2.15.2</version>
      <configuration>
        <args>
          <arg>-P:continuations:enable</arg>
        </args>
        <compilerPlugins>
          <compilerPlugin>
            <groupId>org.scala-lang.plugins</groupId>
            <artifactId>continuations</artifactId>
            <version>${scala.version}</version>
          </compilerPlugin>
        </compilerPlugins>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>compile</goal>
            <goal>testCompile</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

<dependencies>
  <dependency>
    <groupId>org.scala-lang</groupId>
    <artifactId>scala-library</artifactId>
    <version>${scala.version}</version>
  </dependency>

  <dependency>
    <groupId>eu.hats-project</groupId>
    <artifactId>abs-scala-runtime</artifactId>
    <version>1.0-SNAPSHOT</version>
  </dependency>
</dependencies>

If you want to compile the generated code, you only need to invoke the 'compile' goal; the 'generate-sources' goal is invoked automatically.