Gradle Kotlin DSL does not resolve properly
See original GitHub issueA Gradle Kotlin DSL project will not be resolved properly.
Environment
- Operating System: MacOS 10.15.7
- JDK version: 1.8/11
- Visual Studio Code version: 1.51.1
- Java extension version: 0.72.0
Steps To Reproduce
$ mkdir kotlin-dsl && cd "$_"
$ gradle init --dsl kotlin --type java-library --test-framework junit-jupiter --project-name kotlin-dsl --package org.example
> Task :init
Get more help with your project: https://docs.gradle.org/6.7.1/samples/sample_building_java_libraries.html
BUILD SUCCESSFUL in 556ms
2 actionable tasks: 2 executed
$ mv lib/build.gradle.kts .
$ mv lib/src src
$ rm -rf lib
$ echo 'rootProject.name = "kotlin-dsl"' > settings.gradle.kts
$ tree
.
βββ build.gradle.kts
βββ gradle
βΒ Β βββ wrapper
βΒ Β βββ gradle-wrapper.jar
βΒ Β βββ gradle-wrapper.properties
βββ gradlew
βββ gradlew.bat
βββ settings.gradle.kts
βββ src
βββ main
βΒ Β βββ java
βΒ Β βΒ Β βββ org
βΒ Β βΒ Β βββ example
βΒ Β βΒ Β βββ Library.java
βΒ Β βββ resources
βββ test
βββ java
βΒ Β βββ org
βΒ Β βββ example
βΒ Β βββ LibraryTest.java
βββ resources
$ code .
Executing the Gradle task properties via the Gradle tasks pane:
> Executing task: gradle: properties <
> Task :properties
------------------------------------------------------------
Root project
------------------------------------------------------------
allprojects: [root project 'kotlin-dsl']
ant: org.gradle.api.internal.project.DefaultAntBuilder@52160ca7
antBuilderFactory: org.gradle.api.internal.project.DefaultAntBuilderFactory@7ca9adb0
archivesBaseName: kotlin-dsl
artifacts: org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler_Decorated@786d9ca
asDynamicObject: DynamicObject for root project 'kotlin-dsl'
autoTargetJvmDisabled: false
baseClassLoaderScope: org.gradle.api.internal.initialization.DefaultClassLoaderScope@2b0317e4
buildDir: /Users/dev/tmp/kotlin-dsl/build
buildFile: /Users/dev/tmp/kotlin-dsl/build.gradle.kts
buildPath: :
buildScriptSource: org.gradle.groovy.scripts.TextResourceScriptSource@49124517
buildscript: org.gradle.api.internal.initialization.DefaultScriptHandler@78e7b5a8
childProjects: {}
class: class org.gradle.api.internal.project.DefaultProject_Decorated
classLoaderScope: org.gradle.api.internal.initialization.DefaultClassLoaderScope@652f557e
components: SoftwareComponentInternal set
configurationActions: org.gradle.configuration.project.DefaultProjectConfigurationActionContainer@499e6bf7
configurationTargetIdentifier: org.gradle.configuration.ConfigurationTargetIdentifier$1@7a91f917
configurations: configuration container
convention: org.gradle.internal.extensibility.DefaultConvention@21f031af
defaultArtifacts: extension 'defaultArtifacts'
defaultTasks: []
deferredProjectConfiguration: org.gradle.api.internal.project.DeferredProjectConfiguration@647f8acc
dependencies: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@5e848467
dependencyLocking: org.gradle.internal.locking.DefaultDependencyLockingHandler_Decorated@2b2887e1
depth: 0
description: null
displayName: root project 'kotlin-dsl'
distsDir: /Users/dev/tmp/kotlin-dsl/build/distributions
distsDirName: distributions
distsDirectory: property(org.gradle.api.file.Directory, map(org.gradle.api.file.Directory property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/dev/tmp/kotlin-dsl/build)) org.gradle.api.internal.file.DefaultFilePropertyFactory$PathToDirectoryTransformer@bf5b662))
docsDir: /Users/dev/tmp/kotlin-dsl/build/docs
docsDirName: docs
ext: org.gradle.internal.extensibility.DefaultExtraPropertiesExtension@13c4643a
extensions: org.gradle.internal.extensibility.DefaultConvention@21f031af
fileOperations: org.gradle.api.internal.file.DefaultFileOperations@69996d99
fileResolver: org.gradle.api.internal.file.BaseDirFileResolver@6e1f8c4
gradle: build 'kotlin-dsl'
gradleKotlinDsl.projectAccessorsClassPath: AccessorsClassPath(bin=[/Users/dev/.gradle/caches/6.7.1/kotlin-dsl/accessors/69ecgqbvtrp0sqcsz4otxo0m1/classes], src=[/Users/dev/.gradle/caches/6.7.1/kotlin-dsl/accessors/69ecgqbvtrp0sqcsz4otxo0m1/sources])
group:
identityPath: :
inheritedScope: org.gradle.internal.extensibility.ExtensibleDynamicObject$InheritedDynamicObject@208118dc
java: extension 'java'
javaInstalls: org.gradle.jvm.toolchain.internal.DefaultJavaInstallationRegistry@10d44d42
javaToolchains: extension 'javaToolchains'
layout: org.gradle.api.internal.file.DefaultProjectLayout@32830f64
libsDir: /Users/dev/tmp/kotlin-dsl/build/libs
libsDirName: libs
libsDirectory: property(org.gradle.api.file.Directory, map(org.gradle.api.file.Directory property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, /Users/dev/tmp/kotlin-dsl/build)) org.gradle.api.internal.file.DefaultFilePropertyFactory$PathToDirectoryTransformer@3badf628))
listenerBuildOperationDecorator: org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator@13c24e79
logger: org.gradle.internal.logging.slf4j.OutputEventListenerBackedLogger@578975df
logging: org.gradle.internal.logging.services.DefaultLoggingManager@214eaf1e
model: project :
modelIdentityDisplayName: null
modelRegistry: org.gradle.model.internal.registry.DefaultModelRegistry@b9c7c7c
modelSchemaStore: org.gradle.model.internal.manage.schema.extract.DefaultModelSchemaStore@5ed2d0f5
module: org.gradle.api.internal.artifacts.ProjectBackedModule@11e98ad7
mutationState: project :
name: kotlin-dsl
normalization: org.gradle.normalization.internal.DefaultInputNormalizationHandler_Decorated@5fd4d791
objects: org.gradle.api.internal.model.DefaultObjectFactory@5e64eb94
parent: null
parentIdentifier: null
path: :
pluginManager: org.gradle.api.internal.plugins.DefaultPluginManager_Decorated@a068919
plugins: [org.gradle.api.plugins.HelpTasksPlugin@62916bb9, org.gradle.buildinit.plugins.BuildInitPlugin@1b004025, org.gradle.buildinit.plugins.WrapperPlugin@6241309a, org.gradle.language.base.plugins.LifecycleBasePlugin@5c31338a, org.gradle.api.plugins.BasePlugin@35945716, org.gradle.api.plugins.JvmEcosystemPlugin@2c8c38e9, org.gradle.api.plugins.ReportingBasePlugin@47221802, org.gradle.api.plugins.JavaBasePlugin$Inject@125ade0f, org.gradle.api.plugins.JavaPlugin@5e107b5, org.gradle.api.plugins.JavaLibraryPlugin@48e73c90, org.gradle.kotlin.dsl.provider.plugins.KotlinScriptRootPlugin@1f52df86, org.gradle.kotlin.dsl.provider.plugins.KotlinScriptBasePlugin@5bbcd0c5]
processOperations: org.gradle.process.internal.DefaultExecActionFactory$DecoratingExecActionFactory@566da8a8
project: root project 'kotlin-dsl'
projectConfigurator: org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator@271f1d49
projectDir: /Users/dev/tmp/kotlin-dsl
projectEvaluationBroadcaster: ProjectEvaluationListener broadcast
projectEvaluator: org.gradle.configuration.project.LifecycleProjectEvaluator@2e3858c3
projectPath: :
projectRegistry: org.gradle.api.internal.project.DefaultProjectRegistry@13bf8f39
properties: {...}
providers: org.gradle.api.internal.provider.DefaultProviderFactory_Decorated@28ac4d0e
publicType: org.gradle.api.plugins.BasePluginConvention
rawSourceCompatibility: null
rawTargetCompatibility: null
reporting: extension 'reporting'
reportsDir: /Users/dev/tmp/kotlin-dsl/build/reports
repositories: repository container
resources: org.gradle.api.internal.resources.DefaultResourceHandler@7786e807
rootDir: /Users/dev/tmp/kotlin-dsl
rootProject: root project 'kotlin-dsl'
script: false
scriptHandlerFactory: org.gradle.api.internal.initialization.DefaultScriptHandlerFactory@1b144874
scriptPluginFactory: org.gradle.configuration.ScriptPluginFactorySelector@743dda68
serviceRegistryFactory: org.gradle.internal.service.scopes.ProjectScopeServices$$Lambda$549/0x00000008007bf840@6066908e
services: ProjectScopeServices
sourceCompatibility: 11
sourceSets: SourceSet container
standardOutputCapture: org.gradle.internal.logging.services.DefaultLoggingManager@214eaf1e
state: project state 'EXECUTED'
status: integration
subprojects: []
targetCompatibility: 11
taskThatOwnsThisObject: null
tasks: task set
testReportDir: /Users/dev/tmp/kotlin-dsl/build/reports/tests
testReportDirName: tests
testResultsDir: /Users/dev/tmp/kotlin-dsl/build/test-results
testResultsDirName: test-results
version: unspecified
BUILD SUCCESSFUL in 108ms
1 actionable task: 1 executed
Current Result
A Gradle project with Kotlin DSL will not resolve properly.
Expected Result
A Gradle project with Kotlin DSL will resolve properly.
Additional Informations
$ code --version
1.51.1
e5a624b788d92b8d34d1392e4c4d9789406efe8f
x64
$ code --list-extensions --show-versions
fwcd.kotlin@0.2.18
mathiasfrohlich.Kotlin@1.7.1
naco-siren.gradle-language@0.2.3
redhat.java@0.72.0
richardwillis.vscode-gradle@3.5.2
richardwillis.vscode-gradle-extension-pack@0.0.2
VisualStudioExptTeam.vscodeintellicode@1.2.10
vscjava.vscode-java-debug@0.29.0
vscjava.vscode-java-dependency@0.15.0
vscjava.vscode-java-pack@0.12.0
vscjava.vscode-java-test@0.26.0
vscjava.vscode-maven@0.26.0
$ cat ~/Library/Application\ Support/Code/User/settings.json | jq '. | to_entries | map(select(.key | match("kotlin";"i"),match("java";"i")))'
[
{
"key": "java.configuration.runtimes",
"value": [
{
"name": "JavaSE-1.8",
"path": "/Users/dev/Library/jabba/jdk/zulu@1.8.272/Contents/Home"
},
{
"name": "JavaSE-11",
"path": "/Users/dev/Library/jabba/jdk/zulu@1.11.0-9/Contents/Home"
}
]
},
{
"key": "kotlin.compiler.jvm.target",
"value": "1.8"
},
{
"key": "java.home",
"value": "/Users/dev/Library/jabba/jdk/zulu@1.11.0-9/Contents/Home"
}
]
If you do the same with Groovy DSL it works:
$ mkdir groovy-dsl && cd "$_"
$ gradle init --dsl groovy --type java-library --test-framework junit-jupiter --project-name kotlin-dsl --package org.example
> Task :init
Get more help with your project: https://docs.gradle.org/6.7.1/samples/sample_building_java_libraries.html
BUILD SUCCESSFUL in 556ms
2 actionable tasks: 2 executed
$ mv lib/build.gradle .
$ mv lib/src src
$ rm -rf lib
$ echo 'rootProject.name = "groovy-dsl"' > settings.gradle
$ tree
.
βββ build.gradle
βββ gradle
βΒ Β βββ wrapper
βΒ Β βββ gradle-wrapper.jar
βΒ Β βββ gradle-wrapper.properties
βββ gradlew
βββ gradlew.bat
βββ settings.gradle
βββ src
βββ main
βΒ Β βββ java
βΒ Β βΒ Β βββ org
βΒ Β βΒ Β βββ example
βΒ Β βΒ Β βββ Library.java
βΒ Β βββ resources
βββ test
βββ java
βΒ Β βββ org
βΒ Β βββ example
βΒ Β βββ LibraryTest.java
βββ resources
13 directories, 8 files
$ code .
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Android-related dependencies methods could not be resolved ...
I'm migrating simple gradle project to kotlin-dsl and faced a problem: methods api , implementation , compileOnly , related to gradle 3.0.0+Β ...
Read more >Gradle Kotlin DSL, error resolving KotlinCompile in build ...
I have tried to do a complete Invalidate & Restart which did not change anything. removed the .idea directory, did not change anything....
Read more >org.gradle.kotlin.kotlin-dsl was not found - Stack Overflow
This is the correct answer!! Try to find the latest version of the 'kotlin-dsl' plugin, and use it in either of (groovy or...
Read more >Gradle Kotlin DSL Primer
If you can run the build successfully from the command line but your script editor is complaining, then you should try restarting your...
Read more >Configure a Gradle project | Kotlin Documentation
In the build module, you may have related compile tasks, for example: ... main and test source set compile tasks are not related....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hmm, would you maybe so kind to mention it somewhere? No fun spending 1 hour on a bug report β¦
https://github.com/redhat-developer/vscode-java#quick-start
=>
https://github.com/redhat-developer/vscode-java#features
=>
https://code.visualstudio.com/docs/languages/java#_java-project-in-vs-code
=>
This is a duplicated feature request with https://github.com/redhat-developer/vscode-java/issues/632. But it finally depends on buildship component to provide the support, see https://github.com/eclipse/buildship/issues/222.