Skip to content

Commit c0a3140

Browse files
committed
Added gradle plugin and fixed package naming errors
1 parent 2a878f1 commit c0a3140

File tree

30 files changed

+251
-57
lines changed

30 files changed

+251
-57
lines changed

build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ plugins {
2121
idea
2222
kotlin version Versions.kotlin apply false
2323
buildconfig version Versions.buildconfig apply false
24+
25+
// Needs to be installed in the local maven repository
26+
id("org.jetbrains.kotlinx.spark.api") version Versions.project apply false
2427
}
2528

2629
group = Versions.groupID
@@ -127,17 +130,17 @@ subprojects {
127130
val projectVersion = Versions.project
128131
val groupId = Versions.groupID
129132

130-
val compilerPluginId = "$groupId.compilerPlugin"
131-
132133
val compilerPluginArtifactId = compilerPlugin.name
133134
val gradlePluginArtifactId = gradlePlugin.name
134135

135-
val defaultSparkifyFqName = "$groupId.plugin.annotations.Sparkify"
136-
val defaultColumnNameFqName = "$groupId.plugin.annotations.ColumnName"
136+
val compilerPluginId = "$groupId.api"
137+
138+
val defaultSparkifyFqName = "$groupId.api.plugin.annotations.Sparkify"
139+
val defaultColumnNameFqName = "$groupId.api.plugin.annotations.ColumnName"
137140

138141
val projectRoot = project.rootDir.absolutePath
139142

140-
packageName(groupId)
143+
packageName("$groupId.api")
141144
className("Artifacts")
142145

143146
buildConfigField("compilerPluginId", compilerPluginId)

buildSrc/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import org.gradle.kotlin.dsl.`kotlin-dsl`
2-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3-
41
plugins {
52
`kotlin-dsl`
63
}
74

85
repositories {
96
mavenCentral()
7+
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
108
}

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
object Dependencies {
1+
object Dependencies : Dsl<Dependencies> {
22
inline val kotlinStdLib get() = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}"
33
inline val reflect get() = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin}"
44
inline val scalaLibrary get() = "org.scala-lang:scala-library:${Versions.scala}"
@@ -35,6 +35,7 @@ object Dependencies {
3535
inline val kotlinScriptRuntime get() = "org.jetbrains.kotlin:kotlin-script-runtime:${Versions.kotlin}"
3636
inline val kotlinAnnotationsJvm get() = "org.jetbrains.kotlin:kotlin-annotations-jvm:${Versions.kotlin}"
3737
inline val kotlinCompilerInternalTestFramework get() = "org.jetbrains.kotlin:kotlin-compiler-internal-test-framework:${Versions.kotlin}"
38+
inline val kotlinGradlePlugin get() = "org.jetbrains.kotlin:kotlin-gradle-plugin"
3839
}
3940

4041

buildSrc/src/main/kotlin/Helpers.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import org.gradle.api.artifacts.Dependency
22
import org.gradle.api.artifacts.ProjectDependency
33
import org.gradle.api.artifacts.dsl.DependencyHandler
44

5+
interface Dsl<T> {
6+
operator fun invoke(block: T.() -> Unit) = block(this as T)
7+
}
8+
59
fun DependencyHandler.testApi(vararg dependencyNotations: Any): List<Dependency?> =
610
dependencyNotations.map {
711
add("testApi", it)
@@ -33,10 +37,15 @@ fun DependencyHandler.runtimeOnly(vararg dependencyNotations: Any): List<Depende
3337
add("runtimeOnly", it)
3438
}
3539

40+
fun DependencyHandler.compileOnly(vararg dependencyNotations: Any): List<Dependency?> =
41+
dependencyNotations.map {
42+
add("compileOnly", it)
43+
}
44+
3645
fun DependencyHandler.project(
3746
path: String,
3847
configuration: String? = null
3948
): ProjectDependency = project(
4049
if (configuration != null) mapOf("path" to path, "configuration" to configuration)
4150
else mapOf("path" to path)
42-
) as ProjectDependency
51+
) as ProjectDependency

buildSrc/src/main/kotlin/Plugins.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ inline val PluginDependenciesSpec.jupyter
3636
inline val PluginDependenciesSpec.buildconfig
3737
get() = id("com.github.gmazzo.buildconfig")
3838

