Skip to content

Commit

Permalink
Code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipDolnik committed Oct 18, 2023
1 parent 8d949d8 commit def1616
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package io.outfoxx.swiftpoet
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class AnyTypeName private constructor() : TypeName() {

override fun emit(out: CodeWriter): CodeWriter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Touchlab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.outfoxx.swiftpoet.builder

import io.outfoxx.swiftpoet.FunctionSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Outfox, Inc.
* Copyright 2023 Touchlab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Outfox, Inc.
* Copyright 2023 Touchlab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Outfox, Inc.
* Copyright 2023 Touchlab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ buildConfig {
// Workaround for problems with BuildConfig - it incorrectly wraps long strings, and it cannot easily generate a List
val supportedKotlinVersions = project.stringListProperty("versionSupport.supportedKotlinVersions")
.joinToString(", ") { it.enquoted() }
buildConfigField("kotlin.Any", "SUPPORTED_KOTLIN_VERSIONS", "listOf<String>($supportedKotlinVersions)")
buildConfigField("co.touchlab.skie.plugin.util.StringList", "SUPPORTED_KOTLIN_VERSIONS", "listOf($supportedKotlinVersions)")

buildConfigField("String", "SKIE_VERSION", "\"${project.version}\"")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,35 @@ abstract class SkieLoaderPlugin : Plugin<Project> {
}

val error = when {
kotlinVersion == null ->
kotlinVersion == null -> {
"""
SKIE could not infer Kotlin plugin version.
Make sure you have Kotlin Multiplatform plugin applied in the same module as SKIE and that the plugin works - for example by calling the link task that produces the Obj-C framework.
If that is the case, then this problem is likely caused by a bug in SKIE - please report it to the SKIE developers.
You can try to workaround this issue by providing the Kotlin version manually via 'skie.kgpVersion' property in your gradle.properties.
""".trimIndent()
!kotlinVersion.isSupported && !skipSupportedVersionsCheck ->
}
!kotlinVersion.isSupported && !skipSupportedVersionsCheck -> {
"""
SKIE ${BuildConfig.SKIE_VERSION} does not support Kotlin $kotlinVersion.
Supported versions are ${BuildConfig.SUPPORTED_KOTLIN_VERSIONS}.
Check if you have the most recent version of SKIE and if so, please wait for the SKIE developers to add support for this Kotlin version.
New Kotlin versions are usually supported within a few days after they are released.
Note that there are no plans for supporting early access versions like Beta, RC, etc.
""".trimIndent()
else -> null
}
else -> return kotlinVersion
}

if (error != null) {
reportSkieLoaderError(error)

return null
}
reportSkieLoaderError(error)

return kotlinVersion
return null
}

private fun Project.reportSkieLoaderError(error: String) {
logger.error("Error:\n$error\nSKIE cannot not be used until this error is resolved.\n")

project.gradle.taskGraph.whenReady {
gradle.taskGraph.whenReady {
val hasLinkTask = allTasks.any { it.name.startsWith("link") && it.project == project }
val isSkieEnabled = extensions.findByType(SkieExtension::class.java)?.isEnabled?.get() == true

Expand Down Expand Up @@ -183,7 +181,7 @@ abstract class SkieLoaderPlugin : Plugin<Project> {
private value class KotlinVersion(val value: String) {

val isSupported: Boolean
get() = (BuildConfig.SUPPORTED_KOTLIN_VERSIONS as List<*>).contains(value)
get() = BuildConfig.SUPPORTED_KOTLIN_VERSIONS.contains(value)

override fun toString(): String = value
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package co.touchlab.skie.plugin.util

// Workaround for limitation of BuildConfig plugin - as of time of writing it cannot declare generic types
internal typealias StringList = List<String>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ internal class GradleAnalyticsManager(

linkTask.project.afterEvaluate {
uploadTask.configure {
isEnabled = !project.skieExtension.analytics.disableUpload.get() && project.skieExtension.analytics.enabled.get()
onlyIf {
val analyticsConfiguration = project.skieExtension.analytics

analyticsConfiguration.enabled.get() && !analyticsConfiguration.disableUpload.get()
}
}
}
}
Expand Down

0 comments on commit def1616

Please sign in to comment.