From 66404c6db511c23cbc7d8de9d366b2f210d20a5c Mon Sep 17 00:00:00 2001 From: Laimonas Turauskas Date: Thu, 4 Jan 2024 13:00:36 -0500 Subject: [PATCH] Publish all artifacts locally. (#327) * Publish all artifacts locally. * Fix issues with artifact publishing. * Only run the build once. * Fix doc publishing. --- .github/workflows/build-workflow.yml | 20 ++++++++++++--- build.gradle.kts | 12 +++++++++ formula-android-compose/build.gradle.kts | 28 +++------------------ formula-android/build.gradle.kts | 32 +++++------------------- formula-lint/build.gradle.kts | 9 ------- gradle/libs.versions.toml | 2 +- 6 files changed, 39 insertions(+), 64 deletions(-) diff --git a/.github/workflows/build-workflow.yml b/.github/workflows/build-workflow.yml index 4f24a6d0..112574ae 100644 --- a/.github/workflows/build-workflow.yml +++ b/.github/workflows/build-workflow.yml @@ -1,5 +1,11 @@ name: Build -on: [pull_request, push] +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: test: runs-on: ubuntu-latest @@ -27,7 +33,7 @@ jobs: - name: Run Formula Android Instrumentation Tests run: ./gradlew :formula-android-tests:testRelease - name: Run Formula Lint Tests - run: ./gradlew :formula-lint:test + run: ./gradlew :formula-lint:build - name: Generate Jacoco Report run: ./gradlew jacocoTestReportMerged - name: Save Jacoco Report @@ -67,4 +73,12 @@ jobs: - name: Assemble Stopwatch Compose Sample run: ./gradlew :samples:stopwatch-compose:assembleDebug - name: Assemble Stopwatch Kotlin Coroutine Sample - run: ./gradlew :samples:stopwatch-coroutines:assembleDebug \ No newline at end of file + run: ./gradlew :samples:stopwatch-coroutines:assembleDebug + - name: Publish all artifacts locally + run: | + ./gradlew :formula:build + ./gradlew :formula-android:build + ./gradlew :formula-test:build + ./gradlew :formula-android-compose:build + ./gradlew :formula-lint:build + ./gradlew publishToMavenLocal --no-parallel --no-daemon \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 77398c20..47a5f50a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -115,4 +115,16 @@ tasks.register("install") { dependsOn(publishTasks) } +// We disable jacoco report when running buildTask +val isBuild = gradle.startParameter.taskNames.any { it.contains("build") } +if (isBuild) { + subprojects { + plugins.withType { + tasks.withType { + enabled = false + } + } + } +} + apply(from = "gradle/merge-reports.gradle") diff --git a/formula-android-compose/build.gradle.kts b/formula-android-compose/build.gradle.kts index dfccbd08..f0877f39 100644 --- a/formula-android-compose/build.gradle.kts +++ b/formula-android-compose/build.gradle.kts @@ -18,32 +18,10 @@ android { composeOptions { kotlinCompilerExtensionVersion = libs.versions.compose.get() } -} - -task("sourcesJar") { - from(android.sourceSets["main"].java.srcDirs) - archiveClassifier.set("sources") -} - -task("javadoc") { - isFailOnError = false - source(android.sourceSets["main"].java.getSourceFiles()) - classpath = project.files( - android.bootClasspath.joinToString(separator = File.pathSeparator), - configurations.api, - configurations.implementation - ) -} - -task("javadocJar") { - dependsOn("javadoc") - archiveClassifier.set("javadoc") - from(tasks["javadoc"].path) -} -artifacts { - archives(tasks["sourcesJar"]) - archives(tasks["javadocJar"]) + publishing { + singleVariant("release") + } } dependencies { diff --git a/formula-android/build.gradle.kts b/formula-android/build.gradle.kts index f93d228e..96c89066 100644 --- a/formula-android/build.gradle.kts +++ b/formula-android/build.gradle.kts @@ -1,7 +1,8 @@ +import org.jetbrains.dokka.gradle.DokkaTask + plugins { id("com.android.library") id("kotlin-android") - id("kotlin-kapt") id("kotlin-parcelize") } @@ -16,32 +17,10 @@ android { testOptions { unitTests.isReturnDefaultValues = true } -} - -task("sourcesJar") { - from(android.sourceSets["main"].java.srcDirs) - archiveClassifier.set("sources") -} - -task("javadoc") { - isFailOnError = false - source(android.sourceSets["main"].java.getSourceFiles()) - classpath = project.files( - android.bootClasspath.joinToString(separator = File.pathSeparator), - configurations.api, - configurations.implementation - ) -} - -task("javadocJar") { - dependsOn("javadoc") - archiveClassifier.set("javadoc") - from(tasks["javadoc"].path) -} -artifacts { - archives(tasks["sourcesJar"]) - archives(tasks["javadocJar"]) + publishing { + singleVariant("release") + } } dependencies { @@ -60,3 +39,4 @@ dependencies { testImplementation(libs.mockito.kotlin) testImplementation(libs.kotlin.reflect) } + diff --git a/formula-lint/build.gradle.kts b/formula-lint/build.gradle.kts index 14622a42..3ce39833 100644 --- a/formula-lint/build.gradle.kts +++ b/formula-lint/build.gradle.kts @@ -22,12 +22,3 @@ dependencies { testImplementation(libs.lint.tests) testImplementation(libs.junit) } - -// Need to register direct task dependencies since jacocoTestReport is -// accessing the files produced by those lint tasks -plugins.withId("jacoco") { - tasks.named("jacocoTestReport") { - dependsOn(tasks.withType()) - dependsOn(tasks.withType()) - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 73ea4971..72ec223e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] android-gradle = "8.2.0" -dokka-gradle = "1.4.32" +dokka-gradle = "1.9.10" kotlin = "1.9.10" coroutines = "1.5.2"