Skip to content

Commit

Permalink
Merge pull request #58 from sourcegraph/nsc/debug-project-ootb
Browse files Browse the repository at this point in the history
configure debug-project to use jar from :semanticdb-kotlinc:shadowJar
  • Loading branch information
Strum355 authored Jul 17, 2023
2 parents cf6fc09 + 2487965 commit 582c898
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.palantir.gradle.gitversion.VersionDetails
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import groovy.lang.Closure
import org.gradle.jvm.toolchain.internal.CurrentJvmToolchainSpec

plugins {
kotlin("jvm") version "1.5.30"
Expand Down
27 changes: 20 additions & 7 deletions debug-project/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.collections.mapOf

plugins {
kotlin("jvm")
Expand All @@ -20,8 +17,24 @@ val semanticdbJar: Configuration by configurations.creating {

dependencies {
implementation(kotlin("stdlib"))
semanticdbJar(project(mapOf(
"path" to ":" + projects.semanticdbKotlinc.name,
"configuration" to "semanticdbJar"
)))
semanticdbJar(project(
path = ":${projects.semanticdbKotlinc.name}",
configuration = "semanticdbJar"
))
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
dependsOn(":${projects.semanticdbKotlinc.name}:shadowJar")
val targetroot = File(project.buildDir, "semanticdb-targetroot")
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xplugin=${semanticdbJar.first()}",
"-P",
"plugin:semanticdb-kotlinc:sourceroot=${projectDir.path}",
"-P",
"plugin:semanticdb-kotlinc:targetroot=${targetroot}"
)
}
}
18 changes: 5 additions & 13 deletions semanticdb-kotlinc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import java.net.URI
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.publish.maven.MavenPublication

Expand Down Expand Up @@ -50,30 +49,23 @@ dependencies {
}

tasks.withType<KotlinCompile> {
dependsOn(projects.semanticdbKotlin.dependencyProject.tasks.build.get().path)
dependsOn(":${projects.semanticdbKotlin.name}:build")
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf("-Xinline-classes")
}
}

val semanticdbJar: Configuration by configurations.creating {
afterEvaluate {
isCanBeConsumed = true
isCanBeResolved = false
outgoing.artifact(tasks.shadowJar.get().outputs.files.first())
}
isCanBeConsumed = true
isCanBeResolved = false
}

artifacts {
afterEvaluate {
add("semanticdbJar", tasks.shadowJar.get().outputs.files.first()) {
builtBy(tasks.shadowJar)
}
}
add(semanticdbJar.name, tasks.shadowJar)
}

tasks.jar {
archiveClassifier.set("-slim")
archiveClassifier.set("slim")
manifest {
attributes["Specification-Title"] = project.name
attributes["Specification-Version"] = project.version
Expand Down

0 comments on commit 582c898

Please sign in to comment.