Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/unknown Android classes #76

Merged
merged 27 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
58230ca
start setting up Android integration test project
aSemy May 21, 2023
f7c96a8
refactor DokkatooExampleProjects convention plugin so that the `gradl…
aSemy May 21, 2023
8ad738d
enable AndroidX in Android IT project
aSemy May 21, 2023
e2301e7
simplify UpdateDokkatooExampleGradleProperties
aSemy May 21, 2023
dd459f0
move DokkatooExampleProjects task group
aSemy May 21, 2023
264613a
tidy up buildsrc code
aSemy May 21, 2023
5a2c4a3
fix android-it project
aSemy May 21, 2023
01121c7
mostly fix missing Android classes?
aSemy May 21, 2023
3b5fe6a
tidy up IJ dir exclusions
aSemy May 21, 2023
9ff6679
incremental improvement to fix Android implementation...
aSemy May 22, 2023
74554b6
update logo src
aSemy May 22, 2023
8aa6dab
tidy DokkatooKotlinAdapter
aSemy May 22, 2023
d30db41
update api dump
aSemy May 22, 2023
0b18c52
add deprecation for setSourceSetname()
aSemy May 22, 2023
0600a2f
modify deprecation of sourceSetName setter
aSemy May 22, 2023
487f39b
remove unused providers from KotlinSourceSetDetails
aSemy May 22, 2023
ae5a8f0
tidy up code
aSemy May 22, 2023
8de3690
tidy up buildSrc example project utils
aSemy May 22, 2023
96e8c53
add Android SDK setup step
aSemy May 22, 2023
607c8c1
refactor DokkatooAndroidAdapter to prevent Caused by: org.gradle.inte…
aSemy May 22, 2023
c378cbf
update DokkaSourceSetBuilderTest. listOf() -> setOf()
aSemy May 22, 2023
8895084
try refining the ANDROID_SDK value setter, to help on CI/CD
aSemy May 22, 2023
528ae97
remove commented out mavenLocal() in it-project
aSemy May 22, 2023
809a07a
refactor template projects setup and Android local.properties utils
aSemy May 28, 2023
b382122
Merge remote-tracking branch 'origin/main' into fix/unknown_android_c…
aSemy May 28, 2023
5fe9e0c
tidy `examples/build.gradle.kts`
aSemy May 29, 2023
cf3a0b8
tidy integration-tests build.gradle.kts
aSemy May 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/gradle_task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
distribution: temurin
java-version: 11

- name: Setup Android SDK # required for integration tests
uses: android-actions/setup-android@v2

- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ idea {
".gradle",
"build",
"gradle/wrapper",
"ANDROID_SDK",
)
addAll(
projectDir.walk().filter { file ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package buildsrc.conventions

import buildsrc.tasks.SetupDokkaProjects
import java.io.File
import java.time.Duration
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.*
import buildsrc.utils.skipTestFixturesPublications
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.util.suffixIfNot


/**
* Utilities for preparing Android projects
*/

plugins {
base
id("buildsrc.conventions.base")
}


val androidSdkDir: Provider<File> = providers
// first try getting the SDK installed on via GitHub step setup-android
.environmentVariable("ANDROID_SDK_ROOT").map(::File)
// else get the project-local SDK
.orElse(layout.projectDirectory.file("projects/ANDROID_SDK").asFile)



val createAndroidLocalPropertiesFile by tasks.registering {

val localPropertiesFile = temporaryDir.resolve("local.properties")
outputs.file(localPropertiesFile).withPropertyName("localPropertiesFile")

val androidSdkDir = androidSdkDir
// add the relative path as a property for Gradle up-to-date checks (the directory contents don't matter)
inputs.property(
"androidSdkDirPath",
androidSdkDir.map { it.relativeTo(projectDir).invariantSeparatorsPath }
)

doLast {
val androidSdkPath = androidSdkDir.get().invariantSeparatorsPath

localPropertiesFile.apply {
parentFile.mkdirs()
createNewFile()
writeText(
"""
|# DO NOT EDIT - Generated by $path
|
|sdk.dir=$androidSdkPath
|
""".trimMargin()
)
}
}
}


val updateAndroidLocalProperties by tasks.registering {

// find all local.properties files
val localPropertiesFiles = layout.projectDirectory.dir("projects").asFileTree
.matching {
include("**/local.properties")
}.files

outputs.files(localPropertiesFiles).withPropertyName("localPropertiesFiles")

val androidSdkDir = androidSdkDir

// add the relative path as a property for Gradle up-to-date checks (the directory contents don't matter)
inputs.property(
"androidSdkDirPath",
androidSdkDir.map { it.relativeTo(projectDir).invariantSeparatorsPath }
)

doLast {
val androidSdkDirPath = androidSdkDir.get().invariantSeparatorsPath

localPropertiesFiles.forEach { file ->
if (file.exists()) {
file.writeText(
file.useLines { lines ->
lines.joinToString("\n") { line ->
when {
line.startsWith("sdk.dir=") -> "sdk.dir=$androidSdkDirPath"
else -> line
}
}.suffixIfNot("\n")
}
)
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kotlinx-serialization = "1.5.0"

kotest = "5.6.0"

gradlePlugin-android = "4.0.1"
gradlePlugin-android = "4.2.2"
gradlePlugin-dokkatoo = "1.1.1"
gradlePlugin-gradlePublishPlugin = "1.1.0"
gradlePlugin-bcvMu = "0.0.4"
Expand Down
57 changes: 37 additions & 20 deletions modules/dokkatoo-plugin-integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@file:Suppress("UnstableApiUsage") // jvm test suites & test report aggregation are incubating

import buildsrc.tasks.SetupDokkaProjects
import buildsrc.utils.skipTestFixturesPublications
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -15,6 +16,7 @@ plugins {
buildsrc.conventions.`java-base`
buildsrc.conventions.`maven-publish-test`
buildsrc.conventions.`dokkatoo-example-projects`
buildsrc.conventions.`android-setup`
}

description = """
Expand All @@ -38,7 +40,6 @@ dependencies {
// don't define test dependencies here, instead define them in the testing.suites {} configuration below
}


tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += listOf(
Expand All @@ -48,6 +49,7 @@ tasks.withType<KotlinCompile>().configureEach {
}
}

//region Test suites and task configuration
testing.suites {

withType<JvmTestSuite>().configureEach {
Expand Down Expand Up @@ -91,13 +93,11 @@ testing.suites {
}
}


/** Examples tests suite */
val testExamples by registering(JvmTestSuite::class) {
description = "Test the example projects, from the 'examples' directory in the project root"
}


/** Integration tests suite */
val testIntegration by registering(JvmTestSuite::class) {
description =
Expand All @@ -109,6 +109,12 @@ testing.suites {


tasks.withType<Test>().configureEach {
// this seems to help OOM errors in the Worker Daemons
//setForkEvery(1)
jvmArgs(
"-Xmx1g",
"-XX:MaxMetaspaceSize=512m",
)

mustRunAfter(tasks.withType<AbstractPublishToMaven>())

Expand All @@ -127,14 +133,29 @@ tasks.withType<Test>().configureEach {
showStackTraces = true
}
}
//endregion

skipTestFixturesPublications()
//region Example & Template projects setup
dokkatooExampleProjects {
exampleProjects {
projectsItAndroid0Dokkatoo {
gradlePropertiesContent.add("android.useAndroidX=true")
}
}
}

dokkaTemplateProjects {

val androidLocalPropertiesFile = tasks.createAndroidLocalPropertiesFile.map {
it.outputs.files
}

register(
source = "integration-tests/gradle/projects/it-android-0",
destination = "projects/it-android-0/dokka",
)
) {
additionalFiles.from(androidLocalPropertiesFile)
}
register(
source = "integration-tests/gradle/projects/it-basic",
destination = "projects/it-basic/dokka",
Expand Down Expand Up @@ -172,7 +193,6 @@ dokkaTemplateProjects {
// register("projects/serialization/dokka") { }
// register("projects/stdlib/dokka") { }


configureEach {
additionalPaths.addAll(
"integration-tests/gradle/projects/template.root.gradle.kts",
Expand All @@ -188,11 +208,8 @@ tasks.setupDokkaTemplateProjects.configure {

doLast {
outputs.files.asFileTree.files.forEach { file ->
println("copied file $file")

when (file.name) {
"build.gradle.kts" -> {
println("re-writing $file")
file.writeText(
file.readText()
.replace(
Expand All @@ -206,7 +223,6 @@ tasks.setupDokkaTemplateProjects.configure {
}

"settings.gradle.kts" -> {
println("re-writing $file")
file.writeText(
file.readText()
.replace(
Expand All @@ -217,7 +233,6 @@ tasks.setupDokkaTemplateProjects.configure {
}

"template.settings.gradle.kts" -> {
println("re-writing $file")
file.writeText(
file.readText()
.replace(
Expand All @@ -231,15 +246,17 @@ tasks.setupDokkaTemplateProjects.configure {
}
}

tasks.withType<Test>().configureEach {
// this seems to help OOM errors in the Worker Daemons
//setForkEvery(1)
jvmArgs(
"-Xmx1g",
"-XX:MaxMetaspaceSize=512m",
)
}

dokkaSourceDownload {
dokkaVersion.set(libs.versions.kotlin.dokka)
}

tasks.updateAndroidLocalProperties {
mustRunAfter(tasks.withType<SetupDokkaProjects>())
}

tasks.updateDokkatooExamples {
dependsOn(tasks.updateAndroidLocalProperties)
}
//endregion

skipTestFixturesPublications()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

601085b94cd77f0b54ff86406957099ebe79c4d6
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

859f317696f67ef3d7f30a50a5560e7834b43903
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

24333f8a63b6825ea9c5514f83c2829b004d1fee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

84831b9409646a918e30573bab4c9c91346d8abd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

33b6a2b64607f11b759f320ef9dff4ae5c47d97a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

d975f751698a77b662f1254ddbeed3901e976f5a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

e9acab5b5fbb560a72cfaecce8946896ff6aab9d
Loading