random-maven / scalor-maven-plugin

Build integrator for Java, Scala, Scala.macro, Scala.js, Scala.native, Eclipse and Maven.
https://random-maven.github.io/scalor-maven-plugin/2.12/plugin-info.html
Other
50 stars 6 forks source link
eclipse eclipse-plugin java m2e macros maven maven-plugin scala scala-ide scala-native scalajs

Scalor Maven Plugin

Build integrator for Java, Scala, Scala.macro, Scala.js, Scala.native, Eclipse and Maven.

Project License Travis Status Appvey Status Lines of Code

Install Production Release Development Release
Scalor Plugin 1.X for Scala IDE 4.7
Central Bintray

Similar plugins

Getting started

Plugin features

Scala

Scala.macro

Scala.js

Scala.native

Eclipse and Maven

Primary Maven goals

Complete goals reference

Eclipse setup

Prerequisites:

Involves two steps:

  1. declare scalor-maven-plugin in pom.xml editor
    this makes plugin available for Maven and Eclipse M2E
    make sure to provide Maven plugin goal eclipse-config

  2. 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:

Version mapping

Normally, Scala IDE itself runs on the latest stable Scala Library at the time frame.

For example:

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:

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>

Usage example

Project Examples:

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.scalajs.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>

Build yourself

Linux

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

Windows