Git Product home page Git Product logo

scala-multi-version's Introduction

Scala Multi-Version Project

Demonstrates the use of different Scala versions in a multi-project Gradle build to compile, package, and execute the tests with the help of the plugin prokod/gradle-crossbuild-scala.

Use Cases

  • Project a: Builds with Scala 2.11 and 2.12.
  • Project b: Only builds with Scala 2.11 and depends on outgoing 2.11-compatible artifact of project a.
  • Project c: Builds with Scala 2.11 and 2.12 and depends on outgoing 2.11-compatible or 2.12-compatible artifact of project a.
  • Project d: Builds with Scala 2.11 and publishes its artifact to a binary repository. The generated POM declares transitive dependencies.
  • Project e: Builds with Scala 2.11 and 2.12 and defines a Test task that uses the Scala 2.11/2.12-compiled classes + test runtime dependencies to execute the tests.
  • Project f: Builds an Android project and depends on the outgoing 2.11-compatible artifact of project a. Requires the Android plugin to be disabled to build properly in IntelliJ CE.

Build Execution

The prokod/gradle-crossbuild-scala plugin introduces tasks for compiling the code and generating the JAR file per Scala version. For example, for Scala 2.11 you'd have a task named compileCrossBuildScala_212Scala and crossBuildScala_212Jar. The JAR task depends on the compilation task as it needs to generate the byte code to be bundled in the JAR file. The command line invocation below compiles and generates a JAR file for Scala 2.11 and 2.12 for the project a which is configured to support both Scala versions.

$ ./gradlew :a:crossBuildScala_211Jar :a:crossBuildScala_212Jar --console=verbose
> Task :a:compileCrossBuildScala_211Java NO-SOURCE
> Task :a:compileCrossBuildScala_211Scala
> Task :a:processCrossBuildScala_211Resources NO-SOURCE
> Task :a:crossBuildScala_211Classes
> Task :a:crossBuildScala_211Jar
> Task :a:compileCrossBuildScala_212Java NO-SOURCE
> Task :a:compileCrossBuildScala_212Scala
> Task :a:processCrossBuildScala_212Resources NO-SOURCE
> Task :a:crossBuildScala_212Classes
> Task :a:crossBuildScala_212Jar

At this time, the plugin doesn't support similar functionality for executing tests. Project e introduces custom code to execute Scala version-specific Test tasks. Each Test task resolves the classes produces for a specific Scala version and the dedicated dependencies. The tasks are called crossBuildScala_211Test for Scala 2.11 and crossBuildScala_212Test for Scala 2.12.

$ ./gradlew :e:crossBuildScala_211Test :e:crossBuildScala_212Test --console=verbose
> Task :e:compileCrossBuildScala_211Java NO-SOURCE
> Task :e:compileCrossBuildScala_211Scala
> Task :e:processCrossBuildScala_211Resources NO-SOURCE
> Task :e:crossBuildScala_211Classes
> Task :e:crossBuildScala_211Test
> Task :e:compileCrossBuildScala_212Java NO-SOURCE
> Task :e:compileCrossBuildScala_212Scala
> Task :e:processCrossBuildScala_212Resources NO-SOURCE
> Task :e:crossBuildScala_212Classes
> Task :e:crossBuildScala_212Test

Executing the standard tasks like build will simply compile the code, generate the JAR, and execute the tests with the versions of Scala that are assigned to the configurations implementation and testImplementation. The prokod/gradle-crossbuild-scala plugin doesn't come into play at all. Therefore, Scala multi-version functionality is not supported. Probably the right thing to do would be to disable those standard tasks to avoid confusion.

Open Issues

The following issues have been opened to address missing features and/or bugs encountered when using the plugin in the sample project.

scala-multi-version's People

Contributors

bmuschko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.