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

Support navigation to sources of included Kotlin libraries #96

Closed
bamboo opened this Issue Jul 13, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@bamboo
Member

bamboo commented Jul 13, 2016

No description provided.

@bamboo bamboo added this to the 1.0.0 milestone Jul 13, 2016

@bamboo bamboo self-assigned this May 9, 2017

@bamboo bamboo modified the milestones: 0.9.0, 1.0.0 May 9, 2017

@bamboo

This comment has been minimized.

Show comment
Hide comment
@bamboo

bamboo May 9, 2017

Member

Requires introducing a dependency on gradle-platform-jvm from KotlinBuildScriptModelBuilder so it can query source artifacts using an ArtifactResolutionQuery such as:

fun resolveKotlinSourcesUsing(dependencyHandler: DependencyHandler) =
    dependencyHandler
        .createArtifactResolutionQuery()
        .forComponents(kotlinComponent("kotlin-stdlib"), kotlinComponent("kotlin-reflect"))
        .withArtifacts(JvmLibrary::class.java, SourcesArtifact::class.java)
        .execute()
        .resolvedComponents
        .flatMap { it.getArtifacts(SourcesArtifact::class.java) }
        .filterIsInstance<ResolvedArtifactResult>()
        .map { it.file }

fun kotlinComponent(module: String): ModuleComponentIdentifier =
    moduleId("org.jetbrains.kotlin", module, embeddedKotlinVersion)

fun moduleId(group: String, module: String, version: String) =
    object : ModuleComponentIdentifier {
        override fun getGroup() = group
        override fun getModule() = module
        override fun getVersion() = version
        override fun getDisplayName() = "$group:$module:$version"
    }

In order to introduce the dependency, first KotlinBuildScriptModelBuilder must be moved to a separated module since gradle-core depends on gradle-script-kotlin and gradle-platform-jvm depends on gradle-core, #304 provides a good opportunity for that.

Member

bamboo commented May 9, 2017

Requires introducing a dependency on gradle-platform-jvm from KotlinBuildScriptModelBuilder so it can query source artifacts using an ArtifactResolutionQuery such as:

fun resolveKotlinSourcesUsing(dependencyHandler: DependencyHandler) =
    dependencyHandler
        .createArtifactResolutionQuery()
        .forComponents(kotlinComponent("kotlin-stdlib"), kotlinComponent("kotlin-reflect"))
        .withArtifacts(JvmLibrary::class.java, SourcesArtifact::class.java)
        .execute()
        .resolvedComponents
        .flatMap { it.getArtifacts(SourcesArtifact::class.java) }
        .filterIsInstance<ResolvedArtifactResult>()
        .map { it.file }

fun kotlinComponent(module: String): ModuleComponentIdentifier =
    moduleId("org.jetbrains.kotlin", module, embeddedKotlinVersion)

fun moduleId(group: String, module: String, version: String) =
    object : ModuleComponentIdentifier {
        override fun getGroup() = group
        override fun getModule() = module
        override fun getVersion() = version
        override fun getDisplayName() = "$group:$module:$version"
    }

In order to introduce the dependency, first KotlinBuildScriptModelBuilder must be moved to a separated module since gradle-core depends on gradle-script-kotlin and gradle-platform-jvm depends on gradle-core, #304 provides a good opportunity for that.

bamboo added a commit that referenced this issue May 11, 2017

Introduce `tooling-builders` module
So `KotlinBuildScriptModelBuilder` can depend on `gradle-platform-jvm`
to execute `SourcesArtifact` resolution queries.

The module is still empty as we first need to patch Gradle's
`DynamicModulesClassPathProvider` to load it as part of the
`GRADLE_EXTENSIONS` classpath.

See #96

bamboo added a commit that referenced this issue May 16, 2017

bamboo added a commit that referenced this issue May 17, 2017

@bamboo bamboo closed this May 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment