Code Monkey home page Code Monkey logo

gradle-scala-multiversion-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-scala-multiversion-plugin's Issues

Scaladocs overwrite each other when created

When using the scaladoc task with the multiversion-plugin first one version's docs get created in build/docs/scaladoc/ then the next version's docs get created in the same location.

Your docs likely are the same, but this could cause issues for anyone wishing to have both sets of documents. Especially with the style change between 2.11.x and 2.12.x

Submodules built with a subset of Scala versions?

Is it possible to specify that some submodule should be built only for a subset of Scala versions (eg. root module with 2.10-2.12 and a submodule just 2.10)? Or in other words exclude a project based on the Scala version. Thanks.

Dotty support

Any plans to support dotty/scala 3? Would be awesome to be able to add 3.0.0-M3 to scalaVersions and things would just work.

Would also be awesome to have something similar to withDottyCompat like in sbt

I tried adapting an gradle project to compile with dotty but it seems scala 2.13 is still being used. See https://github.com/jtjeferreira/mongo-java-driver/tree/dotty

Gradle 7 error on publishing

When using Gradle 7 and the Maven Publish plugin, I get:

Execution failed for task ':myproject:generatePomFileForApiPublication'.
> Could not apply withXml() to generated POM
   > Could not get unknown property 'compile' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.

Removing this plugin solves the issue. So I think the plugin should be using a different property here:

To replicate, run:

./gradlew clean generatePomFileForApiPublication -p myproject

I can confirm it's an issue in versions 1.0.37 and 1.0.38-main-SNAPSHOT.

only the first scala version jar is created

when the second round happens I see all is UP-TO-DATE so nothing happens:

:compileJava NO-SOURCE
Errors occurred while build effective model from 
:compileScala UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava NO-SOURCE
:compileTestScala
:processTestResources NO-SOURCE
:testClasses
:test
Discovery starting.
Discovery completed in 165 milliseconds.
Run starting. Expected test count is: 0
DataSourceInstanceTests:
Table details should be provided
- should for instance !!! IGNORED !!!
CVTestBase:
UserConnectionManagerTests:
UserConnection
- should connect to CV !!! IGNORED !!!
Run completed in 211 milliseconds.
Total number of tests run: 0
Suites: completed 4, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 2, pending 0
No tests were executed.
:check
:build
:recurseWithScalaVersion_2.12.4
:v9:compileJava NO-SOURCE
:v9:compileScala UP-TO-DATE
:v9:processResources NO-SOURCE
:v9:classes UP-TO-DATE
:v9:jar UP-TO-DATE
:v9:assemble UP-TO-DATE
:v9:compileTestJava NO-SOURCE
:v9:compileTestScala UP-TO-DATE
:v9:processTestResources NO-SOURCE
:v9:testClasses UP-TO-DATE
:v9:test UP-TO-DATE
:v9:check UP-TO-DATE
:v9:build UP-TO-DATE

BUILD SUCCESSFUL in 22s

Generated maven pom contains `_%%` in dependencies

even with maven-publish

Example:

...
<dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>%scala-version%</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.typesafe.akka</groupId>
      <artifactId>akka-actor_%%</artifactId>
      <version>2.5.25</version>
      <scope>runtime</scope>
    </dependency>
</dependencies>

baseName property deprecation

After upgrading to gradle 6, I came across this warning:

The baseName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveBaseName property instead.

I removed all external dependencies and the error was gone. I added them back one by one and found that it was caused by this repo. Hopefully it is simple to resolve.

Builds fail if gradle-scala-multiversion-plugin is used with Gradle 5 dependency locking

Unfortunately, it looks like this plugin has issues with Gradle 5's new dependency locking feature.

Let's say we're using gradle-scala-multiversion-plugin to build a project against Scala 2.11 and 2.12, but we're using dynamic versions for one of our dependencies

build.gradle (snippet)

plugins {
  id 'com.adtran.scala-multiversion-plugin' version "1.0.34"
  id 'scala'
  id 'java-library'
}

dependencies {
  api 'org.scalactic:scalactic_%%:[3.0.0,)'
}

gradle.properties

scalaVersions = 2.11.8,2.12.3

If we lock the dependency versions, the first build that writes the dependency locks works just fine:

