From a79ec6bc334dd38b2f38283a1d5da5dbd08f60d2 Mon Sep 17 00:00:00 2001 From: "aman.kapoor" Date: Tue, 8 Feb 2022 15:11:31 +0530 Subject: [PATCH 1/4] Support for publishing modules, api module published --- .github/workflows/buildPreProd.yml | 2 +- .github/workflows/publish_api.yml | 63 +++++++++++++++++ api/Changelog.md | 0 api/build.gradle.kts | 18 ++++- app/build.gradle.kts | 7 +- build.gradle.kts | 4 ++ buildSrc/build.gradle.kts | 7 ++ .../com/voxfinite/logvue/Configuration.kt | 15 ++++ .../com/voxfinite/logvue/Dependencies.kt | 11 +++ gradle.properties | 3 - plugins/pdt/build.gradle.kts | 9 ++- scripts/publish-module.gradle | 68 +++++++++++++++++++ scripts/publish-root.gradle | 39 +++++++++++ 13 files changed, 230 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/publish_api.yml create mode 100644 api/Changelog.md create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt create mode 100644 buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt create mode 100644 scripts/publish-module.gradle create mode 100644 scripts/publish-root.gradle diff --git a/.github/workflows/buildPreProd.yml b/.github/workflows/buildPreProd.yml index 65415e7..c38adb4 100644 --- a/.github/workflows/buildPreProd.yml +++ b/.github/workflows/buildPreProd.yml @@ -1,4 +1,4 @@ -name: Logvue Build +name: Logvue Build Pre-Prod env: GITHUB_DEPLOY: 'false' diff --git a/.github/workflows/publish_api.yml b/.github/workflows/publish_api.yml new file mode 100644 index 0000000..c6747f4 --- /dev/null +++ b/.github/workflows/publish_api.yml @@ -0,0 +1,63 @@ +name: Logvue Publish + +env: + GITHUB_DEPLOY: 'false' + +on: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + build: + name: Release build and publish + continue-on-error: false + + runs-on: ubuntu-latest + environment: Production + strategy: + fail-fast: true + matrix: + jdk: [ 18 ] + + steps: + - name: Check out the source code + uses: actions/checkout@v2 + + - name: Download OpenJDK ${{ matrix.jdk }} + id: download-jdk + uses: sormuras/download-jdk@v1 + with: + feature: ${{ matrix.jdk }} + + - name: Set up OpenJDK ${{ matrix.jdk }} + id: setup-java + uses: actions/setup-java@v2 + if: always() && steps.download-jdk.outcome == 'success' + with: + distribution: jdkfile + java-version: ${{ env.JDK_VERSION }} + jdkFile: ${{ env.JDK_FILE }} + + - name: Cache Gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + # Runs upload, and then closes & releases the repository + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} \ No newline at end of file diff --git a/api/Changelog.md b/api/Changelog.md new file mode 100644 index 0000000..e69de29 diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 64c5e97..30ba2c4 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -1,10 +1,22 @@ -val pf4jVersion: String by project - +import com.voxfinite.logvue.Configuration +import com.voxfinite.logvue.Dependencies plugins { kotlin("jvm") } +ext { + set("PUBLISH_GROUP_ID", Configuration.Api.artifactGroup) + if (Configuration.Api.isSnapshot || rootProject.ext["snapshot"] as Boolean) { + set("PUBLISH_VERSION", Configuration.Api.snapshotVersionName) + } else { + set("PUBLISH_VERSION", Configuration.Api.versionName) + } + set("PUBLISH_ARTIFACT_ID", Configuration.Api.artifactId) +} + +apply(from = "${rootDir}/scripts/publish-module.gradle") + dependencies { implementation(kotlin("stdlib")) // https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl @@ -12,7 +24,7 @@ dependencies { implementation("org.apache.logging.log4j:log4j-api:2.17.0") implementation("org.apache.logging.log4j:log4j-core:2.17.0") - compileOnly("org.pf4j:pf4j:${pf4jVersion}") + compileOnly(Dependencies.Pf4j) // types parser for object to map conversion implementation("com.github.drapostolos:type-parser:0.7.0") implementation("com.google.code.gson:gson:2.8.9") diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c8ff756..d0fcf8b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,8 +1,7 @@ import org.jetbrains.compose.compose import org.jetbrains.compose.desktop.application.dsl.TargetFormat -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import com.voxfinite.logvue.Dependencies -val pf4jVersion: String by project val pluginsDir: File by rootProject.extra plugins { @@ -21,7 +20,7 @@ val appMainClass = "com.voxfinite.logvue.app.MainKt" dependencies { implementation(kotlin("stdlib")) testImplementation(kotlin("test")) - implementation(project(":api")) + implementation(Dependencies.LogVueApi) implementation(compose.desktop.currentOs) // https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0") @@ -40,7 +39,7 @@ dependencies { implementation("io.sentry:sentry-log4j2:5.6.0") // https://mvnrepository.com/artifact/net.harawata/appdirs implementation("net.harawata:appdirs:1.2.1") - implementation ("org.pf4j:pf4j:${pf4jVersion}") + implementation (Dependencies.Pf4j) r8("com.android.tools:r8:3.0.73") } diff --git a/build.gradle.kts b/build.gradle.kts index ff256a6..ef941a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,8 @@ buildscript { plugins { kotlin("jvm") version "1.6.10" + id("org.jetbrains.dokka") version "1.6.10" + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" } allprojects { @@ -34,3 +36,5 @@ subprojects { kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } } + +apply(from = "${rootDir}/scripts/publish-root.gradle") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..b22ed73 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt new file mode 100644 index 0000000..979787e --- /dev/null +++ b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt @@ -0,0 +1,15 @@ +package com.voxfinite.logvue + +object Configuration { + + object Api { + const val majorVersion = 1 + const val minorVersion = 0 + const val patchVersion = 0 + const val versionName = "$majorVersion.$minorVersion.$patchVersion" + const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT" + const val isSnapshot = false + const val artifactGroup = "io.github.amank22.logvue" + const val artifactId = "api" + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt new file mode 100644 index 0000000..241119c --- /dev/null +++ b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt @@ -0,0 +1,11 @@ +package com.voxfinite.logvue + +object Versions { + const val LogVueApi = "1.0.0" + const val P4fj = "3.6.0" +} + +object Dependencies { + const val LogVueApi = "io.github.amank22.logvue:api:${Versions.LogVueApi}" + const val Pf4j = "org.pf4j:pf4j:${Versions.P4fj}" +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3183a8e..9930c09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,2 @@ kotlin.code.style=official #kotlin.native.binary.memoryModel=experimental - -# PF4J -pf4jVersion=3.6.0 diff --git a/plugins/pdt/build.gradle.kts b/plugins/pdt/build.gradle.kts index 0a5fa82..72a61c2 100644 --- a/plugins/pdt/build.gradle.kts +++ b/plugins/pdt/build.gradle.kts @@ -1,14 +1,13 @@ +import com.voxfinite.logvue.Dependencies plugins { kotlin("kapt") } -val pf4jVersion: String by project - dependencies { - compileOnly(project(":api")) + compileOnly(Dependencies.LogVueApi) compileOnly(kotlin("stdlib")) - compileOnly("org.pf4j:pf4j:${pf4jVersion}") - kapt("org.pf4j:pf4j:${pf4jVersion}") + compileOnly(Dependencies.Pf4j) + kapt(Dependencies.Pf4j) // implementation("org.apache.commons:commons-lang3:3.5") // this is an example for an external library included } diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle new file mode 100644 index 0000000..2ef7475 --- /dev/null +++ b/scripts/publish-module.gradle @@ -0,0 +1,68 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' +apply plugin: 'org.jetbrains.dokka' + +java { + withSourcesJar() +} + +tasks.withType(dokkaHtmlPartial.getClass()).configureEach { + pluginsMapConfiguration.set( + ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""] + ) +} + +task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { + archiveClassifier.set('javadoc') + from dokkaJavadoc.outputDirectory +} + +group = PUBLISH_GROUP_ID +version = PUBLISH_VERSION + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + from components.java + artifact javadocJar + + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Monitor, analyse local analytics from ADB and use SQL-Like query to filter logs on desktop' + url = 'https://github.com/amank22/LogVue' + licenses { + license { + name = 'GPL-3.0 License' + url = 'https://github.com/amank22/LogVue/blob/main/LICENSE' + } + } + developers { + developer { + id = 'amank22' + name = 'Aman Kapoor' + email = 'kapoor.aman22@gmail.com' + } + } + scm { + connection = 'scm:git:github.com/amank22/logvue.git' + developerConnection = 'scm:git:ssh://github.com/amank22/logvue.git' + url = 'https://github.com/amank22/LogVue/tree/main' + } + } + } + } + } +} + +signing { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"], + ) + sign publishing.publications +} \ No newline at end of file diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle new file mode 100644 index 0000000..d29822d --- /dev/null +++ b/scripts/publish-root.gradle @@ -0,0 +1,39 @@ +// Create variables with empty default values +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.key"] = '' +ext["snapshot"] = false + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + // Read local.properties file first if it exists + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } + p.each { name, value -> ext[name] = value } +} else { + // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') + ext["signing.password"] = System.getenv('SIGNING_PASSWORD') + ext["signing.key"] = System.getenv('SIGNING_KEY') + ext["snapshot"] = System.getenv('SNAPSHOT') +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword +// version = rootVersionName + } + } +} \ No newline at end of file From 7da26c4b23a457f48961cf1293b2ae2effc0d258 Mon Sep 17 00:00:00 2001 From: "aman.kapoor" Date: Tue, 8 Feb 2022 15:48:38 +0530 Subject: [PATCH 2/4] Gradle Extensions for uncluttering build files --- app/build.gradle.kts | 42 ++----------------- .../logvue/utils/GradleExtensions.kt | 41 ++++++++++++++++++ 2 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d0fcf8b..cd20c33 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,9 @@ import org.jetbrains.compose.compose import org.jetbrains.compose.desktop.application.dsl.TargetFormat import com.voxfinite.logvue.Dependencies +import com.voxfinite.logvue.utils.findPkg +import com.voxfinite.logvue.utils.ghActionOutput +import com.voxfinite.logvue.utils.getMainAppVersion val pluginsDir: File by rootProject.extra @@ -13,7 +16,7 @@ plugins { val r8: Configuration by configurations.creating group = "com.voxfinite" -version = appVersion() +version = project.getMainAppVersion() val appName = "logvue" val appMainClass = "com.voxfinite.logvue.app.MainKt" @@ -154,40 +157,3 @@ gradle.buildFinished { nativePkg.ghActionOutput("app_pkg") jarPkg.ghActionOutput("uber_jar") } - -fun File.findPkg(format: String?) = when (format != null) { - true -> walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true) } - else -> null -} - -fun File?.ghActionOutput(prefix: String) = this?.let { - when (System.getenv("GITHUB_ACTIONS").toBoolean()) { - true -> println( - """ - ::set-output name=${prefix}_name::${it.name} - ::set-output name=${prefix}_path::${it.absolutePath} - """.trimIndent() - ) - else -> println("$prefix: $this") - } -} - -fun appVersion() : String { - val key = "APP_VERSION" - return if (project.hasProperty(key)) { - val version = project.property("APP_VERSION").toString() - println("Version = $version") - if (version.isBlank()) { - return "1.0.0" - } - if (version.matches(Regex("^[\\d]{1,3}.[\\d]{1,3}.[\\d]{1,4}"))) { - return version - } - if (version.matches(Regex("^v[\\d]{1,3}.[\\d]{1,3}.[\\d]{1,4}"))) { - return version.removePrefix("v") - } - "1.0.0" - } else { - "1.0.0" - } -} diff --git a/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt b/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt new file mode 100644 index 0000000..b621371 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt @@ -0,0 +1,41 @@ +package com.voxfinite.logvue.utils + +import org.gradle.api.Project +import java.io.File + +fun Project.getMainAppVersion() : String { + val key = "APP_VERSION" + return if (hasProperty(key)) { + val version = property("APP_VERSION").toString() + println("Version = $version") + if (version.isBlank()) { + return "1.0.0" + } + if (version.matches(Regex("^[\\d]{1,3}.[\\d]{1,3}.[\\d]{1,4}"))) { + return version + } + if (version.matches(Regex("^v[\\d]{1,3}.[\\d]{1,3}.[\\d]{1,4}"))) { + return version.removePrefix("v") + } + "1.0.0" + } else { + "1.0.0" + } +} + +fun File.findPkg(format: String?) = when (format != null) { + true -> walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true) } + else -> null +} + +fun File?.ghActionOutput(prefix: String) = this?.let { + when (System.getenv("GITHUB_ACTIONS").toBoolean()) { + true -> println( + """ + ::set-output name=${prefix}_name::${it.name} + ::set-output name=${prefix}_path::${it.absolutePath} + """.trimIndent() + ) + else -> println("$prefix: $this") + } +} \ No newline at end of file From c07cbfc127397605b9de6246d430a639530e7d94 Mon Sep 17 00:00:00 2001 From: "aman.kapoor" Date: Tue, 8 Feb 2022 18:29:47 +0530 Subject: [PATCH 3/4] Plugin support readme --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd1fd3d..2a2fb6d 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ - Plain Yaml - Copy single analytics data in details section +## Plugins + +You can extend LogVue with you own analytics platform. +See [LogVue Templates](https://github.com/amank22/Logvue-Plugin-Template) for creating +your own analytics parser for LogVue. + ## Contribute Do you see any improvements or want to implement a missing feature? Contributions are very welcome! @@ -83,8 +89,6 @@ before you start making any changes. ## Future goals -- [ ] Plugin system to support more logs and allows for in-house - customisations [#27](https://github.com/amank22/LogVue/issues/27) - [ ] Import event logs directly [#28](https://github.com/amank22/LogVue/issues/28) - [ ] A framework to validate logs directly with some set of rules directly in GUI - [ ] Create [feature request](https://github.com/amank22/LogVue/issues/new) and we can discuss From 8fd337c57b4cc9fc619044e867a62225c5c2f519 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 8 Feb 2022 13:02:20 +0000 Subject: [PATCH 4/4] Restyled by whitespace --- buildSrc/build.gradle.kts | 2 +- buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt | 2 +- buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt | 2 +- .../main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt | 2 +- scripts/publish-module.gradle | 2 +- scripts/publish-root.gradle | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index b22ed73..876c922 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -4,4 +4,4 @@ plugins { repositories { mavenCentral() -} \ No newline at end of file +} diff --git a/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt index 979787e..b62eaba 100644 --- a/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt +++ b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Configuration.kt @@ -12,4 +12,4 @@ object Configuration { const val artifactGroup = "io.github.amank22.logvue" const val artifactId = "api" } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt index 241119c..aa11d48 100644 --- a/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt +++ b/buildSrc/src/main/kotlin/com/voxfinite/logvue/Dependencies.kt @@ -8,4 +8,4 @@ object Versions { object Dependencies { const val LogVueApi = "io.github.amank22.logvue:api:${Versions.LogVueApi}" const val Pf4j = "org.pf4j:pf4j:${Versions.P4fj}" -} \ No newline at end of file +} diff --git a/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt b/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt index b621371..67e2c19 100644 --- a/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt +++ b/buildSrc/src/main/kotlin/com/voxfinite/logvue/utils/GradleExtensions.kt @@ -38,4 +38,4 @@ fun File?.ghActionOutput(prefix: String) = this?.let { ) else -> println("$prefix: $this") } -} \ No newline at end of file +} diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 2ef7475..c9a6d55 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -65,4 +65,4 @@ signing { rootProject.ext["signing.password"], ) sign publishing.publications -} \ No newline at end of file +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index d29822d..aa3c6c9 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -36,4 +36,4 @@ nexusPublishing { // version = rootVersionName } } -} \ No newline at end of file +}