Skip to content
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

Version updates + copyright updates + deprecation fixes #240

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand All @@ -10,17 +10,8 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

buildscript {
@Suppress("LocalVariableName") val KOTLIN_VERSION: String by project
repositories {
mavenLocal()
mavenCentral()
google()
}
dependencies {
classpath("com.vanniktech:gradle-maven-publish-plugin:0.25.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION")
}
plugins {
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.maven.publish) apply false
}

7 changes: 3 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020-2023 Touchlab.
# Copyright (c) 2020-2024 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
#
Expand All @@ -12,15 +12,14 @@
#
kotlin.code.style=official
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2g
org.gradle.jvmargs=-Xmx4g

#Uncomment to allow local publishing without signing
#RELEASE_SIGNING_ENABLED=false

GROUP=co.touchlab.kmmbridge
VERSION_NAME=0.5.1
VERSION_NAME=0.5.2
VERSION_NAME_3x=0.3.7
KOTLIN_VERSION=1.9.0

POM_URL=https://github.com/touchlab/KMMBridge
POM_DESCRIPTION=KMM Packaging and tooling
Expand Down
13 changes: 13 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[versions]
kotlin = "1.9.22"
mavenPublish = "0.27.0"

[libraries]
aws = { module = "software.amazon.awssdk:s3", version = "2.23.8" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" }
gson = { module = "com.google.code.gson:gson", version = "2.10.1" }

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
maven-publish = { id = "com.vanniktech.maven.publish.base", version.ref = "mavenPublish" }

25 changes: 9 additions & 16 deletions kmmbridge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@file:Suppress("PropertyName")

/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand All @@ -15,17 +15,12 @@

plugins {
`kotlin-dsl`
kotlin("jvm")
id("java-gradle-plugin")
id("com.vanniktech.maven.publish.base")
id("com.gradle.plugin-publish") version "1.2.1"
}

repositories {
gradlePluginPortal()
mavenCentral()
`java-gradle-plugin`
alias(libs.plugins.kotlin)
alias(libs.plugins.maven.publish)
}

@Suppress("UnstableApiUsage")
gradlePlugin {
website = "https://github.com/touchlab/KMMBridge"
vcsUrl = "https://github.com/touchlab/KMMBridge.git"
Expand All @@ -43,12 +38,9 @@ gradlePlugin {
dependencies {
implementation(kotlin("stdlib"))
compileOnly(kotlin("gradle-plugin"))

implementation("commons-codec:commons-codec:1.15")
implementation("software.amazon.awssdk:s3:2.20.17")

implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation(libs.aws)
implementation(libs.okhttp)
implementation(libs.gson)

testImplementation(kotlin("test"))
}
Expand All @@ -68,5 +60,6 @@ mavenPublishing {
val releaseSigningEnabled =
project.properties["RELEASE_SIGNING_ENABLED"]?.toString()?.equals("false", ignoreCase = true) != true
if (releaseSigningEnabled) signAllPublications()
@Suppress("UnstableApiUsage")
pomFromGradleProperties()
}
2 changes: 1 addition & 1 deletion kmmbridge/src/main/kotlin/BuildFileHelper.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
4 changes: 2 additions & 2 deletions kmmbridge/src/main/kotlin/co/touchlab/faktory/KMMBridge.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down Expand Up @@ -58,7 +58,7 @@ class KMMBridgePlugin : Plugin<Project> {
val zipFile = zipFilePath()
val zipTask = tasks.register<Zip>("zipXCFramework") {
group = TASK_GROUP_NAME
from("$buildDir/XCFrameworks/${extension.buildType.get().getName()}")
from("$layoutBuildDir/XCFrameworks/${extension.buildType.get().getName()}")
destinationDirectory.set(zipFile.parentFile)
archiveFileName.set(zipFile.name)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down Expand Up @@ -27,12 +27,14 @@ import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import java.io.File

internal val Project.layoutBuildDir get() = layout.buildDirectory.get().asFile

internal val Project.kotlin: KotlinMultiplatformExtension get() = extensions.getByType()
internal val Project.kmmBridgeExtension get() = extensions.getByType<KmmBridgeExtension>()
internal val Project.publishingExtension get() = extensions.getByType<PublishingExtension>()

internal val Project.urlFile get() = file("$buildDir/faktory/url")
internal val Project.versionFile get() = file("$buildDir/faktory/version")
internal val Project.urlFile get() = file("$layoutBuildDir/faktory/url")
internal val Project.versionFile get() = file("$layoutBuildDir/faktory/version")

// Cocoapods is an extension of KMP extension, so you can't just do project.extensions.getByType<CocoapodsExtension>()
internal val KotlinMultiplatformExtension.cocoapodsOrNull get() = (this as ExtensionAware).extensions.findByType<CocoapodsExtension>()
Expand All @@ -49,7 +51,7 @@ internal val Project.spmBuildTargets: String?

@Suppress("SpellCheckingInspection")
internal fun Project.zipFilePath(): File {
val tempDir = file("$buildDir/faktory/zip")
val tempDir = file("$layoutBuildDir/faktory/zip")
val artifactName = "frameworkarchive.zip"
return file("$tempDir/$artifactName")
}
Expand All @@ -68,9 +70,9 @@ internal const val EXTENSION_NAME = "kmmbridge"
internal fun Project.findXCFrameworkAssembleTask(buildType: NativeBuildType? = null): TaskProvider<Task> {
val extension = extensions.getByType<KmmBridgeExtension>()
val name = extension.frameworkName.get()
val buildTypeString = (buildType ?: extension.buildType.get()).getName().capitalize()
val buildTypeString = (buildType ?: extension.buildType.get()).getName().capitalized()
val taskWithoutName = "assemble${buildTypeString}XCFramework"
val taskWithName = "assemble${name.capitalize()}${buildTypeString}XCFramework"
val taskWithName = "assemble${name.capitalized()}${buildTypeString}XCFramework"
return runCatching {
tasks.named(taskWithName)
}.recoverCatching {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package co.touchlab.faktory

import java.util.Locale

fun String.capitalized(): String {
return this.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.touchlab.faktory.artifactmanager

import co.touchlab.faktory.capitalized
import co.touchlab.faktory.publishingExtension
import org.gradle.api.GradleException
import org.gradle.api.Project
Expand Down Expand Up @@ -82,10 +83,10 @@ class MavenPublishArtifactManager(

// Either the user has supplied a correct name, or we use the default. If neither is found, fail.
val publicationNameCap =
publishingExtension.publications.getByName(publicationName ?: FRAMEWORK_PUBLICATION_NAME).name.capitalize()
publishingExtension.publications.getByName(publicationName ?: FRAMEWORK_PUBLICATION_NAME).name.capitalized()

return publishingExtension.repositories.filterIsInstance<MavenArtifactRepository>().map { repo ->
val repositoryName = repo.name.capitalize()
val repositoryName = repo.name.capitalized()
val publishTaskName = "publish${publicationNameCap}PublicationTo${repositoryName}Repository"
// Verify that the "publish" task exists before collecting
project.tasks.named(publishTaskName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down Expand Up @@ -38,7 +38,7 @@ class CocoapodsDependencyManager(
override fun configure(project: Project, uploadTask: TaskProvider<Task>, publishRemoteTask: TaskProvider<Task>) {

val podSpecFile =
"${project.buildDir}/faktory/podspec/${project.kmmBridgeExtension.buildType.get().name.toLowerCase()}/${project.kotlin.cocoapods.name}.podspec"
"${project.layoutBuildDir}/faktory/podspec/${project.kmmBridgeExtension.buildType.get().name.lowercase()}/${project.kotlin.cocoapods.name}.podspec"

val generatePodspecTask = project.tasks.register("generateReleasePodspec") {
inputs.files(project.urlFile, project.versionFile)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down Expand Up @@ -166,7 +166,7 @@ internal fun stripEndSlash(path: String): String {

private fun makeLocalDevPackageFileText(swiftPackageFolder: String, frameworkName: String, project: Project): String {
val swiftFolderPath = project.file(swiftPackageFolder).toPath()
val projectBuildFolderPath = project.buildDir.toPath()
val projectBuildFolderPath = project.layoutBuildDir.toPath()
val xcFrameworkPath =
"${swiftFolderPath.relativize(projectBuildFolderPath)}/XCFrameworks/${NativeBuildType.DEBUG.getName()}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand Down
11 changes: 10 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Touchlab.
* Copyright (c) 2024 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
*
Expand All @@ -19,5 +19,14 @@ pluginManagement {
}
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenLocal()
mavenCentral()
google()
}
}

rootProject.name = "KMMBridge"
include(":kmmbridge")
Loading