compiler option gets recognized as argument

53 views
Skip to first unread message

brettvormkopp

unread,
Dec 25, 2010, 7:30:04 AM12/25/10
to Maven and Scala
after installing maven 2.2.1 and revisiting an old project of mine i
stubled upon some strange(?) behaviour which i "verified" using the
following example:

package de.thanith

object Test {
def main(args: Array[String]) {
args.foreach(println)
}
}

my pom.xml configures the plugin to enable continuations (which are
needed by other sources in my project):

<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<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>
</plugin>

now the execution of the run goal yields the following output:

C:\Users\wotan\IdeaProjects\Default\ScalaWorkspace>mvn -DaddArgs=17 -
DmainClass=de.thanith.Test -f C:\Users\wotan\IdeaProjects\Default
\ScalaWorkspace\pom.xml org.scala-to
ols:maven-scala-plugin:2.15.0:run
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building Unnamed - ScalaWorkspace:ScalaWorkspace:jar:1.0
[INFO] task-segment: [org.scala-tools:maven-scala-plugin:
2.15.0:run]
[INFO]
------------------------------------------------------------------------
[INFO] Preparing scala:run
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\wotan\IdeaProjects
\Default\ScalaWorkspace\src\main\resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:compile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,**/*.java,]
[INFO] excludes = []
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\wotan\IdeaProjects
\Default\ScalaWorkspace\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:testCompile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,**/*.java,]
[INFO] excludes = []
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:run {execution: default-cli}]
[INFO] Checking for multiple versions of scala
-P:continuations:enable
17
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Sat Dec 25 12:59:14 CET 2010
[INFO] Final Memory: 35M/344M
[INFO]
------------------------------------------------------------------------

so "-P:continuations:enable" gets recognized as an argument but it
should not, at least in my opinion.

what am i missing here?

rgds
toni

David Bernard

unread,
Dec 26, 2010, 8:53:29 AM12/26/10
to maven-a...@googlegroups.com
Hi,

Configuration defined at top level plugin (directly under <plugin>) are shared by every plugin's goals (so by scala:run, scala:cc, scala:compile, scala:testCompile... in your case).
2 solutions :
* try to move your configuration node under <execution>, then the configuration will be shared only by compile and testCompile.
* use launcher, then scala:run will use specific configuration defined by launcher section see http://scala-tools.org/mvnsites/maven-scala-plugin/example_run.html

/davidB

brettvormkopp

unread,
Dec 26, 2010, 3:58:49 PM12/26/10
to Maven and Scala
Hi,

i modified the plugin configuration to follow your first suggestion:

<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<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>
</execution>
</executions>
</plugin>

compilation of the project proved successful and the compiler option
is no longer recognized as an argument, but now the execution of
scala:run on a main class that needs continuations yields:

Exception in thread "main" java.lang.NoSuchMethodError:
scala.util.continuations.package$.shift(Lscala/Function1;)Ljava/lang/
Object;
at de.thanith.scala.Typesafe$.format(Typesafe.scala:18)
at de.thanith.scala.Typesafe$$anonfun$4.apply(Typesafe.scala:24)
at de.thanith.scala.Typesafe$$anonfun$4.apply(Typesafe.scala:24)
at scala.util.continuations.package$.reset(package.scala:20)
at de.thanith.scala.Typesafe$.sprintf(Typesafe.scala:22)
at de.thanith.scala.Typesafe$.<init>(Typesafe.scala:24)
at de.thanith.scala.Typesafe$.<clinit>(Typesafe.scala)
at de.thanith.scala.Typesafe.main(Typesafe.scala)

Btw. i am duing this in order to use Intelij IDEA's Run/Debug
configurations to specify addArgs parameters (thats the reason i did
not use launchers :).

Any hints, ideas how i can adjust pom.xml to use the continuations
plugin and be able to specify addArgs?

thx and rgds
toni

