Build integrator for Java, Scala, Scala.macro, Scala.js, Scala.native, Eclipse and Maven.
Install | Production Release | Development Release |
---|---|---|
Similar plugins
Getting started
- build and study demo project
Scala
- new incremental Zinc
- uses static compiler-bridge
- auto-discovery of Scala compiler plugins
- cross-scala-version build with simple setup
- limited Scala Java 9 support
Scala.macro
- same-project Scala macro build
- compiles in 3 scopes: macro, main, test
Scala.js
- compiles and links Scala.js JavaScrpt
- supports JavaScrpt module initializers
- same-project JS-VM + JVM JUnit testing
- incremental cached JS linking in Eclipse/M2E
- auto-provisions Webjars resources for testing
- auto-provisions JavaScript JS-VM environments for testing
Scala.native
- compiles and links scala-native binary runtime
- supports embedding of objcopy resources
- supports compiling of C/CPP user sources
- incremental cached Native linking in Eclipse/M2E
Eclipse and Maven
- brings and installs companion Eclipse plugin
- creates custom Scala installations for Scala IDE
- exposes comprehensive configuration and logging
- provides identical compiler settings for Maven and Eclipse
- provides identical formatter settings for Maven and Eclipse
- works around spurious crashes of Scala IDE presentation compiler
- auto-restarts test application after full or incremental build in Eclipse
Primary Maven goals
Complete goals reference
Prerequisites:
- JDK-8 or JDK-9
- Eclipse 4.7, Maven M2E 1.8, Scala IDE 4.7.
- better, use Maven M2E 1.9 and Scala IDE 4.7 RC .
Involves two steps:
-
declare
scalor-maven-plugin
inpom.xml
editor
this makes plugin available for Maven and Eclipse M2E
make sure to provide Maven plugin goaleclipse-config
-
invoke from menu
Eclipse -> Project -> { Auto, Clean, Build }
this allows Maven plugin to install own Eclipse companion plugin
which in turn invokes M2E project configurator for Scala projects
Project update tips:
-
After an edit of
pom.xml
, propagate changes to Scala IDE
via context menuProject -> Maven -> Update Project...
-
Activate M2E Maven Console to review
Maven plugin and Eclipse plugin messages. -
If in doubt, review generated Eclipse descriptors:
.project, .classpath, .settings/scala-ide.
Normally, Scala IDE itself runs on the latest stable Scala Library at the time frame.
For example:
- Scala IDE
4.7.0
-> Scala Library2.12.3
Eclipse companion plugin provided by this Maven plugin needs to interact with Scala IDE and hence must run on the Scala Library from the same epoch:
- Scala IDE
4.7.0
->scalor-maven-plugin_2.12
However, compiler-bridge
module provides an isolation gateway
which allows scalor-maven-plugin_2.12
to build projects
with different Scala epoch, such as 2.11
, 2.12
, 2.13
Required version mapping is provided via scalor-maven-plugin
configuration entries:
<defineAuto>
<defineBridge>
<defineCompiler>
<definePluginList>
Project Examples:
- basic demo project
- test project for Scala Native
- test project for cross Scala 2.11, 2.12, 2.13
scalor-maven-plugin
project itself is a cross master / module build
Command line invocation:
mvn clean install -P scalor
<profile>
<id>scalor</id>
<build>
<plugins>
<!-- Disable default compiler. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<skip>true</skip>
<skipMain>true</skipMain>
</configuration>
</plugin>
<!-- Enable alternative compiler. -->
<plugin>
<groupId>com.carrotgarden.maven</groupId>
<artifactId>scalor-maven-plugin_2.12</artifactId>
<configuration>
<!-- Compiler bridge. -->
<defineBridge>
<dependency>
<groupId>org.scala-sbt</groupId>
<artifactId>compiler-bridge_${version.scala.epoch}</artifactId>
<version>${version.scala.zinc}</version>
</dependency>
</defineBridge>
<!-- Scala compiler. -->
<defineCompiler>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${version.scala.release}</version>
</dependency>
</defineCompiler>
<!-- Compiler plugins. -->
<definePluginList>
<dependency>
<groupId>org.scalamacros</groupId>
<artifactId>paradise_${version.scala.release}</artifactId>
<version>${version.scala.plugin.macro}</version>
</dependency>
<dependency>
<groupId>org.scala-js</groupId>
<artifactId>scalajs-compiler_${version.scala.release}</artifactId>
<version>${version.sjs.release}</version>
</dependency>
</definePluginList>
</configuration>
<executions>
<execution>
<!-- Subset of available. -->
<goals>
<!-- Setup Eclipse plugin. -->
<goal>eclipse-config</goal>
<!-- Transfer format settings. -->
<goal>eclipse-format</goal>
<!-- Manage test application. -->
<goal>eclipse-restart</goal>
<!-- Manage presentation compiler. -->
<goal>eclipse-prescomp</goal>
<!-- Add compilation sources. -->
<goal>register-macro</goal>
<goal>register-main</goal>
<goal>register-test</goal>
<!-- Compile sources. -->
<goal>compile-macro</goal>
<goal>compile-main</goal>
<goal>compile-test</goal>
<!-- Link runtime JS script. -->
<goal>scala-js-link-main</goal>
<goal>scala-js-link-test</goal>
<!-- Provide JS-VM environment for testing. -->
<goal>scala-js-env-prov-webjars</goal>
<goal>scala-js-env-prov-nodejs</goal>
<goal>scala-js-env-conf-nodejs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
cd /tmp
git clone git@github.com:random-maven/scalor-maven-plugin.git
cd scalor-maven-plugin
./mvnw.sh clean install -B -P skip-test