gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 434 forks source link

Build error in hello-kapt sample #1392

Closed IgorGanapolsky closed 5 years ago

IgorGanapolsky commented 5 years ago

Expected Behavior

Project should build in IntelliJ IDE without errrors/warnings.

Make project compatible with IntelliJ IDE

Current Behavior

See screenshot. There is a build warning (Type mismatch) in the application { } block in build.gradle.kts

Make this warning go away.

Context

Cannot build the sample

Steps to Reproduce (for bugs)

https://gradle.com/s/55hnsqk5xenlu

a) Open project in IntelliJ IDEA b) View build.gradle.kts file

Your Environment

IntelliJ IDEA 2019.3 EAP (Ultimate Edition) Build #IU-193.4386.10, built on October 8, 2019 IntelliJ IDEA EAP User Expiration date: November 7, 2019 Runtime version: 11.0.4+10-b517.1 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.15 GC: ParNew, ConcurrentMarkSweep Memory: 1979M Cores: 16

Screen Shot 2019-10-14 at 11 40 29 AM
StefMa commented 5 years ago

According to the build scan it can build. There is no issue. It's only a 'visualization' issue.

Do you see at the top of the file in IntelliJ a (I guess it is yellow) message like "apply new context" or something? Then click it. It should resolve the red warnings...

On Mon, Oct 14, 2019, 5:50 PM Igor Ganapolsky notifications@github.com wrote:

Expected Behavior

Project should build in IntelliJ IDE without errrors/warnings.

Make project compatible with IntelliJ IDE Current Behavior

See screenshot. There is a build warning (Type mismatch) in the application { } block in build.gradle.kts

Make this warning go away. Context

Cannot build the sample Steps to Reproduce (for bugs)

https://gradle.com/s/55hnsqk5xenlu

a) Open project in IntelliJ IDEA b) View build.gradle.kts file Your Environment

IntelliJ IDEA 2019.3 EAP (Ultimate Edition) Build #IU-193.4386.10, built on October 8, 2019 IntelliJ IDEA EAP User Expiration date: November 7, 2019 Runtime version: 11.0.4+10-b517.1 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.15 GC: ParNew, ConcurrentMarkSweep Memory: 1979M Cores: 16 [image: Screen Shot 2019-10-14 at 11 40 29 AM] https://user-images.githubusercontent.com/201209/66764626-2d006e80-ee78-11e9-814b-facc96bcd775.png

  • Build scan URL: https://gradle.com/s/55hnsqk5xenlu
  • gradle --version 5.4
  • Version of IntelliJ or Android Studio (in About menu you can copy version information)
  • Version of the Kotlin Plugin used in IntelliJ or Android Studio (in the Configure Kotlin Plugin Updates preference panel)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gradle/kotlin-dsl-samples/issues/1392?email_source=notifications&email_token=ACOBQ67MNKBJXHKZC7CHWQDQOSIL5A5CNFSM4JAQ6OQ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HRUGJIQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOBQ66NBOLOQQXP354ICEDQOSIL5ANCNFSM4JAQ6OQQ .

IgorGanapolsky commented 5 years ago

There is no such option

apply new context

see full screenshot:

Screen Shot 2019-10-14 at 1 33 38 PM
eskatos commented 5 years ago

Thanks for the report @IgorGanapolsky. As @StefMa said, this is a IDE problem. It is due to a mismatch in IntelliJ setup between the JDK used for Gradle and the JDK used for the project sources. The script editor can't find java.lang.String!

This is https://github.com/gradle/gradle/issues/9195

Using the same Java version for Gradle in IntelliJ and your Project SDK in IntelliJ will fix this. If you can't use the same Java version for Gradle in IntelliJ and your Project SDK in IntelliJ then you'll need to be using Gradle >=6.0 and the Kotlin IntelliJ Plugin >= 1.3.50.

Closing, please reopen if the problem persists after applying the above.