On 26 Dez., 14:53, David Bernard <david.bernard...@gmail.com> wrote:
> Hi,
>
> Configuration defined at top level plugin (directly under <plugin>) are
> shared by every plugin's goals (so by scala:run, scala:cc, scala:compile,
> scala:testCompile... in your case).
> 2 solutions :
> * try to move your configuration node under <execution>, then the
> configuration will be shared only by compile and testCompile.
> * use launcher, then scala:run will use specific configuration defined by
> launcher section seehttp://scala-tools.org/mvnsites/maven-scala-plugin/example_run.html
>
> /davidB

brettvormkopp

unread,
Dec 26, 2010, 4:02:23 PM12/26/10
to Maven and Scala


On 26 Dez., 14:53, David Bernard <david.bernard...@gmail.com> wrote:
> Hi,
>
> Configuration defined at top level plugin (directly under <plugin>) are
> shared by every plugin's goals (so by scala:run, scala:cc, scala:compile,
> scala:testCompile... in your case).
> 2 solutions :
> * try to move your configuration node under <execution>, then the
> configuration will be shared only by compile and testCompile.
> * use launcher, then scala:run will use specific configuration defined by
> launcher section seehttp://scala-tools.org/mvnsites/maven-scala-plugin/example_run.html
>
> /davidB

Josh Suereth

unread,
Dec 28, 2010, 10:20:59 AM12/28/10
to maven-a...@googlegroups.com
If it can't find the continuations library, than the scala-library is somehow not on your path.  All scala.util.continuations code is located in the scala-library.
  What does your POM look like for scala:run?

thanks

- josh

brettvormkopp

unread,
Dec 28, 2010, 12:02:05 PM12/28/10
to Maven and Scala
my POM looks as given below (it is pretty much was comes with the
artifact, i just enabled continuations and the maven-scalatest
plugin).

(Btw. all the classes which do not need continuations execute without
problems.)

<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>ScalaWorkspace</groupId>
<artifactId>ScalaWorkspace</artifactId>
<version>1.0</version>
<inceptionYear>2008</inceptionYear>
<properties>
<scala.version>2.8.1</scala.version>
</properties>

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

<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>

<pluginManagement>
<plugins>
<plugin>
<groupId>com.jteigen</groupId>
<artifactId>maven-scalatest-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<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>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<buildcommands>
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</
buildcommand>
</buildcommands>
<additionalProjectnatures>
<projectnature>ch.epfl.lamp.sdt.core.scalanature</
projectnature>
</additionalProjectnatures>
<classpathContainers>

<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</
classpathContainer>

<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</
classpathContainer>
</classpathContainers>
</configuration>
</plugin>

<plugin>
<groupId>com.jteigen</groupId>
<artifactId>maven-scalatest-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
</project>


rgds
toni


On 28 Dez., 16:20, Josh Suereth <joshua.suer...@gmail.com> wrote:
> If it can't find the continuations library, than the scala-library is
> somehow not on your path.  All scala.util.continuations code is located in
> the scala-library.
>   What does your POM look like for scala:run?
>
> thanks
>
> - josh
>

Josh Suereth

unread,
Dec 28, 2010, 10:47:47 PM12/28/10
to maven-a...@googlegroups.com
your code is *not* being compiled with the continuations plugin enabled.


Set the displayCmd option to true and let's see what your command line argument is.  My guess is that your configuration does not bind the goals to a phase and is therefore not being used in the default lifecycle.   Only a guess though.


- Josh

David Bernard

unread,
Dec 29, 2010, 2:56:43 AM12/29/10
to maven-a...@googlegroups.com
try to remove configuration under plugin, because :
* I'm not sur maven (every version) merge configuration for plugin with configuration from execution
* it's useless, maven-scala-plugin detecte the version from scala-library or the property scala.version (use of configuration is only for some case like packaging == pom)

good pratice : set the version of the maven-scala-plugin (eg : 2.15.0)
* to have a reproductible build (in time, in environment)
* to follow maven 3 advice

/davidB
Reply all
Reply to author
Forward
0 new messages