{"id":24357045,"url":"https://github.com/erfanmhat/ai4kt","last_synced_at":"2025-04-15T14:24:00.335Z","repository":{"id":273099820,"uuid":"918458255","full_name":"erfanmhat/AI4kt","owner":"erfanmhat","description":"Bringing Python AI libraries to Kotlin.","archived":false,"fork":false,"pushed_at":"2025-02-13T08:50:53.000Z","size":924,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T21:11:38.492Z","etag":null,"topics":["artificial-intelligence","kotlin","kotlin-android","kotlin-multiplatform","machine-learning","matplotlib","numpy","pandas","python","python3","seaborn","sklearn","tensorflow2"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erfanmhat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-18T01:37:42.000Z","updated_at":"2025-02-27T07:58:13.000Z","dependencies_parsed_at":"2025-01-18T17:36:22.888Z","dependency_job_id":"7b68bbce-4803-4392-a00c-39403a036ff9","html_url":"https://github.com/erfanmhat/AI4kt","commit_stats":null,"previous_names":["erfanmhat/ai4kt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanmhat%2FAI4kt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanmhat%2FAI4kt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanmhat%2FAI4kt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanmhat%2FAI4kt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erfanmhat","download_url":"https://codeload.github.com/erfanmhat/AI4kt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249086468,"owners_count":21210468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","kotlin","kotlin-android","kotlin-multiplatform","machine-learning","matplotlib","numpy","pandas","python","python3","seaborn","sklearn","tensorflow2"],"created_at":"2025-01-18T18:55:22.543Z","updated_at":"2025-04-15T14:24:00.310Z","avatar_url":"https://github.com/erfanmhat.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![official project](http://jb.gg/badges/official.svg)](https://github.com/JetBrains#jetbrains-on-github)\n\n# Multiplatform library template\n\n## What is it?\n\nThis repository contains a simple library project, intended to demonstrate a [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html) library that is deployable to [Maven Central](https://central.sonatype.com/).\n\nThe library has only one function: generate the [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_sequence) starting from platform-provided numbers. Also, it has a test for each platform just to be sure that tests run.\n\nNote that no other actions or tools usually required for the library development are set up, such as [tracking of backwards compatibility](https://kotlinlang.org/docs/jvm-api-guidelines-backward-compatibility.html#tools-designed-to-enforce-backward-compatibility), explicit API mode, licensing, contribution guideline, code of conduct and others. You can find a guide for best practices for designing Kotlin libraries [here](https://kotlinlang.org/docs/api-guidelines-introduction.html).\n\n## How to publish?\n\nThis guide describes the steps of publishing a library built with Kotlin Multiplatform to the [Maven Central repository](https://central.sonatype.com/). To publish your library, you’ll need to:\n\n* Set up credentials, including an account on Maven Central and a PGP key to use for signing.\n* Configure the publishing plugin in your library’s project.\n* Provide your credentials to the publishing plugin so it can sign and upload your artifacts.\n* Run the publication task, either locally or using continuous integration.\n\nThis guide assumes that you are:\n\n- Creating an open-source library.\n- Using macOS or Linux. If you are a Windows user, use [GnuPG or Gpg4win](https://gnupg.org/download) to generate a key pair.\n- Either not registered on Maven Central yet, or have an existing account that’s suitable for [publishing to the Central Portal](https://central.sonatype.org/publish-ea/publish-ea-guide/) (created after March 12th, 2024, or migrated to the Central Portal by their support).\n- Publishing your library in a GitHub repository.\n- Using GitHub Actions for continuous integration.\n\nMost of the steps here are still applicable if you’re using a different setup, but there might be some differences you need to account for. An [important limitation](https://kotlinlang.org/docs/multiplatform-publish-lib.html#host-requirements) is that Apple targets must be built on a machine with macOS.\n\nThroughout this guide, we’ll use the [https://github.com/kotlin-hands-on/fibonacci](https://github.com/kotlin-hands-on/fibonacci) repository as an example. You can refer to the code of this repository to see how the publishing setup works. You **must replace all example values with your own** as you’re configuring your project.\n\n### Prepare accounts and credentials\n\n#### Register a namespace\n\nArtifacts published to Maven repositories are identified by their coordinates, for example `com.example:library:1.0.0`. These coordinates are made up of three parts, separated by colons: the `groupId`, `artifactId`, and `version`.\n\nAs a first step for publishing to Maven Central, you’ll need to have a verified namespace. The `groupId` of the artifacts you publish will have to start with the name of your verified namespace. For example, if you register the `com.example` namespace, you’ll be able to publish artifacts with the `groupId` set to `com.example` or `com.example.libraryname`.\n\nTo get started with publishing to Maven Central, sign in (or create a new account) on the [Maven Central](https://central.sonatype.com/) portal. Once signed in, navigate to [Namespaces](https://central.sonatype.com/publishing/namespaces) under your profile, and click the Add Namespace button. Here, you can register a namespace for your artifacts, either based on your GitHub account or a domain name that you own.\n\n**For a GitHub repository**\nUsing your GitHub account to create a namespace is a good option if you don’t own a domain name to use for publication. To create a namespace based on your GitHub account:\n\n1. Enter `io.github.\u003cyour username\u003e` as your namespace. For example, `io.ai4kt.ai4kt-hands-on`.\n2. Copy the Verification Key displayed.\n3. On GitHub, create a new repository with your GitHub account with the verification key as the repository’s name. For example, `http://github.com/kotlin-hands-on/ex4mpl3c0d`.\n4. Navigate back to Maven Central, and click on the Verify Namespace button. After verification succeeds you can delete the repository you’ve created.\n\n**For a domain name**\nTo use a domain name that you own as your namespace:\n\n1. Enter your domain as the namespace using a reverse-DNS form. If your domain is `example.com`, enter `com.example`.\n2. Copy the Verification Key displayed.\n3. Create a new DNS TXT record with the verification key as its contents. See [Maven Central’s FAQ](https://central.sonatype.org/faq/how-to-set-txt-record/) for more information on how to do this with various domain registrars.\n4. Navigate back to Maven Central, and click on the Verify Namespace button. After verification succeeds you can delete the TXT record you’ve created.\n\n#### Generate a Key Pair\n\nArtifacts published to Maven Central [must be signed with a PGP signature](https://central.sonatype.org/publish/requirements/gpg/), which allows users to validate the origin of artifacts.\n\nTo get started with signing, you’ll need to generate a key pair:\n\n* The **private key** is used to sign your artifacts, and should never be shared with others.\n* The **public key** can be used by others to validate the signature of the artifacts, and should be published.\n\nThe `gpg` tool that can manage signatures for you is available from [their website](https://gnupg.org/download/index.html). You can also install it using package managers such as [Homebrew](https://brew.sh/):\n\n```bash \nbrew install gpg\n```\nGenerate a key pair with the following command, and fill in the required details when prompted.\n\n```bash\ngpg --full-generate-key\n```\n\nChoose the recommended defaults for the type of key to be created. You can leave these selections empty and press Enter to accept the default values.\n\n\u003e [!NOTE]\n\u003e At the time of writing, this is `ECC (sign and encrypt)` with `Curve 25519`. Older versions of `gpg` might default to `RSA` with a `3072` bit key size.\n\nNext, you’ll be prompted to set the expiration of the key. If you choose to create a key that automatically expires after a set amount of time, you’ll need to [extend its validity](https://central.sonatype.org/publish/requirements/gpg/#dealing-with-expired-keys) when it expires.\n\nYou will be asked for your real name, email, and a comment. You can leave the comment empty.\n\n```text\nPlease select what kind of key you want:\n    (1) RSA and RSA\n    (2) DSA and Elgamal\n    (3) DSA (sign only)\n    (4) RSA (sign only)\n    (9) ECC (sign and encrypt) *default*\n    (10) ECC (sign only)\n    (14) Existing key from card\nYour selection? 9\n\nPlease select which elliptic curve you want:\n    (1) Curve 25519 *default*\n    (4) NIST P-384\n    (6) Brainpool P-256\nYour selection? 1\n\nPlease specify how long the key should be valid.\n    0 = key does not expire\n    \u003cn\u003e  = key expires in n days\n    \u003cn\u003ew = key expires in n weeks\n    \u003cn\u003em = key expires in n months\n    \u003cn\u003ey = key expires in n years\nKey is valid for? (0) 0\nKey does not expire at all\n\nIs this correct? (y/N) y\nGnuPG needs to construct a user ID to identify your key.\n```\n\nYou will be asked for a passphrase to encrypt the key, which you have to repeat. Keep this passphrase stored securely and privately. You’ll be using it later to access the private key.\n\nLet’s take a look at the key we’ve created with the following command:\n\n```bash\ngpg --list-keys\n```\n\nThe output will look something like this:\n\n```text\npub   ed25519 2024-10-06 [SC]\n      F175482952A225BFC4A07A715EE6B5F76620B385CE\nuid   [ultimate] Your name \u003cyour email address\u003e\n      sub   cv25519 2024-10-06 [E]\n```\n\nYou’ll need to use the long alphanumerical identifier of your key displayed here in the following steps.\n\n#### Upload the public key\n\nYou need to [upload the public key to a keyserver](https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key) for it to be accepted by Maven Central. There are multiple available keyservers, we’ll use `keyserver.ubuntu.com` as a default choice.\n\nRun the following command to upload your public key using `gpg`, **substituting your own keyid** in the parameters:\n\n```bash\ngpg --keyserver keyserver.ubuntu.com --send-keys F175482952A225BFC4A07A715EE6B5F76620B385CE\n```\n\n#### Export your private key\n\nTo let your Gradle project access your private key, you’ll need to export it to a file. Use the following command, **passing in your own keyid** as a parameter. You will be prompted to enter the passphrase you’ve used when creating the key.\n\n```bash\ngpg --armor --export-secret-keys F175482952A225BFC4A07A715EE6B5F76620B385CE \u003e key.gpg\n```\n\nThis will create a `key.gpg` file which contains your private key.\n\n\u003e [!CAUTION]\n\u003e Never share a private key with anyone.\n\nIf you check the contents of the file, you should see contents similar to this:\n\n```text\n-----BEGIN PGP PRIVATE KEY BLOCK-----\nlQdGBGby2X4BEACvFj7cxScsaBpjty60ehgB6xRmt8ayt+zmgB8p+z8njF7m2XiN\n...\nbpD/h7ZI7FC0Db2uCU4CYdZoQVl0MNNC1Yr56Pa68qucadJhY0sFNiB63KrBUoiO \n-----END PGP PRIVATE KEY BLOCK-----\n```\n\n#### Generate the user token\n\nYour project will also need to authenticate with Maven Central to upload artifacts. On the Central Portal, navigate to the [Account](https://central.sonatype.com/account) page, and click on *Generate User Token*.\n\nThe output will look like the example below, containing a username and a password. Store this information securely, as it can’t be viewed again on the Central Portal. If you lose these credentials, you’ll need to generate new ones later.\n\n```xml\n\u003cserver\u003e\n    \u003cid\u003e${server}\u003c/id\u003e\n    \u003cusername\u003el3nfaPmz\u003c/username\u003e\n    \u003cpassword\u003egh9jT9XfnGtUngWTZwTu/8241keYdmQpipqLPRKeDLTh\u003c/password\u003e\n\u003c/server\u003e\n```\n\n### Configure the project\n\n#### Prepare your library project\n\nIf you started developing your library from a template project, this is a good time to change any default names in the project to match your own library’s name. This includes the name of your library module, and the name of the root project in your top-level `build.gradle.kts` file.\n\nIf you have an Android target in your project, you should follow the [steps to prepare your Android library release](https://developer.android.com/build/publish-library/prep-lib-release). This, at a minimum, requires you to [specify an appropriate namespace](https://developer.android.com/build/publish-library/prep-lib-release#choose-namespace) for your library, so that a unique R class will be generated when their resources are compiled.  Notice that the namespace is different from the Maven namespace created in the [Register a namespace](#register-a-namespace) section above.\n\n```kotlin\n// build.gradle.kts\n\nandroid {\n     namespace = \"io.ai4kt.ai4kthandson.fibonacci\"\n}\n```\n\n#### Set up the publishing plugin\n\nThis guide uses [vanniktech/gradle-maven-publish-plugin](https://github.com/vanniktech/gradle-maven-publish-plugin) to help with publications to Maven Central. You can read more about the advantages of the plugin [here](https://vanniktech.github.io/gradle-maven-publish-plugin/#advantages-over-maven-publish). See the [plugin’s documentation](https://vanniktech.github.io/gradle-maven-publish-plugin/central/) to learn more about its usage and available configuration options.\n\nTo add the plugin to your project, add the following line in the plugins block, in your library module’s `build.gradle.kts` file:\n\n```kotlin\n// build.gradle.kts\n\nplugins {\n    id(\"com.vanniktech.maven.publish\") version \"0.29.0\" \n}\n```\n\n*Note: for the latest available version of the plugin, check its [releases page](https://github.com/vanniktech/gradle-maven-publish-plugin/releases).*\n\nIn the same file, add the following configuration. Customize all these values appropriately for your library.\n\n```kotlin\n// build.gradle.kts\n\nmavenPublishing {\n    publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)\n    \n    signAllPublications()\n    \n    coordinates(group.toString(), \"fibonacci\", version.toString())\n    \n    pom { \n        name = \"Fibonacci library\"\n        description = \"A mathematics calculation library.\"\n        inceptionYear = \"2024\"\n        url = \"https://github.com/kotlin-hands-on/fibonacci/\"\n        licenses {\n            license {\n                name = \"The Apache License, Version 2.0\"\n                url = \"https://www.apache.org/licenses/LICENSE-2.0.txt\"\n                distribution = \"https://www.apache.org/licenses/LICENSE-2.0.txt\"\n            }\n        }\n        developers {\n            developer {\n                id = \"kotlin-hands-on\"\n                name = \"Kotlin Developer Advocate\"\n                url = \"https://github.com/kotlin-hands-on/\"\n            }\n        }\n        scm {\n            url = \"https://github.com/kotlin-hands-on/fibonacci/\"\n            connection = \"scm:git:git://github.com/kotlin-hands-on/fibonacci.git\"\n            developerConnection = \"scm:git:ssh://git@github.com/kotlin-hands-on/fibonacci.git\"\n        }\n    }\n}\n```\n\nNote that it’s also possible to use Gradle properties instead.\n\nSome of the most important, required settings here are:\n\n* The `coordinates`, which specify the `groupId`, `artifactId`, and `version` of your library.\n* The [license](https://central.sonatype.org/publish/requirements/#license-information) that you’re publishing your library under.\n* The [developer information](https://central.sonatype.org/publish/requirements/#developer-information) which lists the authors of the library.\n* [SCM (Source Code Management) information](https://central.sonatype.org/publish/requirements/#scm-information), which specifies where the sources of your library are available.\n\n### Publish to Maven Central from Continuous Integration\n\n#### Add a GitHub Actions workflow to your project\n\nYou can set up continuous integration which builds and publishes your library for you. We’ll use [GitHub Actions](https://docs.github.com/en/actions) as an example.\n\nTo get started, add the following workflow to your repository, in the `.github/workflows/publish.yml` file.\n\n```yaml\n# .github/workflows/publish.yml\n\nname: Publish\non:\n  release:\n    types: [released, prereleased]\njobs:\n  publish:\n    name: Release build and publish\n    runs-on: macOS-latest\n    steps:\n      - name: Check out code\n        uses: actions/checkout@v4\n      - name: Set up JDK 21\n        uses: actions/setup-java@v4\n        with:\n          distribution: 'zulu'\n          java-version: 21\n      - name: Publish to MavenCentral\n        run: ./gradlew publishToMavenCentral --no-configuration-cache\n        env:\n          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}\n          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}\n          ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}\n          ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}\n          ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}\n```\n\nAfter committing and pushing this change, this workflow will run automatically when you create a release (including a pre-release) in the GitHub repository hosting your project. It checks out the current version of your code, sets up a JDK, and then runs the `publishToMavenCentral` Gradle task.\n\n\u003e [!NOTE]\n\u003e Alternatively, you could configure the workflow to [trigger when a tag is pushed](https://stackoverflow.com/a/61892639) to your repository.\n\u003e\n\u003e The script above disables Gradle [configuration cache](https://docs.gradle.org/current/userguide/configuration_cache.html) for the publication task by adding `--no-configuration-cache` to the Gradle command, as the publication plugin does not support it (see this [open issue](https://github.com/gradle/gradle/issues/22779)).\n\u003e\n\u003e Reminder: When using `publishToMavenCentral`, you’ll still need to check and release your deployment manually on the website, as described in the previous section. You may use `publishAndReleaseToMavenCentral` instead for a fully automated release.\n\nThis action will need your signing details and your Maven Central credentials. These will be configured as GitHub Actions secrets in the next section. The configuration of the workflow above takes these secrets and places them into environment variables, which will make them available to the Gradle build automatically.\n\n### Add secrets to GitHub\n\nTo use the keys and credentials required for publication in your GitHub Action workflow while keeping them private, you need to place those values into secrets. From your GitHub repository, go to `Settings` \\\u003e `(Security) Secrets and variables \u003e Actions`.\n\nClick on the `New repository secret` button, and add the following secrets:\n\n- `MAVEN_CENTRAL_PASSWORD` and `MAVEN_CENTRAL_PASSWORD` are the values generated by the Central Portal website in the [Generate User Token](#generate-the-user-token) section.\n- `SIGNING_KEY_ID` is **the last 8 characters** of your signing key’s identifier.\n- `SIGNING_PASSWORD` is the passphrase you’ve provided when generating your signing key.\n- `GPG_KEY_CONTENTS` should contain the contents of your GPG private key file, which you’ve created earlier in the [Export your private key](#export-your-private-key) section.\n\n![](/images/github_secrets.png)\n\nNote again that the names used for these secrets must match those used by the workflow that accesses their values.\n\n#### Create a release on GitHub\n\nWith the workflow and secrets set up, you’re now ready to [create a release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) that will trigger the publication of your library.\n\nGo to your GitHub repository’s main page, and click on Releases in the menu in the right sidebar.\n\n![](/images/github_releases.png)\n\nClick *Draft a new release*.\n\n![](/images/draft_release.png)\n\nEach release creates a new tag. Set the name for the tag to be created, and set a name for the release (these may be identical). Note that setting a version here does not change the version of your coordinates configured in your `build.gradle.kts` file, so you should update that version before creating a new release.\n\n![](/images/create_release_and_tag.png)\n\nDouble-check the branch you want to target with the release (especially if you want to release from a branch that’s different from your default), and add appropriate release notes for your new version.\n\nThe checkboxes below allow you to mark a release as a pre-release (useful for alpha, beta, or RC versions of a library), or to set the release as the latest available one:\n\n![](/images/release_settings.png)\n\nClick the *Publish release* button to create the new release. This will immediately show up on your GitHub repository’s main page.\n\nClick the Actions tab on the top of your GitHub repository. Here you’ll see the new workflow was triggered by the GitHub release. Click it to see the outputs of the publication task.\n\nAfter this task completes successfully, navigate to the [Deployments](https://central.sonatype.com/publishing/deployments) dashboard. You should see a new deployment here. This deployment will be in the *pending* and *validating* states for some time while Maven Central performs checks on it.\n\nOnce your deployment moves to a *validated* state, you should see that it contains all the artifacts you’ve uploaded. If everything looks correct, click the *Publish* button to release these artifacts.\n\n![](/images/published_on_maven_central.png)\n\nNote that it will take some time (about 15–30 minutes, usually) after the release for the artifacts to be available publicly on Maven Central.\nAlso note that the library may be available for use before they are indexed on [the Maven Central website](https://central.sonatype.com/).\n\nThere’s also another task available which both uploads and releases the artifacts automatically once the deployment is verified, without having to manually release them on the website:\n\n```bash\n./gradlew publishAndReleaseToMavenCentral\n```\n\n**Et voilà, you have successfully published your library to Maven Central.**\n\n# Next steps\n- Share your library with the Kotlin Community in the `#feed` channel in the [Kotlin Slack](https://kotlinlang.slack.com/) (To sign up visit https://kotl.in/slack.)\n- Add [shield.io badges](https://shields.io/badges/maven-central-version) to your README.\n- Create a documentation site for your project using [Writerside](https://www.jetbrains.com/writerside/). \n- Share API documentation for your project using [Dokka](https://kotl.in/dokka).\n- Add [Renovate](https://docs.renovatebot.com/) to automatically update dependencies.\n\n# Other resources\n* [Publishing via the Central Portal](https://central.sonatype.org/publish-ea/publish-ea-guide/)\n* [Gradle Maven Publish Plugin \\- Publishing to Maven Central](https://vanniktech.github.io/gradle-maven-publish-plugin/central/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfanmhat%2Fai4kt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferfanmhat%2Fai4kt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfanmhat%2Fai4kt/lists"}