39+
inline val PluginDependenciesSpec.gradlePublishPlugin
40+
get() = id("com.gradle.plugin-publish") version Versions.gradlePublishPlugin
41+
42+
inline val PluginDependenciesSpec.shadow
43+
get() = id("com.github.johnrengelman.shadow") version Versions.shadow

buildSrc/src/main/kotlin/Projects.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import org.gradle.api.Project
44

5-
object Projects {
5+
object Projects : Dsl<Projects> {
66

77
inline fun Project.searchProject(name: String): Project =
88
rootProject

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
object Versions {
2-
const val project = "1.2.5-SNAPSHOT"
1+
object Versions : Dsl<Versions> {
2+
const val project = "2.0.0-SNAPSHOT"
33
const val groupID = "org.jetbrains.kotlinx.spark"
44
const val kotlin = "2.0.0-Beta5"
55
const val jvmTarget = "8"
@@ -13,7 +13,9 @@ object Versions {
1313
inline val sparkConnect get() = System.getProperty("sparkConnect", "false").toBoolean()
1414
const val jupyter = "0.12.0-32-1"
1515

16+
const val gradlePublishPlugin = "1.1.0"
1617
const val kotest = "5.5.4"
18+
const val shadow = "8.1.1"
1719

1820
const val buildconfig = "5.3.5"
1921

compiler-plugin/build.gradle.kts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23

34
plugins {
45
java
56
kotlin
6-
mavenPublishBase
7+
mavenPublish
78
buildconfig
89
}
910

@@ -24,7 +25,7 @@ sourceSets {
2425
}
2526

2627
dependencies {
27-
with(Dependencies) {
28+
Dependencies {
2829
compileOnly(kotlinCompiler)
2930

3031
testRuntimeOnly(
@@ -62,17 +63,29 @@ tasks.test {
6263
}
6364

6465
tasks.withType<KotlinCompile>().configureEach {
65-
kotlinOptions {
66-
languageVersion = "2.0"
67-
freeCompilerArgs = freeCompilerArgs +
68-
"-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi" +
69-
"-Xcontext-receivers"
66+
compilerOptions {
67+
freeCompilerArgs.addAll(
68+
"-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi",
69+
"-Xcontext-receivers"
70+
)
71+
languageVersion = KotlinVersion.KOTLIN_2_0
72+
}
73+
}
74+
75+
kotlin {
76+
jvmToolchain {
77+
languageVersion = JavaLanguageVersion.of(8)
78+
}
79+
}
80+
java {
81+
toolchain {
82+
languageVersion = JavaLanguageVersion.of(8)
7083
}
7184
}
7285

7386
val generateTests by tasks.creating(JavaExec::class) {
7487
classpath = sourceSets.test.get().runtimeClasspath
75-
mainClass.set("org.jetbrains.kotlinx.spark.compilerPlugin.GenerateTestsKt")
88+
mainClass.set("org.jetbrains.kotlinx.spark.api.compilerPlugin.GenerateTestsKt")
7689
}
7790

7891
val compileTestKotlin by tasks.getting {

compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/compilerPlugin/SimplePluginRegistrar.kt renamed to compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/SimplePluginRegistrar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jetbrains.kotlinx.spark.compilerPlugin
1+
package org.jetbrains.kotlinx.spark.api.compilerPlugin
22

33
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
44

compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/compilerPlugin/SparkifyCommandLineProcessor.kt renamed to compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/SparkifyCommandLineProcessor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package org.jetbrains.kotlinx.spark.compilerPlugin
1+
package org.jetbrains.kotlinx.spark.api.compilerPlugin
22

33
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
44
import org.jetbrains.kotlin.compiler.plugin.CliOption
55
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
66
import org.jetbrains.kotlin.config.CompilerConfiguration
77
import org.jetbrains.kotlin.config.CompilerConfigurationKey
8-
import org.jetbrains.kotlinx.spark.Artifacts
8+
import org.jetbrains.kotlinx.spark.api.Artifacts
99

1010
open class SparkifyCommandLineProcessor : CommandLineProcessor {
1111

0 commit comments

Comments
 (0)