Welcome, Michael

posted 03:38PM Jan 18, 2008 with tags blogs jcr scala by Lars Trieloff

I would like to welcome my colleague Michael among the bloggers that contribute to PlanetDay. Michael is, among other things, blogging about Scala and JCR, some topics that I have show interest in, so this is a must-have in my reading list.

Building Scala Applications with Maven 2

posted 04:59PM Aug 30, 2006 with tags java maven opensource plexus scala by Lars Trieloff

Scala is a programming language that implements many interesting concepts and can be compiled into Java bytecode, making it an an ideal match for Java developers who would like to try out new programming language and keep using existing code and third-party libraries.

Unfortunately Scala and Maven 2 have not been working together until now. Scala comes with an standalone compiler, scalac and a collection of Ant tasks. Maven 2 relies on Plexus for compilers and there are up to now Plexus compiler components for the standard javac, for Jikes, for the Eclipse Java Compiler and for C# using Microsofts compiler or Mono.

It wrote until now, because this patch for Plexus brings a Scala compiler component for plexus. The easiest way to use it is to create a new Maven project with some Scala source code in src/main/scala and to use an adaption of following 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>scala-maven-example</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Scala Maven Example</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>scala</groupId>
      <artifactId>scala-library</artifactId>
      <version>2.1.8</version>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <id>Goshaky</id>
      <url>http://www.goshaky.com/m2</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>Goshaky Plugins</id>
      <url>http://www.goshaky.com/m2</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/scala</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerId>scalac</compilerId>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-scalac</artifactId>
            <version>1.6-SNAPSHOT</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

This pom uses the Goshaky repository which contains snapshots for Scala and the new compiler component until they are available in the public repository, configures the Maven compiler plugin to use the Scala compiler component and adds the path src/main/scala to the source lookup path, so you don't have to put your *.scala files below src/main/java.

The most interesting part in writing this component was seeing how certain Scala constructs (e.g. functions as arguments) are mapped to Java constructs.

New Scala and Scala Eclipse Plugin

posted 03:35PM May 04, 2006 with tags eclipse java scala by Lars Trieloff

The Scala Team has mad a new release of Scala available and a new release of the Scala Eclipse Plugin. Scala is a programming language for the Java Virtual Machine that implements many very interesting concepts like being object-oriented and functional at the same time, strong statical typing and extensibility.