-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Conventions Rework * Conventions Rework * Conventions Rework * Conventions Rework * Conventions Rework * Conventions Rework * GH Actions fixes * Kotlin 1.5.0 * Kotlin 1.5.20-RC * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423 * Kotlin 1.5.30-dev-2423
- Loading branch information
Showing
78 changed files
with
702 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,30 @@ on: | |
version: | ||
required: true | ||
description: Package version to publish under | ||
skipPages: | ||
description: Should we skip releasing GitHub pages | ||
required: false | ||
default: "y" | ||
skipGitHub: | ||
description: Should we skip publishing artefacts to GitHub Packages | ||
required: false | ||
default: "y" | ||
skipMavenCentral: | ||
description: Should we skip publishing artefacts to Maven Central | ||
required: false | ||
default: "y" | ||
release: | ||
types: [ created ] | ||
|
||
env: | ||
VERSION: ${{ github.event.release.tag_name }} | ||
GRADLE_OPTS: "-Dorg.gradle.daemon=false" | ||
|
||
jobs: | ||
check: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
max-parallel: 5 | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- macos-latest | ||
|
@@ -41,19 +57,37 @@ jobs: | |
- run: ./gradlew check publishToMavenLocal --info | ||
name: Gradle Check | ||
|
||
release-GitHub: | ||
release-Artefacts: | ||
runs-on: ${{ matrix.os }} | ||
needs: [ check ] | ||
env: | ||
GH_USERNAME: ${{ github.actor }} | ||
GH_PASSWORD: ${{ github.token }} | ||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} | ||
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} | ||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} | ||
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | ||
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | ||
strategy: | ||
max-parallel: 5 | ||
matrix: | ||
repository: | ||
- name: Github Packages | ||
tasks: publishAllPublicationsToGitHubRepository | ||
enabled: ${{ github.event.inputs.skipGitHub != 'y' && true }} | ||
- name: Maven Central | ||
# Requires to manually release a new version on https://s01.oss.sonatype.org/#stagingRepositories | ||
# If you're brave, you could change it to `publishToSonatype closeAndReleaseSonatypeStagingRepository` to fully automate the release | ||
tasks: publishToSonatype closeSonatypeStagingRepository | ||
enabled: ${{ github.event.inputs.skipMavenCentral != 'y' && true }} | ||
os: | ||
- macos-latest | ||
- windows-latest | ||
- ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
if: ${{ matrix.repository.enabled == true }} | ||
- name: Restore Gradle cache | ||
if: ${{ matrix.repository.enabled == true }} | ||
id: cache | ||
uses: actions/[email protected] | ||
with: | ||
|
@@ -67,23 +101,22 @@ jobs: | |
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- uses: actions/setup-java@v2 | ||
if: ${{ matrix.repository.enabled == true }} | ||
with: | ||
distribution: 'adopt' | ||
java-version: 11 | ||
- run: | | ||
- name: Gradle Publish | ||
if: ${{ matrix.repository.enabled == true }} | ||
shell: bash | ||
run: | | ||
VERSION=${VERSION:=${{ github.event.inputs.version }}} | ||
VERSION=${VERSION/v} | ||
./gradlew publish -Pversion=${VERSION//v} --info | ||
shell: bash | ||
name: Gradle Publish | ||
env: | ||
VERSION: ${{ github.event.release.tag_name }} | ||
GH_USERNAME: ${{ github.actor }} | ||
GH_PASSWORD: ${{ github.token }} | ||
./gradlew ${{ matrix.repository.tasks }} -Pversion=${VERSION//v} | ||
release-Dokka: | ||
runs-on: ubuntu-latest | ||
needs: [release-GitHub] | ||
needs: [check] | ||
if: ${{ github.event.inputs.skipPages != 'y' }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Restore Gradle cache | ||
|
@@ -103,17 +136,21 @@ jobs: | |
with: | ||
distribution: 'adopt' | ||
java-version: 11 | ||
- uses: nick-invision/retry@v2 | ||
name: Build Dokka | ||
env: | ||
JVM_ARGS: -XX:MaxMetaspaceSize=2g | ||
with: | ||
max_attempts: 3 | ||
timeout_minutes: 30 | ||
command: ./gradlew dokkaHtmlMultiModule --info | ||
- uses: crazy-max/ghaction-github-pages@v2 | ||
- name: Build Dokka Pages | ||
shell: bash | ||
run: | | ||
VERSION=${VERSION:=${{ github.event.inputs.version }}} | ||
VERSION=${VERSION/v} | ||
REPO_NAME=${{ github.repository }} | ||
REPO_NAME=${REPO_NAME#${{ github.repository_owner }}/} | ||
./gradlew dokkaHtmlMultiModule -Pversion=${VERSION//v}; | ||
cp -avr build/dokka/htmlMultiModule/ public; | ||
find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec gzip -f -k {} \; | ||
echo "/${REPO_NAME} /${REPO_NAME}/${REPO_NAME}/index.html 301" > public/_redirects; | ||
echo "/${REPO_NAME}/index.html /${REPO_NAME}/${REPO_NAME}/index.html 301" >> public/_redirects; | ||
- uses: crazy-max/[email protected] | ||
with: | ||
target_branch: gh-pages | ||
build_dir: build/dokka/htmlMultiModule | ||
build_dir: public | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ build/ | |
.vscode/ | ||
local.properties | ||
*.hprof | ||
lint.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,85 @@ | ||
[![Dokka docs](https://img.shields.io/badge/docs-dokka-orange?style=flat-square)](http://mpetuska.github.io/template-kmp-library) | ||
[![Version maven-central](https://img.shields.io/maven-central/v/dev.petuska/template-kmp-library?logo=apache-maven&style=flat-square)](https://mvnrepository.com/artifact/dev.petuska/template-kmp-library/latest) | ||
|
||
# template-kmp-library | ||
|
||
Kotlin multiplatform library template. | ||
|
||
Has a baseline setup for a multiplatform library supporting all kotlin [targets](https://kotlinlang.org/docs/mpp-supported-platforms.html) | ||
Has a baseline setup for a multiplatform library supporting all | ||
kotlin [targets](https://kotlinlang.org/docs/mpp-supported-platforms.html) | ||
except android (any help in getting that setup welcome) & deprecated wasm32. | ||
|
||
## Features | ||
|
||
* Native target grouping and shared sourceSets | ||
* Wrapper library module that declares dependencies on all lib modules | ||
* Uniform configuration via conventional plugins `local.common-conventions` & `local.library-conventions` | ||
* Uniform configuration via conventional plugins `convention.common`, `convention.library` & `convention.publishing` | ||
* Local `test` module for shared test utilities (a helper function to run coroutine tests in common sourceSet included) | ||
* Local `sandbox` module for easy library consumer side checks | ||
* Publication control to avoid multiple publications for targets that can be built on multiple hosts | ||
* `ktlint` plugin with automatic `git-hooks` | ||
* `refreshVersions` plugin for better library version control | ||
* Main host for publications can be changed via `gradle.properties#project.mainOS` property | ||
* Gradle Build Scan setup | ||
* GH dependabot setup | ||
* GH release action for platform dependant publications | ||
* GH check action for platform dependant tests on PRs | ||
* Maven Central publishing setup | ||
* GH Packages publishing setup | ||
|
||
## Setup | ||
|
||
Here are some pointers to help you get up and running with this template | ||
|
||
### Badges | ||
|
||
This README contains some useful badges for your project. To tailor them to your artefacts the following changes needs | ||
to be made: | ||
|
||
* `Dokka docs` - change the link as `(http://$GH_USERNAME.github.io/$GH_PROJECT_NAME)` | ||
* `Version maven-central - change all occurrences of `dev.petuska` to your own group and `template-kmp-library` to your | ||
root library name | ||
|
||
### gradle.properties | ||
|
||
Have a look at `gradle.properties` file and change these properties as needed | ||
|
||
* `gh.owner.id` - main library developer's username | ||
* `gh.owner.name` - main library developer's name | ||
* `gh.owner.email` - main library developer's email | ||
* `project.mainOS` - main host to publish cross-platform artefacts from (to avoid duplicate publications) | ||
* `group` - artefacts' group | ||
* `description` - library description | ||
* `version` - library version (overridden in CI, so doesn't really matter here) | ||
|
||
### Modules | ||
|
||
All the library modules should go to `/lib/` directory and be included in `/settings.gradle.kts`. There are already two | ||
sample modules to illustrate how simple the setup is (`/lib/template-kmp-library-core` & `template-kmp-library-dsl`). | ||
They both contain some sample code and tests that make use of local `/test` module with testing utilities. | ||
|
||
### Kotlin Targets | ||
|
||
The template comes packed with all kotlin targets preconfigured, however if you want to remove some of them or tweak the | ||
config, you only need to make changes as needed in `/buildSrc/src/main/kotlin/convention.library.gradle.kts`. Removing | ||
targets from this file will not break any publications as they're configured on top of pre-registered targets. | ||
|
||
### GitHub Actions | ||
|
||
The template also comes with GH actions to check builds on PRs and publish artefacts when creating a GH release. By | ||
default, it'll publish to GH packages and Maven Central. However to fully unlock Maven Central publishing, you'll need | ||
to add these secrets to your GH repository. If you want to quickly disable Maven Central publishing, you can toggle it | ||
at `.github/workflows/release.yml#L80` | ||
|
||
* `SIGNING_KEY` - GPG signing key | ||
* `SIGNING_KEY_ID` - GPG signing key ID | ||
* `SIGNING_PASSWORD` - GPG signing key password (if set) | ||
* `SONATYPE_PASSWORD` - Sonatype PAT username | ||
* `SONATYPE_USERNAME` - Sonatype PAT password | ||
|
||
## Known Issues | ||
|
||
* [KT-46957](https://youtrack.jetbrains.com/issue/KT-46957) - Commonizer breaks for linuxMips32. This is fixed and | ||
scheduled to be released in 1.5.30-M1. However, to make the setup work now, the template is currently using dev build | ||
from kotlin snapshot repositories. If you'd like to use a stable kotlin version instead, remove linuxMips32 from linux | ||
native target group in `/buildSrc/src/main/kotlin/convention.library.gradle.kts`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
plugins { | ||
id("local.library-conventions") | ||
id("convention.publishing-nexus") | ||
id("com.github.jakemarsden.git-hooks") | ||
idea | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
subprojects.filter { it.path.startsWith(":lib:") }.forEach { | ||
api(it) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
gitHooks { | ||
setHooks( | ||
mapOf( | ||
"post-checkout" to "ktlintApplyToIdea", | ||
"pre-commit" to "ktlintFormat", | ||
"pre-push" to "check" | ||
"pre-push" to "ktlintCheck" | ||
) | ||
) | ||
} | ||
|
||
idea { | ||
module { | ||
isDownloadSources = true | ||
isDownloadJavadoc = true | ||
gradleEnterprise { | ||
buildScan { | ||
termsOfServiceUrl = "https://gradle.com/terms-of-service" | ||
termsOfServiceAgree = "yes" | ||
} | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
subprojects.filter { it.path.startsWith(":lib:") }.forEach { | ||
api(it) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import de.fayard.refreshVersions.bootstrapRefreshVersionsForBuildSrc | ||
|
||
buildscript { | ||
repositories { gradlePluginPortal() } | ||
dependencies.classpath("de.fayard.refreshVersions:refreshVersions:0.9.7") | ||
pluginManagement { | ||
plugins { | ||
id("de.fayard.refreshVersions") version "0.10.1" | ||
} | ||
} | ||
|
||
bootstrapRefreshVersionsForBuildSrc() | ||
plugins { | ||
id("de.fayard.refreshVersions") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
plugins { | ||
id("org.jlleitschuh.gradle.ktlint") | ||
idea | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
if (project.properties["project.useSnapshotRepositories"] == "true") { | ||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") | ||
} | ||
} | ||
|
||
idea { | ||
module { | ||
isDownloadSources = true | ||
isDownloadJavadoc = true | ||
} | ||
} | ||
|
||
tasks { | ||
withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
} |
Oops, something went wrong.