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 JVM IR compiler plugin in AtomicfuGradlePlugin #246
Conversation
Why doesn't the build pass with RC? |
This fix for |
… the plugin separately to JS ans JVM targets
ee1f42a
to
85bebfc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please add quite a few tests for that functionality:
- Only JVM_IR transformation with Kotlin 1.7.0
- Only JS_IR transformation with Kotlin 1.7.0
- Both transformations
JVM tests worth adding for both MPP and JVM-only projects
@@ -29,16 +29,16 @@ private const val ORIGINAL_DIR_NAME = "originalClassesDir" | |||
private const val COMPILE_ONLY_CONFIGURATION = "compileOnly" | |||
private const val IMPLEMENTATION_CONFIGURATION = "implementation" | |||
private const val TEST_IMPLEMENTATION_CONFIGURATION = "testImplementation" | |||
private const val ENABLE_IR_TRANSFORMATION = "kotlinx.atomicfu.enableIrTransformation" | |||
private const val ENABLE_JS_IR_TRANSFORMATION_LEGACY = "kotlinx.atomicfu.enableIrTransformation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a comment why it is legacy and when it is safe to remove it
// for KGP >= 1.7.20: | ||
// compiler plugin for JS IR is applied via the property `kotlinx.atomicfu.enableJsIrTransformation` | ||
// compiler plugin for JVM IR is applied via the property `kotlinx.atomicfu.enableJvmIrTransformation` | ||
if (kotlinVersion.major == 1 && (kotlinVersion.minor == 7 && kotlinVersion.patch >= 20 || kotlinVersion.minor > 7)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have at least three duplicating checks, each of them requires non-trivial effort to see if it's correct.
I suggest introducing something like if (kotlinVersion.atLeast(1, 7, 20)
and use it everywhere
@@ -109,7 +141,8 @@ private fun String.toBooleanStrict(): Boolean = when (this) { | |||
} | |||
|
|||
private fun Project.needsJsIrTransformation(target: KotlinTarget): Boolean = | |||
rootProject.getBooleanProperty(ENABLE_IR_TRANSFORMATION) && target.isJsIrTarget() | |||
(rootProject.getBooleanProperty(ENABLE_JS_IR_TRANSFORMATION) || rootProject.getBooleanProperty(ENABLE_JS_IR_TRANSFORMATION_LEGACY)) | |||
&& target.isJsIrTarget() | |||
|
|||
private fun KotlinTarget.isJsIrTarget() = (this is KotlinJsTarget && this.irTarget != null) || this is KotlinJsIrTarget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't addCompilerPluginDependency
add dependency for JVM transformation as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the atomicfu-runtime dependency is required by the JS plugin only
kotlinx.atomicfu.enableJsIrTransformation
andkotlinx.atomicfu.enableJvmIrTransformation
AtomicfuKotlinGradleExtension
Waiting to merge this PR after update to
1.7.20