> gradle build --write-locks
...
BUILD SUCCESSFUL

But if we try to build after locking dependency versions...

> gradle build
> Task :compileScala FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileScala'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Resolved 'org.scalactic:scalactic_2.11:3.0.3' which is not part of the dependency lock state
   > Did not resolve 'org.scalactic:scalactic_2.12:3.0.3' which is part of the dependency lock state

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
1 actionable task: 1 executed

When the build is executed with --write-locks, the lock files are updated both when the build tasks run for Scala 2.11 and Scala 2.12, but Gradle only keeps the dependencies that were last resolved (the ones for Scala 2.12).

When the build is executed after the locks are created, the build first runs against Scala 2.11, but since the lock state is for Scala 2.12, the build fails.

Dependencies cannot use `_%%` in constraints

I have a build file with some scala dependencies in there, and want to cross-compile the module.
My dependencies are using constraints to set the version, see:

dependencies {
    implementation("org.scala-lang:scala-library")
    testImplementation("org.scalatest:scalatest_%%")

    constraints {
        dependencies {
            implementation("org.scala-lang:scala-library:%scala-version%")
            testImplementation("org.scalatest:scalatest_%%:3.2.3")
        }
    }

This results in the following error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':myproject:compileTestScala'.
> Could not resolve all files for configuration ':myproject:testCompileClasspath'.
   > Could not resolve org.scalatest:scalatest_%%.
     Required by:
         project :myproject
      > Invalid format: 'org.scalatest:scalatest_2.13:'. Group, name and version cannot be empty. Correct example: 'org.gradle:gradle-core:1.0'

[Edge case] Included build has same name as a project of the main build

Hi folks,

Thanks for this plugin, we have found it really useful.

Recently we refactored one of our gradle projects to split into 2 subprojects. When we run tasks with -PallScalaVersions, we get an error like:

$ gw clean compileScala -PallScalaVersions
...
Execution failed for task ':recurseWithScalaVersion_2.12.10'.
> Included build in /Users/tomnis/foo has name 'foo' which is the same as a project of the main build.

We are not using composite builds, and my understanding is this plugin does not use composite builds either, but GradleBuild uses a similar mechanism.

One of our subprojects has the same name as our repository, but we override rootProject.name in settings.gradle.
We are using gradle 6.5.1 and multiversion 1.0.35.

Based on some further reading I believe the root cause is a regression in gradle 6.x. I think we are running into a combination of these 2 issues:

gradle/gradle#12872
gradle/gradle#3828 (we set rootProject.name in our settings.gradle, but that appears to not take effect for dynamic recursion tasks)

In issue 12872, @/ark100 suggested a workaround of setting buildName on dynamic GradleBuild tasks:

task task1(type: GradleBuild) {
    buildFile = file('gen/build.gradle')
    // ...
    if(6 <= gradle.gradleVersion.split(Pattern.quote('.'))[0].toInteger() ){
        buildName = "t1"
    }
}

I modified ScalaMultiVersionPlugin.groovy and published a local snapshot, this workaround seems to work for us.
tomnis@a21ba5a

I am unclear whether this repo is still being maintained, but just wanted y'all to be aware of this edge case and put this out there for anyone else running into the same issue. Thanks again for this plugin, it has been really handy for us.

Recursion into other version does not honor 1st version's command line options

When recursing into the 2nd version (e.g. when compiling 2.12 and 2.11 in order, 2.11 is the 2nd version), the command line options of the first version are not honored.

We discovered this when we used command line flags to skip tests. E.g. ./gradlew publish -x test
On the first publish task, it will skip testing.
On the 2nd publish task, it will not skip testing.

Only one jar created when scalaVersions is in ascending order

When I used scalaVersions = 2.11.8, 2.12.1 it only created the 2.12.1 jar, however it worked as expected when I swapped to scalaVersions = 2.12.1, 2.11.8. I wouldn't suggest that this necessarily needs a fix but it should be made explicit in the documentation.

%scala-version% placeholder does not work when not in version position

When using %scala-version% outside a version position (e.g. as required by some Scala compiler plugins, the translation is not applied, e.g.

        scalaCompilerPlugin "org.scalamacros:paradise_%scala-version%:2.1.0"

is translated to repository/public/org/scalamacros/paradise_%25scala-version%25/2.1.0/paradise_%25scala-version%25-2.1.0.pom that can't be found

When the same placeholder is used in a version position, it works fine, as in

        implementation("org.scala-lang:scala-library:%scala-version%")

Clean removes prior builds

If I run gradle clean, then of course my build directory is cleaned.

If I run gradle assemble, then I see the multiple versions output in build/lib. ๐Ÿ‘

If I run gradle clean assemble, then I see output in build/lib for only the last Scala version defined in the scalaVersions property.

This leads me to believe without looking at the code that this plugin re-runs every task for each Scala version.

Maybe it should only run clean once?

Issues with subproject setup

Hi,
First of all, thank you for the plugin.

I'm trying to use this plugin in a subproject and facing an issue where all my projects, even unrelated subprojects are built multiple times as the plugin always adds 1-2 more tasks (depending on how many scala versions we use).

If found the following configuration to work better as it adds the extra build tasks to one of the active tasks that the current scala (sub)project has, effectively making it only run for projects that has the plugin turned on for.

        project.afterEvaluate {
            def recurseScalaVersions = determineScalaVersions()
            if (!project.ext.has("recursed") && !project.gradle.ext.has("recursionTaskAdded")) {
                def buildVersionTasks = recurseScalaVersions.collect { ver ->
                    project.tasks.create("recurseWithScalaVersion_$ver", GradleBuild) {
                        startParameter = project.gradle.startParameter.newInstance()
                        startParameter.projectProperties["scalaVersion"] = ver
                        startParameter.projectProperties["recursed"] = true
                        startParameter.excludedTaskNames = getRunOnceTasks()
                        tasks = project.gradle.startParameter.taskNames
                    }

                }
                def activeSubProjectTasks = findActiveTasks()
                if (!activeSubProjectTasks.isEmpty()) {
                    buildVersionTasks.each { activeSubProjectTasks.head().finalizedBy(it.path) }
                }
                project.gradle.ext.recursionTaskAdded = true
            }
        }
    }
    private List<String> findActiveTasks() {
        def startingTaskNames = project.gradle.startParameter.taskNames
        def subProjectTasksByStartingNames = startingTaskNames.collect {
            project.getTasksByName(it, false)
        }.flatten()
        if (subProjectTasksByStartingNames.isEmpty()) {
            return project.getDefaultTasks()
        }
        subProjectTasksByStartingNames
    }

Let me know if you have a better solution or if I should open a pr with my changes.

Works incorrectly with multiple modules

I have a multimodule project, where different modules should be built against different sets of java versions.
Say module a should be built against 2.11.2 and 2.12.4, while module b should be built only against 2.12

Currently build has weird recursion where a recurses into building b with its own scalaVersions and obviously second one fails because of invalid dependency.

%% placeholder is not working in exclusion clauses

Hello,

Consider this dependency clause

dependencies {
    compile(group: 'io.monix', name: 'monix_%%', version: '3.0.0-RC2') {
        exclude group: 'org.typelevel', module: 'cats-effect_%%'
    }
}

scala-multiversion-plugin does not replace placeholder in exclusion clause which leads to this result in resulting pom.xml

    <dependency>
      <groupId>io.monix</groupId>
      <artifactId>monix_2.11</artifactId>
      <version>3.0.0-RC2</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>cats-effect_%%</artifactId>
          <groupId>org.typelevel</groupId>
        </exclusion>
      </exclusions>
    </dependency>

which is incorrect.
I haven't dive deep enough in groovy and plugin code, is it hard to fix this issue?

"Scala signature has wrong version" in CI build with subprojects

First, I tried to create a minimal working example to reproduce this error. The project is here and the build that fails is here.
The full error is:

java.io.IOException: Scala signature B has wrong version
 expected: 5.0
 found: 5.2 in B.class
	at scala.reflect.internal.pickling.UnPickler$Scan.checkVersion(UnPickler.scala:124)

It seems that with two (or more) Scala subprojects where one of which depends on the other, Gradle runs them in parallel (as you can see here) using a different scala compiler version, causing the exception reported above.

One workaround I found for now is to set the Gradle max-workers to 1 (as you can see here)

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.