How to use MultiplatformPlugin class of org.spekframework.spek2.gradle.entry package

Best Spek code snippet using org.spekframework.spek2.gradle.entry.MultiplatformPlugin

MultiplatformPlugin.kt

Source:MultiplatformPlugin.kt Github

copy

Full Screen

...6import org.jetbrains.kotlin.gradle.plugin.mpp.Executable7import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation8import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget9import org.spekframework.spek2.gradle.domain.MultiplatformExtension10class MultiplatformPlugin : Plugin<Project> {11 override fun apply(project: Project) {12 if (project.extensions.findByType(KotlinMultiplatformExtension::class.java) == null) {13 throw GradleException("Kotlin multiplatform plugin needs to be applied first!")14 }15 project.extensions.create("spek2", MultiplatformExtension::class.java)16 project.afterEvaluate(this::doApply)17 }18 private fun doApply(project: Project) {19 val spekExtension = checkNotNull(project.extensions.findByType(MultiplatformExtension::class.java))20 val kotlinMppExtension = checkNotNull(project.extensions.findByType(KotlinMultiplatformExtension::class.java))21 if (!spekExtension.enabled) {22 return23 }24 kotlinMppExtension.targets.forEach { target ->25 when (target) {26 is KotlinNativeTarget -> configureNativeTarget(target)27 }28 }29 }30 private fun configureNativeTarget(target: KotlinNativeTarget) {31 target.compilations.filter { it.isTestCompilation }32 .forEach(this::configureNativeCompilation)33 }34 private fun configureNativeCompilation(compilation: KotlinNativeCompilation) {35 compilation.isTestCompilation = false36 compilation.target.binaries37 .filterIsInstance<Executable>()38 .forEach { binary ->39 binary.entryPoint = "org.spekframework.spek2.launcher.spekMain"40 }41 compilation.defaultSourceSet.dependencies {42 implementation("$spekMavenGroup:spek-runtime:$spekVersion")43 }44 }45 companion object {46 val spekMavenGroup = "org.spekframework.spek2"47 val spekVersion = MultiplatformPlugin::class.java.`package`.implementationVersion48 }49}...

Full Screen

Full Screen

Subplugin.kt

Source:Subplugin.kt Github

copy

Full Screen

...8import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact9import org.jetbrains.kotlin.gradle.plugin.SubpluginOption10import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile11import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink12import org.spekframework.spek2.gradle.entry.MultiplatformPlugin13import org.spekframework.spek2.gradle.domain.MultiplatformExtension14@AutoService(KotlinGradleSubplugin::class)15class Subplugin : KotlinGradleSubplugin<AbstractCompile> {16 override fun apply(project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?, kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?): List<SubpluginOption> {17 val extension = checkNotNull(project.extensions.findByType(MultiplatformExtension::class.java))18 return listOf(SubpluginOption("enabled", extension.enabled.toString()))19 }20 override fun getCompilerPluginId(): String {21 return "spek2"22 }23 override fun getPluginArtifact(): SubpluginArtifact {24 // HACK: This is a temporary workaround for https://youtrack.jetbrains.com/issue/KT-29901.25 // This plugin does nothing.26 return SubpluginArtifact(27 MultiplatformPlugin.spekMavenGroup,28 "spek-kotlin-compiler-plugin-jvm",29 MultiplatformPlugin.spekVersion30 )31 }32 override fun getNativeCompilerPluginArtifact(): SubpluginArtifact? {33 return SubpluginArtifact(34 MultiplatformPlugin.spekMavenGroup,35 "spek-kotlin-compiler-plugin-native",36 MultiplatformPlugin.spekVersion37 )38 }39 override fun isApplicable(project: Project, task: AbstractCompile): Boolean40 = project.plugins.hasPlugin(MultiplatformPlugin::class.java) && (task is KotlinNativeCompile || task is KotlinNativeLink)41}...

Full Screen

Full Screen

CompilerPlugin.kt

Source:CompilerPlugin.kt Github

copy

Full Screen

...5import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin6import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact7import org.jetbrains.kotlin.gradle.plugin.SubpluginOption8import org.spekframework.spek2.gradle.domain.MultiplatformExtension9import org.spekframework.spek2.gradle.entry.MultiplatformPlugin10class CompilerPlugin : KotlinCompilerPluginSupportPlugin {11 private lateinit var project: Project12 override fun apply(target: Project) {13 project = target14 }15 override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {16 return project.provider {17 val extension = checkNotNull(project.extensions.findByType(MultiplatformExtension::class.java))18 listOf(SubpluginOption("enabled", extension.enabled.toString()))19 }20 }21 override fun getCompilerPluginId() = "spek2"22 override fun getPluginArtifact(): SubpluginArtifact {23 return SubpluginArtifact(24 MultiplatformPlugin.spekMavenGroup,25 "spek-kotlin-compiler-plugin-jvm",26 MultiplatformPlugin.spekVersion27 )28 }29 override fun getPluginArtifactForNative(): SubpluginArtifact? {30 return SubpluginArtifact(31 MultiplatformPlugin.spekMavenGroup,32 "spek-kotlin-compiler-plugin-native",33 MultiplatformPlugin.spekVersion34 )35 }36 override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean {37 return true38 }39}

Full Screen

Full Screen

build.gradle.kts

Source:build.gradle.kts Github

copy

Full Screen

...8gradlePlugin {9 plugins {10 create("spekPlugin") {11 id = "org.spekframework.spek2.multiplatform"12 implementationClass = "org.spekframework.spek2.gradle.entry.MultiplatformPlugin"13 }14 }15}16val autoService = "com.google.auto.service:auto-service:1.0-rc4"17dependencies {18 implementation(kotlin("gradle-plugin"))19 implementation(kotlin("gradle-plugin-api"))20 implementation(autoService)21// kapt(autoService)22}23tasks {24// kapt {25// includeCompileClasspath = false26// }...

Full Screen

Full Screen

MultiplatformPlugin

Using AI Code Generation

copy

Full Screen

1buildscript {2 repositories {3 jcenter()4 mavenLocal()5 }6 dependencies {7 }8}9spek {10 useJUnitPlatform()11}12repositories {13 jcenter()14}15dependencies {16}17test {18 useJUnitPlatform()19}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Spek automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful