From b6eef07983a15f9bae54a9f7115669c7b3d83115 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Thu, 28 Jan 2021 23:30:49 +0300 Subject: [PATCH 01/41] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/issue_reminder.yml | 22 +++++++++++++++ .github/workflows/linter.yml | 37 ++++++++++++++++++++++++ .github/workflows/shfmt.yml | 42 ++++++++++++++++++++++++++++ .github/workflows/version-update.yml | 31 ++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 .github/workflows/issue_reminder.yml create mode 100644 .github/workflows/linter.yml create mode 100644 .github/workflows/shfmt.yml create mode 100644 .github/workflows/version-update.yml diff --git a/.github/workflows/issue_reminder.yml b/.github/workflows/issue_reminder.yml new file mode 100644 index 0000000..44a7a2e --- /dev/null +++ b/.github/workflows/issue_reminder.yml @@ -0,0 +1,22 @@ +name: Issue Reminder +on: + issues: + types: [ opened ] + +jobs: + issue_comment: + runs-on: ubuntu-latest + steps: + - name: Comment on issue + uses: actions/github-script@0.9.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + var url = 'https://github.com/AlexRogalskiy/gradle-kotlin-sample/blob/master/.github/ISSUE_TEMPLATE/bug_report.md' + var msg = `Thank you for opening an issue. If this issue is related to a bug, please follow the steps and provide the information outlined in the [Bug Report Guide](${url}). Failure to follow these instructions may result in automatic closing of this issue.` + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: msg + }) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..a2a5363 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,37 @@ +name: Lint Code Base + +# +# Documentation: +# https://help.github.com/en/articles/workflow-syntax-for-github-actions +# + +############################# +# Start the job on all push # +############################# +on: + push: + branches-ignore: [ master ] + # Remove the line above to run when pushing to master + pull_request: + branches: [ master ] + +############### +# Set the Job # +############### +jobs: + build: + # Name the Job + name: Lint Code Base + # Set the agent to run on + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v3 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/shfmt.yml b/.github/workflows/shfmt.yml new file mode 100644 index 0000000..92bf85c --- /dev/null +++ b/.github/workflows/shfmt.yml @@ -0,0 +1,42 @@ +name: Check Shell scripts + +on: + pull_request: + paths: + - "**/*.sh" + +jobs: + shfmt: + name: Shellformat + runs-on: ubuntu-latest + steps: + - name: Prepare git + run: git config --global core.autocrlf false + + - name: Checkout repository + uses: actions/checkout@v1 + + - run: docker run -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.6.3 shfmt -sr -i 2 -l -w -ci . + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - name: Prepare git + run: git config --global core.autocrlf false + + - name: Checkout repository + uses: actions/checkout@v1 + + - run: shellcheck *.sh + shellcheck2: + name: Shellcheck2 + runs-on: ubuntu-latest + steps: + - name: Prepare git + run: git config --global core.autocrlf false + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml new file mode 100644 index 0000000..ba037ec --- /dev/null +++ b/.github/workflows/version-update.yml @@ -0,0 +1,31 @@ +name: Version Update + +on: + push: + tags: + - '*.**' + +jobs: + update-version: + name: Update VERSION + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: master + fetch-depth: 0 + + - name: Edit version.txt + run: echo "VERSION = \"$(git describe --tags `git rev-list --tags --max-count=1`)\"" > version.txt + + - name: Commit update + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + skip_dirty_check: true + commit_message: 'Update VERSION' + commit_options: '--no-verify --signoff' + commit_user_name: GitHub Bot + commit_user_email: github-actions@nullables.io + commit_author: GitHub Bot From a1b927a8eb1633323cdfdafca30ca788f18feaee Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 29 Jan 2021 12:39:34 +0300 Subject: [PATCH 02/41] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/unlock-reopened-issues.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/unlock-reopened-issues.yml diff --git a/.github/workflows/unlock-reopened-issues.yml b/.github/workflows/unlock-reopened-issues.yml new file mode 100644 index 0000000..178ca5a --- /dev/null +++ b/.github/workflows/unlock-reopened-issues.yml @@ -0,0 +1,13 @@ +name: Unlock reopened issue + +on: + issues: + types: [ reopened ] + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: Dunning-Kruger/unlock-issues@v1 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From 11cc7cf778a40f082f48c19e93ee5d3660940069 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 30 Jan 2021 22:45:59 +0300 Subject: [PATCH 03/41] docs: updates on documentation Added informational and corporate documentation --- build.gradle.kts | 8 +++++--- buildSrc/src/main/kotlin/constants/Dependencies.kt | 2 ++ buildSrc/src/main/kotlin/constants/Versions.kt | 1 + buildSrc/src/main/kotlin/extensions/RepositoryHandler.kt | 6 ++++++ settings.gradle.kts | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3848ca3..163a520 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,10 +36,11 @@ repositories { maven("https://plugins.gradle.org/m2/") maven("https://kotlin.bintray.com/kotlinx") - maven("https://dl.bintray.com/serpro69/maven/") - maven("https://dl.bintray.com/arrow-kt/arrow-kt/") + maven("https://dl.bintray.com/serpro69/maven") + maven("https://dl.bintray.com/arrow-kt/arrow-kt") maven("https://dl.bintray.com/kotlin/kotlin-eap") - maven("http://dl.bintray.com/kategory/maven") + maven("https://dl.bintray.com/kategory/maven") + maven("https://dl.bintray.com/kotlin/kotlinx") } plugins { @@ -127,6 +128,7 @@ subprojects { // kotlinx library dependencies implementation(Dependencies.Core.kotlinx_coroutines) implementation(Dependencies.Core.kotlinx_serialization) + implementation(Dependencies.Core.kotlinx_datetime) // kotlin test library dependencies testImplementation(Dependencies.Test.kotlin_test) diff --git a/buildSrc/src/main/kotlin/constants/Dependencies.kt b/buildSrc/src/main/kotlin/constants/Dependencies.kt index 3b83b95..7d642a7 100644 --- a/buildSrc/src/main/kotlin/constants/Dependencies.kt +++ b/buildSrc/src/main/kotlin/constants/Dependencies.kt @@ -30,6 +30,8 @@ object Dependencies { "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.kotlin_coroutines}" const val kotlinx_serialization = "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.kotlinx_serialization}" + const val kotlinx_datetime = + "org.jetbrains.kotlinx:kotlinx-datetime:${Versions.kotlin_datetime}" // Clikt library dependencies const val clikt = diff --git a/buildSrc/src/main/kotlin/constants/Versions.kt b/buildSrc/src/main/kotlin/constants/Versions.kt index e1659a2..86ec6f8 100644 --- a/buildSrc/src/main/kotlin/constants/Versions.kt +++ b/buildSrc/src/main/kotlin/constants/Versions.kt @@ -20,6 +20,7 @@ object Versions { const val kotlin = "1.4.30-RC" const val kotlinx_serialization = "0.20.0" const val kotlin_coroutines = "1.3.4" + const val kotlin_datetime = "0.1.1" const val rxjava = "2.2.20" const val logback = "1.2.3" const val arrow = "0.11.0" diff --git a/buildSrc/src/main/kotlin/extensions/RepositoryHandler.kt b/buildSrc/src/main/kotlin/extensions/RepositoryHandler.kt index 7159017..51d6594 100644 --- a/buildSrc/src/main/kotlin/extensions/RepositoryHandler.kt +++ b/buildSrc/src/main/kotlin/extensions/RepositoryHandler.kt @@ -16,6 +16,7 @@ package extensions import org.gradle.api.artifacts.dsl.RepositoryHandler +import java.net.URI /** * Applies default plugins for repository @@ -23,5 +24,10 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler fun RepositoryHandler.applyDefaults() { google() mavenCentral() + mavenLocal() jcenter() + maven { + name = "KotlinX" + url = URI.create("https://dl.bintray.com/kotlin/kotlinx") + } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 87bacbd..64ba69e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,6 +21,7 @@ pluginManagement { maven("https://dl.bintray.com/kotlin/kotlin-eap/") maven("https://dl.bintray.com/kotlin/kotlin-dev/") + maven("https://dl.bintray.com/kotlin/kotlinx/") maven("https://plugins.gradle.org/m2/") } } From a584eb49ea01715c68a4d8e172a5c20cf1205a87 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sun, 31 Jan 2021 16:52:19 +0300 Subject: [PATCH 04/41] docs: updates on documentation Added informational and corporate documentation --- buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts index 666889b..cc761cb 100644 --- a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts +++ b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts @@ -141,7 +141,7 @@ tasks { "-Xuse-ir", "-Xskip-runtime-version-check", "-Xdisable-default-scripting-plugin", - "-Xuse-experimental=kotlin.Experimental", + "-Xuse-experimental=kotlin.Experimental,kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn", "-Xinline-classes" ) From f28ebdc0c8165584a896f4e197c250cc0fda8c53 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 1 Feb 2021 21:04:56 +0300 Subject: [PATCH 05/41] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/changelog.yml | 41 +++++++++++++++++++ .typo-ci.yml | 41 +++++++++++++++++++ annotation/build.gradle.kts | 23 +++++++++++ .../main/kotlin/tasks/common-tasks.gradle.kts | 5 ++- settings.gradle.kts | 3 +- 5 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/changelog.yml create mode 100644 .typo-ci.yml create mode 100644 annotation/build.gradle.kts diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..89b58d0 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,41 @@ +# From: https://github.com/hopsoft/stimulus_reflex/blob/master/.github/workflows/changelog.yml +name: Changelog + +on: + workflow_dispatch: + release: + types: [ created ] + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 4 + if: "!contains(github.event.head_commit.message, '[nodoc]')" + steps: + - uses: actions/checkout@master + - name: Set up Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + - uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-changelog-gem + restore-keys: ${{ runner.os }}-changelog-gem + - name: Create local changes + run: | + gem install github_changelog_generator + github_changelog_generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} --token ${{ secrets.GITHUB_TOKEN }} --exclude-labels duplicate,question,invalid,wontfix,nodoc + - name: Commit files + run: | + git config --local user.email "github-actions@example.com" + git config --local user.name "GitHub Actions" + git commit -am "[nodoc] Update Changelog\n\nAdded CHANGELOG file" || echo "No changes to commit" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} \ No newline at end of file diff --git a/.typo-ci.yml b/.typo-ci.yml new file mode 100644 index 0000000..81bd581 --- /dev/null +++ b/.typo-ci.yml @@ -0,0 +1,41 @@ +# This is a sample .typo-ci.yml file, it's used to configure how Typo CI will behave. +# Add it to the root of your project and push it to github. +--- + +# What language dictionaries should it use? By default Typo CI will select 'en' & 'en_GB' +# Currently Typo CI supports: +# de +# en +# en_GB +# es +# fr +# it +# pt +# pt_BR +# tr +dictionaries: + - en + - en_GB + +# Any files/folders we should ignore? +excluded_files: + - "vendor/**/*" + - "node_modules/**/*" + - "*.key" + - "*.enc" + - "*.min.css" + - "*.css.map" + - "*.min.js" + - "*.js.map" + - "*.mk" + - "package-lock.json" + - "yarn.lock" + - "Gemfile.lock" + - ".typo-ci.yml" + +# Any typos we should ignore? +excluded_words: + - typoci + +# Would you like filenames to also be spellchecked? +spellcheck_filenames: true \ No newline at end of file diff --git a/annotation/build.gradle.kts b/annotation/build.gradle.kts new file mode 100644 index 0000000..0953cb8 --- /dev/null +++ b/annotation/build.gradle.kts @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021. Alexander Rogalskiy. All Rights Reserved. + * + * 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. + */ +plugins { + kotlin("jvm") +} + +repositories { + mavenCentral() + jcenter() +} diff --git a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts index cc761cb..d098156 100644 --- a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts +++ b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts @@ -140,9 +140,12 @@ tasks { "-progressive", "-Xuse-ir", "-Xskip-runtime-version-check", + "-Xskip-prerelease-check", "-Xdisable-default-scripting-plugin", - "-Xuse-experimental=kotlin.Experimental,kotlinx.coroutines.ExperimentalCoroutinesApi", + "-Xuse-experimental=kotlin.Experimental", "-Xopt-in=kotlin.RequiresOptIn", + "-Xopt-in=kotlin.time.ExperimentalTime", + "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xinline-classes" ) kotlinOptions.allWarningsAsErrors = project.shouldTreatCompilerWarningsAsErrors() diff --git a/settings.gradle.kts b/settings.gradle.kts index 64ba69e..b0a0783 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -43,5 +43,6 @@ rootProject.name = "gradle-kotlin-sample" include( "appflow", - "testflow" + "testflow", + "annotation" ) From 6b11b647321ddd6e3dca6dd288a25ccb6ac597d6 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 1 Feb 2021 23:46:13 +0300 Subject: [PATCH 06/41] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/changelog.yml | 2 +- .github/workflows/remove-old-artifacts.yml | 18 ++++++++++++++++++ .typo-ci.yml | 2 +- annotation/build.gradle.kts | 3 ++- .../main/kotlin/tasks/common-tasks.gradle.kts | 2 ++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/remove-old-artifacts.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 89b58d0..799e359 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -38,4 +38,4 @@ jobs: uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} \ No newline at end of file + branch: ${{ github.ref }} diff --git a/.github/workflows/remove-old-artifacts.yml b/.github/workflows/remove-old-artifacts.yml new file mode 100644 index 0000000..822fff0 --- /dev/null +++ b/.github/workflows/remove-old-artifacts.yml @@ -0,0 +1,18 @@ +name: Remove old artifacts + +on: + schedule: + # Every day at 1am + - cron: '0 1 * * *' + +jobs: + remove-old-artifacts: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Remove old artifacts + uses: c-hive/gha-remove-artifacts@v1 + with: + age: '7 days' + skip-tags: false diff --git a/.typo-ci.yml b/.typo-ci.yml index 81bd581..b8a3992 100644 --- a/.typo-ci.yml +++ b/.typo-ci.yml @@ -38,4 +38,4 @@ excluded_words: - typoci # Would you like filenames to also be spellchecked? -spellcheck_filenames: true \ No newline at end of file +spellcheck_filenames: true diff --git a/annotation/build.gradle.kts b/annotation/build.gradle.kts index 0953cb8..b8e655b 100644 --- a/annotation/build.gradle.kts +++ b/annotation/build.gradle.kts @@ -14,7 +14,8 @@ * limitations under the License. */ plugins { - kotlin("jvm") + `jvm` + `kotlin-kapt` } repositories { diff --git a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts index d098156..7c01e6f 100644 --- a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts +++ b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts @@ -46,6 +46,7 @@ java { } kapt { + generateStubs = true useBuildCache = true } @@ -139,6 +140,7 @@ tasks { kotlinOptions.freeCompilerArgs = listOf( "-progressive", "-Xuse-ir", + "-Xjvm-default=enable", "-Xskip-runtime-version-check", "-Xskip-prerelease-check", "-Xdisable-default-scripting-plugin", From e348400d001bd34078a32dcbcd6b8e0747255083 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 1 Feb 2021 23:47:17 +0300 Subject: [PATCH 07/41] docs: updates on documentation Added informational and corporate documentation --- buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts index 7c01e6f..d2bb26b 100644 --- a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts +++ b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts @@ -46,7 +46,6 @@ java { } kapt { - generateStubs = true useBuildCache = true } From e3765366fde896c6160e145c7bff772fafd08cfd Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Mon, 1 Feb 2021 23:49:02 +0300 Subject: [PATCH 08/41] docs: updates on documentation Added informational and corporate documentation --- annotation/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/annotation/build.gradle.kts b/annotation/build.gradle.kts index b8e655b..0fa5487 100644 --- a/annotation/build.gradle.kts +++ b/annotation/build.gradle.kts @@ -14,8 +14,8 @@ * limitations under the License. */ plugins { - `jvm` - `kotlin-kapt` + id("org.jetbrains.kotlin.jvm") + id("org.jetbrains.kotlin.kapt") } repositories { From df0305405bde4701d778efd2b5c132b4b225d4d2 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Wed, 3 Feb 2021 12:02:45 +0300 Subject: [PATCH 09/41] docs: updates on workflows Added information on documentation --- buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts b/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts index 481793e..b2412e9 100644 --- a/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts +++ b/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts @@ -34,6 +34,7 @@ plugins { jacoco { toolVersion = Versions.jacoco + includeNoLocationClasses = true } val examplesOrTestUtils = setOf( From 008e2386279862f4a1dbdb4c8d77bf65db711d32 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Thu, 4 Feb 2021 05:22:56 +0300 Subject: [PATCH 10/41] docs: updates on documentation Added informational and corporate documentation --- .../main/kotlin/tasks/common-tasks.gradle.kts | 10 ++ buildSrc/src/main/kotlin/utils/AppConfig.kt | 121 ++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 buildSrc/src/main/kotlin/utils/AppConfig.kt diff --git a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts index d2bb26b..1fa2f25 100644 --- a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts +++ b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts @@ -153,6 +153,11 @@ tasks { } } + withType { + (options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") + options.encoding = "UTF-8" + } + withType { useJUnitPlatform() @@ -244,4 +249,9 @@ tasks { delete(allprojects.map { it.buildDir }) // delete(rootProject.buildDir) } + + register("clean", Delete::class) { + delete(rootProject.buildDir) + delete(File("buildSrc\\build")) + } } diff --git a/buildSrc/src/main/kotlin/utils/AppConfig.kt b/buildSrc/src/main/kotlin/utils/AppConfig.kt new file mode 100644 index 0000000..a2cfca0 --- /dev/null +++ b/buildSrc/src/main/kotlin/utils/AppConfig.kt @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2021. Alexander Rogalskiy. All Rights Reserved. + * + * 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 utils + +import org.gradle.api.Project +import java.io.File + +object AppConfig { + + object Build { + const val APPLICATION_ID = "meow.bottomnavigation" + const val APP_MODULE = "Sample" + const val APP_PACKAGE = "meow/bottomnavigation_sample" + const val LIBRARY_MODULE = "MeowBottomNavigation" + const val LIBRARY_PACKAGE = "meow.bottomnavigation" + const val SRC_MAIN = "src/main/" + + enum class PHASE(var alias: String) { + ALPHA("alpha"), + BETA("beta"), + CANARY("canary"), + RC("rc"), + STABLE("") + } + } + + object Versions { + const val API = 1 + const val MAJOR = 1 + const val MINOR = 3 + const val PATCH = 1 + + val BUILD_PHASE = Build.PHASE.STABLE + + const val KOTLIN = "1.4.21" + } + + object Dependencies { + // Dependencies.implementationItems.forEach { + // implementation(it) + // } + val implementationItems = arrayOf( + // Kotlin + kotlin("stdlib-jdk8", Versions.KOTLIN) + ) + + val kaptItems = arrayListOf() + } + + fun generateVersionCode(): Int { + return Versions.API * 10000000 + Versions.BUILD_PHASE.ordinal * 1000000 + Versions.MAJOR * 10000 + Versions.MINOR * 100 + Versions.PATCH + } + + fun generateVersionName(): String { + val type = if (Versions.BUILD_PHASE.alias == "") "" else "-${Versions.BUILD_PHASE.alias}" + return "${Versions.MAJOR}.${Versions.MINOR}.${Versions.PATCH}$type" + } +} + +fun Project.getPropertyAny(key: String): T { + val properties = java.util.Properties().apply { + load(rootProject.file("local.properties").inputStream()) + } + @Suppress("UNCHECKED_CAST") + return properties.getProperty(key) as T +} + +fun kotlinx(module: String, version: String? = null): Any = + "org.jetbrains.kotlinx:kotlinx-$module${version?.let { ":$version" } ?: ""}" + +fun kotlin(module: String, version: String? = null): Any = + "org.jetbrains.kotlin:kotlin-$module${version?.let { ":$version" } ?: ""}" + +fun getAllResourcesSrcDirs(project: Project, isLibrary: Boolean = false): ArrayList { + val moduleName = if (isLibrary) AppConfig.Build.LIBRARY_MODULE else AppConfig.Build.APP_MODULE + val packageName = + if (isLibrary) AppConfig.Build.LIBRARY_PACKAGE else AppConfig.Build.APP_PACKAGE + val list = arrayListOf() + val path = + project.rootDir.absolutePath + "\\" + moduleName + "\\src\\main\\kotlin\\" + packageName + val root = File(path) + + list.add(project.rootDir.absolutePath + "\\" + moduleName + "\\src\\main\\res") + + root.listDirectoriesWithChild().forEach { directory -> + if (directory.isRes()) + list.add(directory.path) + } + + return list +} + +fun File.listDirectories() = listFiles()?.filter { it.isDirectory } ?: arrayListOf() +fun File.listDirectoriesWithChild(): List { + val list = ArrayList() + + fun File.findAllDirectories(list: ArrayList) { + listDirectories().forEach { + it.findAllDirectories(list) + list.add(it) + } + } + + findAllDirectories(list) + return list +} + +fun File.isRes() = name == "res" From 22c0eb938b1a58d6ca43d3ba151dc8725fb1fbb5 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 6 Feb 2021 15:14:09 +0300 Subject: [PATCH 11/41] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/remove-labels.yml | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/remove-labels.yml diff --git a/.github/workflows/remove-labels.yml b/.github/workflows/remove-labels.yml new file mode 100644 index 0000000..ba74dcc --- /dev/null +++ b/.github/workflows/remove-labels.yml @@ -0,0 +1,53 @@ +name: Remove outdated labels + +on: + pull_request_target: + types: + - closed + issues: + types: + - closed + +jobs: + remove-merged-pr-labels: + name: Remove merged pull request labels + if: github.event.pull_request.merged + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + awaiting reply + changes requested + duplicate + in discussion + invalid + out of scope + pending + won't add + + remove-closed-pr-labels: + name: Remove closed pull request labels + if: github.event_name == 'pull_request_target' && (! github.event.pull_request.merged) + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + in discussion + pending + + remove-closed-issue-labels: + name: Remove closed issue labels + if: github.event.issue.state == 'closed' + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + in discussion + pending + tracking From 7a2e406dc928a5da6da2972744c1d0430aa644de Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Sat, 6 Feb 2021 15:20:03 +0300 Subject: [PATCH 12/41] docs: updates on documentation Added informational and corporate documentation --- .github/workflows/add-labels.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/add-labels.yml diff --git a/.github/workflows/add-labels.yml b/.github/workflows/add-labels.yml new file mode 100644 index 0000000..da4328f --- /dev/null +++ b/.github/workflows/add-labels.yml @@ -0,0 +1,13 @@ +name: Pull Request Labeler + +on: + pull_request_target: + types: [ opened ] + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: ericcornelissen/labeler@label-based-on-status + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} From 0a47919ccea8fe205235a2117b2f727d047b38b7 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Wed, 10 Feb 2021 14:16:24 +0300 Subject: [PATCH 13/41] docs: updates on documentation Added informational and corporate documentation --- .../src/main/kotlin/plugins/jacoco.gradle.kts | 2 +- .../main/kotlin/plugins/publish.gradle.kts | 36 +++++++++++++++++++ .../main/kotlin/tasks/common-tasks.gradle.kts | 7 +--- versions.gradle.kts | 4 +++ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts b/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts index b2412e9..11b1367 100644 --- a/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts +++ b/buildSrc/src/main/kotlin/plugins/jacoco.gradle.kts @@ -34,7 +34,7 @@ plugins { jacoco { toolVersion = Versions.jacoco - includeNoLocationClasses = true + //includeNoLocationClasses = true } val examplesOrTestUtils = setOf( diff --git a/buildSrc/src/main/kotlin/plugins/publish.gradle.kts b/buildSrc/src/main/kotlin/plugins/publish.gradle.kts index b30bf78..b86295e 100644 --- a/buildSrc/src/main/kotlin/plugins/publish.gradle.kts +++ b/buildSrc/src/main/kotlin/plugins/publish.gradle.kts @@ -19,6 +19,7 @@ import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublicationContainer import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication import org.gradle.plugins.signing.SigningExtension apply(plugin = "java") @@ -106,5 +107,40 @@ publishing { } } } + +// register("sonatype", MavenPublication::class) { +// artifactId = "smartype-generator" +// artifact(fatJar) +// artifact(tasks["javadocJar"]) +// artifact(tasks["sourcesJar"]) +// pom { +// name.set("Smartype Generator") +// description.set("Generator ") +// url.set("https://github.com/mParticle/smartype") +// licenses { +// license { +// name.set("The Apache License, Version 2.0") +// url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") +// } +// } +// developers { +// developer { +// id.set("samdozor") +// name.set("Sam Dozor") +// email.set("sdozor@mparticle.com") +// } +// developer { +// id.set("peterjenkins") +// name.set("Peter Jenkins") +// email.set("pjenkins@mparticle.com") +// } +// } +// scm { +// connection.set("scm:git:git://github.com/mParticle/smartype.git") +// developerConnection.set("scm:git:ssh://github.com/mParticle/smartype.git") +// url.set("https://github.com/mParticle/smartype") +// } +// } +// } } } diff --git a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts index 1fa2f25..d75ca7c 100644 --- a/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts +++ b/buildSrc/src/main/kotlin/tasks/common-tasks.gradle.kts @@ -76,7 +76,6 @@ configure { // validationDisabled = false //} -// additional source sets sourceSets { createKotlinMainSources(this) createKotlinTestSources(this) @@ -247,11 +246,7 @@ tasks { registering(Delete::class) { delete(allprojects.map { it.buildDir }) -// delete(rootProject.buildDir) - } - - register("clean", Delete::class) { - delete(rootProject.buildDir) delete(File("buildSrc\\build")) +// delete(rootProject.buildDir) } } diff --git a/versions.gradle.kts b/versions.gradle.kts index e4e5158..b2a0f12 100644 --- a/versions.gradle.kts +++ b/versions.gradle.kts @@ -23,4 +23,8 @@ extra.apply { this["appDescription"] = appDescription this["appGroup"] = appGroup this["appVersion"] = appVersion + + this["signing.keyId"] = System.getenv("mavenSigningKeyId") + this["signing.secretKeyRingFile"] = System.getenv("mavenSigningKeyRingFile") + this["signing.password"] = System.getenv("mavenSigningKeyPassword") } From 9ea0dfeac0dce0abaf3a2f82fdd11d7f84132814 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Wed, 10 Feb 2021 14:35:12 +0300 Subject: [PATCH 14/41] docs: updates on documentation Added informational and corporate documentation --- annotation/build.gradle.kts | 24 ------------------------ settings.gradle.kts | 3 +-- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 annotation/build.gradle.kts diff --git a/annotation/build.gradle.kts b/annotation/build.gradle.kts deleted file mode 100644 index 0fa5487..0000000 --- a/annotation/build.gradle.kts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2021. Alexander Rogalskiy. All Rights Reserved. - * - * 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. - */ -plugins { - id("org.jetbrains.kotlin.jvm") - id("org.jetbrains.kotlin.kapt") -} - -repositories { - mavenCentral() - jcenter() -} diff --git a/settings.gradle.kts b/settings.gradle.kts index b0a0783..64ba69e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -43,6 +43,5 @@ rootProject.name = "gradle-kotlin-sample" include( "appflow", - "testflow", - "annotation" + "testflow" ) From 440d33ff3b769a2b302b677e752211e158869609 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Fri, 26 Feb 2021 19:40:58 +0300 Subject: [PATCH 15/41] docs: updates on documentation Added informational and corporate documentation --- .../main/kotlin/extensions/ProjectHandler.kt | 25 ++++++++++++++++--- buildSrc/src/main/kotlin/utils/StringUtils.kt | 22 ++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/extensions/ProjectHandler.kt b/buildSrc/src/main/kotlin/extensions/ProjectHandler.kt index be011a6..6ef1801 100644 --- a/buildSrc/src/main/kotlin/extensions/ProjectHandler.kt +++ b/buildSrc/src/main/kotlin/extensions/ProjectHandler.kt @@ -29,13 +29,30 @@ import utils.shouldTreatCompilerWarningsAsErrors /** * An extension to create main Kotlin source set. * - * @param namedDomainObjectContainer The container to create the corresponding source set + * @param sourceSet The container to create the corresponding source set * * @return The main Kotlin [SourceSet] */ -fun Project.createKotlinMainSources( - namedDomainObjectContainer: NamedDomainObjectContainer -) = MainSources.create(namedDomainObjectContainer, this) +fun Project.createKotlinMainSources(sourceSet: NamedDomainObjectContainer) = + MainSources.create(sourceSet, this) + +fun Project.isJavaProject() = + listOf("java-library", "java", "java-gradle-plugin").any { plugins.hasPlugin(it) } + +fun Project.isKotlinProject() = + listOf("kotlin", "kotlin-android", "kotlin-platform-jvm").any { plugins.hasPlugin(it) } + +fun Project.isAndroidProject() = listOf( + "com.android.library", + "com.android.application", + "com.android.test", + "com.android.feature", + "com.android.instantapp" +).any { plugins.hasPlugin(it) } + +fun Project.isJsProject() = plugins.hasPlugin("kotlin2js") + +fun Project.isCommonsProject() = plugins.hasPlugin("org.jetbrains.kotlin.platform.common") /** * An extension to create test Kotlin source set. diff --git a/buildSrc/src/main/kotlin/utils/StringUtils.kt b/buildSrc/src/main/kotlin/utils/StringUtils.kt index aae75e2..f06b801 100644 --- a/buildSrc/src/main/kotlin/utils/StringUtils.kt +++ b/buildSrc/src/main/kotlin/utils/StringUtils.kt @@ -15,8 +15,30 @@ */ package utils +import org.gradle.api.Project import java.io.File +private val whitespaceRegex = Regex("\\s") + +internal val String.dotIdentifier + get() = replace("-", "") + .replace(".", "") + .replace(whitespaceRegex, "") + +internal val Project.dotIdentifier get() = "$group$name".dotIdentifier + +internal fun String.nonEmptyPrepend(prepend: String) = + if (isNotEmpty()) prepend + this else this + +internal fun String.toHyphenCase(): String { + if (isBlank()) return this + + return this[0].toLowerCase().toString() + toCharArray() + .map { it.toString() } + .drop(1) + .joinToString(separator = "") { if (it[0].isUpperCase()) "-${it[0].toLowerCase()}" else it } +} + /** * Executes the given command in specified working dir * From 9c5c45c239674539ed0af55199d6e5036ff171f8 Mon Sep 17 00:00:00 2001 From: "ADMSK\\AVROGAL1" Date: Tue, 6 Apr 2021 03:28:01 +0300 Subject: [PATCH 16/41] docs: updates on documentation Added informational and corporate documentation --- .bettercodehub.yml | 5 ++ .deepsource.toml | 8 +++ .github/scripts/close-pending.sh | 27 +++++++++ .github/scripts/comment-commands/close.sh | 21 +++++++ .github/scripts/comment-commands/debug.sh | 7 +++ .github/scripts/comment-commands/help.sh | 13 +++++ .github/scripts/comment-commands/label.sh | 11 ++++ .github/scripts/comment-commands/pending.sh | 22 ++++++++ .github/scripts/comment-commands/ready.sh | 20 +++++++ .github/scripts/comment-commands/retest.sh | 61 +++++++++++++++++++++ .github/scripts/process-comment.sh | 41 ++++++++++++++ .github/workflows/close-pending.yml | 21 +++++++ README.md | 7 +++ 13 files changed, 264 insertions(+) create mode 100644 .bettercodehub.yml create mode 100644 .deepsource.toml create mode 100644 .github/scripts/close-pending.sh create mode 100644 .github/scripts/comment-commands/close.sh create mode 100644 .github/scripts/comment-commands/debug.sh create mode 100644 .github/scripts/comment-commands/help.sh create mode 100644 .github/scripts/comment-commands/label.sh create mode 100644 .github/scripts/comment-commands/pending.sh create mode 100644 .github/scripts/comment-commands/ready.sh create mode 100644 .github/scripts/comment-commands/retest.sh create mode 100644 .github/scripts/process-comment.sh create mode 100644 .github/workflows/close-pending.yml diff --git a/.bettercodehub.yml b/.bettercodehub.yml new file mode 100644 index 0000000..46be470 --- /dev/null +++ b/.bettercodehub.yml @@ -0,0 +1,5 @@ +component_depth: 6 +default_excludes: true +languages: + - java + - kotlin diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..f2b9af9 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,8 @@ +version = 1 + +[[analyzers]] +name = "java" +enabled = true + + [analyzers.meta] + runtime_version = "11" diff --git a/.github/scripts/close-pending.sh b/.github/scripts/close-pending.sh new file mode 100644 index 0000000..b7ed417 --- /dev/null +++ b/.github/scripts/close-pending.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +MESSAGE=$(cat $SCRIPT_DIR/closing-message.txt) + +while IFS= read -r number && + IFS= read -r title; do + echo "Closing PR ($number): $title" + curl -s -o /dev/null \ + -X POST \ + --data "$(jq --arg body "$MESSAGE" -n '{body: $body}')" \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "https://api.github.com/repos/AlexRogalskiy/object-mappers-playground/issues/$number/comments" + + curl -s -o /dev/null \ + -X PATCH \ + --data '{"state": "close"}' \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "https://api.github.com/repos/AlexRogalskiy/object-mappers-playground/pulls/$number" +done < <(curl -H "Content-Type: application/json" \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + "https://api.github.com/search/issues?q=repo:AlexRogalskiy/object-mappers-playground+type:pr+updated:<$(date -d "-21 days" +%Y-%m-%d)+label:pending+is:open" | + jq -r '.items[] | (.number,.title)') diff --git a/.github/scripts/comment-commands/close.sh b/.github/scripts/comment-commands/close.sh new file mode 100644 index 0000000..6c04626 --- /dev/null +++ b/.github/scripts/comment-commands/close.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +#doc: Close pending pull request temporary +# shellcheck disable=SC2124 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +MESSAGE=$(cat $SCRIPT_DIR/../closing-message.txt) + +set +x #GITHUB_TOKEN +curl -s -o /dev/null \ + -X POST \ + --data "$(jq --arg body "$MESSAGE" -n '{body: $body}')" \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "$(jq -r '.issue.comments_url' "$GITHUB_EVENT_PATH")" + +curl -s -o /dev/null \ + -X PATCH \ + --data '{"state": "close"}' \ + --header "authorization: Bearer $GITHUB_TOKEN" \ + --header 'content-type: application/json' \ + "$(jq -r '.issue.pull_request.url' "$GITHUB_EVENT_PATH")" diff --git a/.github/scripts/comment-commands/debug.sh b/.github/scripts/comment-commands/debug.sh new file mode 100644 index 0000000..fbc68ce --- /dev/null +++ b/.github/scripts/comment-commands/debug.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +#doc: Show current event json to debug problems + +echo "\`\`\`" +cat "$GITHUB_EVENT_PATH" +echo "\`\`\`" diff --git a/.github/scripts/comment-commands/help.sh b/.github/scripts/comment-commands/help.sh new file mode 100644 index 0000000..babec9b --- /dev/null +++ b/.github/scripts/comment-commands/help.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +#doc: Show all the available comment commands +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +echo "Available commands:" +DOCTAG="#" +DOCTAG="${DOCTAG}doc" +for command in "$DIR"/*.sh; do + COMMAND_NAME="$(basename "$command" | sed 's/\.sh$//')" + if [ "$COMMAND_NAME" != "debug" ]; then + printf " * /**%s** %s\n" "$COMMAND_NAME" "$(grep $DOCTAG "$command" | sed "s/$DOCTAG//g")" + fi +done diff --git a/.github/scripts/comment-commands/label.sh b/.github/scripts/comment-commands/label.sh new file mode 100644 index 0000000..d7612b4 --- /dev/null +++ b/.github/scripts/comment-commands/label.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +#doc: add new label to the issue: `/label