Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't configure kotlinOptions after upgrade to gradle 5.6.3 using kotlin-dsl #11083

Closed
b95505017 opened this issue Oct 18, 2019 · 7 comments
Closed
Assignees
Labels
Milestone

Comments

@b95505017
Copy link

  Line 172:         jvmTarget = "1.8"
                    ^ Unresolved reference: jvmTarget

  Line 173:         freeCompilerArgs = freeCompilerArgs + listOf(
                    ^ Unresolved reference: freeCompilerArgs

  Line 173:         freeCompilerArgs = freeCompilerArgs + listOf(
                                       ^ Unresolved reference: freeCompilerArgs
@b95505017 b95505017 changed the title Can't configure kotlinOptions after upgrade to gradle 5.6.3 using kotlin dsl Can't configure kotlinOptions after upgrade to gradle 5.6.3 using kotlin-dsl Oct 18, 2019
@eskatos
Copy link
Member

eskatos commented Oct 19, 2019

Thanks for the report @b95505017
It's impossible to tell what is happening without knowing what's above this "Line 172".
Could you please tell us a bit more, sharing a reproducer would be ideal.

@robinlinden
Copy link

robinlinden commented Oct 20, 2019

I run into the same issue after updating to 5.6.3 (https://github.com/robinlinden/aTox/tree/gradle-5.6.3):

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Projects\aTox\app\build.gradle.kts' line: 33

* What went wrong:
Script compilation errors:

  Line 33:         jvmTarget = Java.version.toString()
                   ^ Unresolved reference: jvmTarget

  Line 34:         freeCompilerArgs = listOf("-XXLanguage:+InlineClasses")
                   ^ Unresolved reference: freeCompilerArgs

2 errors

https://github.com/robinlinden/aTox/blob/c47d912be488c1e5ef7c76d2e740953231702eec/app/build.gradle.kts#L12-L35

Just running a gradlew build should be enough to reproduce it and it fails on Travis with the same error: https://travis-ci.org/robinlinden/aTox/builds/600319992#L1161

@eskatos
Copy link
Member

eskatos commented Oct 21, 2019

Thanks @robinlinden, the reproducer helped.

With Gradle 5.6.2, android.kotlinOptions {} is a generated accessor for the kotlinOptions extension of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions on the android extension.

With Gradle 5.6.3, that same accessor is typed Any.

@eskatos eskatos added a:regression This used to work in:kotlin-dsl and removed a:bug labels Oct 21, 2019
@eskatos
Copy link
Member

eskatos commented Oct 21, 2019

You can work around that by using the API instead of the generated accessor:

android {
    (this as ExtensionAware).configure<KotlinJvmOptions> {
        jvmTarget = "1.8"
    }
}

or by using the more dynamic Groovy builder:

android {
    withGroovyBuilder {
        "kotlinOptions" {
            setProperty("jvmTarget", "1.8")
        }
    }
}

@b95505017
Copy link
Author

@eskatos Will future version change back?

@jjohannes jjohannes added this to the 6.0 RC2 milestone Oct 29, 2019
@eskatos eskatos assigned bamboo and unassigned eskatos Oct 29, 2019
@jjohannes
Copy link
Contributor

Fix for 6.0 (#11171) is now on release

@jjohannes jjohannes modified the milestones: 6.0 RC2, 5.6.4 Oct 30, 2019
bamboo added a commit that referenced this issue Oct 30, 2019
And introduce a stricter accessor type precedence order.

The accessor type is the first public Kotlin type found in the given extension
type hierarchy considering all the types in the following order:
* the extension type itsef
* its superclasses excluding `java.lang.Object`
* all supported interfaces ordered by:
  - subtyping first:
      subtypes before supertypes
  - where it's found in the class hierarchy:
      subclass interfaces before superclass interfaces

Fixes #11083
@bamboo
Copy link
Member

bamboo commented Oct 30, 2019

Fix for 5.6 (#11191) is now on release-5.6.

@bamboo bamboo closed this as completed Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
@bamboo @eskatos @b95505017 @jjohannes @robinlinden and others