0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00
Anki-Android/AnkiDroid/robolectricDownloader.gradle

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
4.1 KiB
Groovy
Raw Normal View History

/**
* Downloads all android-all-instrumented dependencies and copies them to the mavenLocal() repository
*
* Once applied to your gradle project, can be executed with ./gradlew robolectricSdkDownload
*/
import java.nio.file.Files
// The general idea of this was borrowed from https://gist.github.com/xian/05c4f27da6d4156b9827842217c2cd5c
// I then modified it heavily to allow easier addition of new SDK versions
// The full implementation is from https://gist.github.com/simtel12/13ff3e57c37e78e468502b51ebb0f4f2
// List from: https://github.com/robolectric/robolectric/blob/master/robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java
// This list will need to be updated for new Android SDK versions that come out.
// Only the versions currently used in AnkiDroid Robolectric tests are active, the rest are commented out
// To update these versions, open a terminal in the Anki-Android directory and perform the following steps:
// 1. Run `rm -r ~/.m2` to delete the .m2 directory in your home directory.
// 2. Run `./gradlew jacocoUnitTestReport` to run all unit tests.
// 3. Run `find ~/.m2 -type d -name '*-robolectric-*'`.
// 4. Update the lines below to match the output from `find`.
def robolectricAndroidSdkVersions = [
// [androidVersion: "6.0.1_r3", frameworkSdkBuildVersion: "r1"],
// [androidVersion: "7.0.0_r1", frameworkSdkBuildVersion: "r1"],
// [androidVersion: "7.1.0_r7", frameworkSdkBuildVersion: "r1"],
// [androidVersion: "8.0.0_r4", frameworkSdkBuildVersion: "r1"],
// [androidVersion: "8.1.0", frameworkSdkBuildVersion: "4611349"],
[androidVersion: "9", frameworkSdkBuildVersion: "4913185-2"],
[androidVersion: "10", frameworkSdkBuildVersion: "5803371"],
[androidVersion: "11", frameworkSdkBuildVersion: "6757853"],
// [androidVersion: "12", frameworkSdkBuildVersion: "7732740"],
Dependency updates 20231031 (#14626) * build(deps): bump org.robolectric:robolectric from 4.10.3 to 4.11 (#14617) * build(deps): bump org.robolectric:robolectric from 4.10.3 to 4.11 Bumps [org.robolectric:robolectric](https://github.com/robolectric/robolectric) from 4.10.3 to 4.11. - [Release notes](https://github.com/robolectric/robolectric/releases) - [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.10.3...robolectric-4.11) --- updated-dependencies: - dependency-name: org.robolectric:robolectric dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): remove robolectric SDK pin so it auto-tracks, alter SDK downloads this was only necessary before because there was an upstream bug in robolectric 4.10.3, now that 4.11.0 is out, we can use robolectric SDK 33 and in fact move forwrd to 34 this implies that our SDK pre-downloads should be altered as well, these are the ones downloaded now on clean runs * test: adjust to match robolectric 4.11 needs - one test disable: API longer responds correctly, but manual test was successful - one test adjustement to reflect typo fix in robolectric APIs --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Hardy <github@mikehardy.net> * build(deps): bump kotlin_version from 1.9.10 to 1.9.20 Bumps `kotlin_version` from 1.9.10 to 1.9.20. Updates `org.jetbrains.kotlin.jvm` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin.android` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin.plugin.parcelize` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin.plugin.serialization` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-reflect` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-test` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-test-junit` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin.jvm dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin.android dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin.plugin.parcelize dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin.plugin.serialization dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-reflect dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-test dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-test-junit5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-test-junit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-31 16:51:28 +01:00
// [androidVersion: "12.1", frameworkSdkBuildVersion: "8229987"],
[androidVersion: "13", frameworkSdkBuildVersion: "9030017"],
Dependency updates 20231031 (#14626) * build(deps): bump org.robolectric:robolectric from 4.10.3 to 4.11 (#14617) * build(deps): bump org.robolectric:robolectric from 4.10.3 to 4.11 Bumps [org.robolectric:robolectric](https://github.com/robolectric/robolectric) from 4.10.3 to 4.11. - [Release notes](https://github.com/robolectric/robolectric/releases) - [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.10.3...robolectric-4.11) --- updated-dependencies: - dependency-name: org.robolectric:robolectric dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): remove robolectric SDK pin so it auto-tracks, alter SDK downloads this was only necessary before because there was an upstream bug in robolectric 4.10.3, now that 4.11.0 is out, we can use robolectric SDK 33 and in fact move forwrd to 34 this implies that our SDK pre-downloads should be altered as well, these are the ones downloaded now on clean runs * test: adjust to match robolectric 4.11 needs - one test disable: API longer responds correctly, but manual test was successful - one test adjustement to reflect typo fix in robolectric APIs --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Hardy <github@mikehardy.net> * build(deps): bump kotlin_version from 1.9.10 to 1.9.20 Bumps `kotlin_version` from 1.9.10 to 1.9.20. Updates `org.jetbrains.kotlin.jvm` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin.android` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin.plugin.parcelize` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin.plugin.serialization` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-reflect` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-test` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) Updates `org.jetbrains.kotlin:kotlin-test-junit` from 1.9.10 to 1.9.20 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/commits) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin.jvm dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin.android dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin.plugin.parcelize dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin.plugin.serialization dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-reflect dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-test dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-test-junit5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-test-junit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-31 16:51:28 +01:00
[androidVersion: "14", frameworkSdkBuildVersion: "10818077"],
]
// Base, public task - will be displayed in ./gradlew robolectricDownloader:tasks
Dependency updates 20231130 (#14855) * build(deps): bump commons-io:commons-io from 2.15.0 to 2.15.1 Bumps commons-io:commons-io from 2.15.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump androidx.webkit:webkit from 1.8.0 to 1.9.0 Bumps androidx.webkit:webkit from 1.8.0 to 1.9.0. --- updated-dependencies: - dependency-name: androidx.webkit:webkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update Gradle Wrapper from 8.4 to 8.5. Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> * build(deps): remove JDK18, support JDK21 (LTS) * build(deps): adopt jacoco 0.8.11 - supports JDK21 * style(lint): use new build variant configuration style documentation: https://developer.android.com/build/build-variants - defer configuration of build types / flavors with create/named, used in example - flavorDimensions is now a property so you += custom dimensions to it * style(lint): gradle .all --> .configureEach * style(lint): use imports vs fully qualified names * docs(gradle): update comment describing CI vCPU determination * style(lint): use deferred-configuration-compatible task registration/dependency * style(lint): deprecated kotlinOptions -> current compilerOptions * style(lint): project.buildDir -> project.layout.buildDirectory required a slightly different way of building the file tree for kotlin class location as input to the report, but despite being a little subtle it is not at all hard to understand --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2023-11-30 22:01:31 +01:00
tasks.register('robolectricSdkDownload') {
group = "Dependencies"
description = "Downloads all robolectric SDK dependencies into mavenLocal, for use with offline robolectric"
}
// Generate the configuration and actual copy tasks.
robolectricAndroidSdkVersions.forEach { robolectricSdkVersion ->
def version = "${robolectricSdkVersion['androidVersion']}-robolectric-${robolectricSdkVersion['frameworkSdkBuildVersion']}-i4"
// Creating a configuration with a dependency allows Gradle to manage the actual resolution of
// the jar file
def sdkConfig = configurations.create(version)
dependencies.add(version, "org.robolectric:android-all-instrumented:${version}")
def mavenLocalFile = new File(this.repositories.mavenLocal().url)
def mavenRobolectric = new File(mavenLocalFile, "org/robolectric/android-all-instrumented/${version}")
// Copying all files downloaded for the created configuration into maven local.
Dependency updates 20231130 (#14855) * build(deps): bump commons-io:commons-io from 2.15.0 to 2.15.1 Bumps commons-io:commons-io from 2.15.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump androidx.webkit:webkit from 1.8.0 to 1.9.0 Bumps androidx.webkit:webkit from 1.8.0 to 1.9.0. --- updated-dependencies: - dependency-name: androidx.webkit:webkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update Gradle Wrapper from 8.4 to 8.5. Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> * build(deps): remove JDK18, support JDK21 (LTS) * build(deps): adopt jacoco 0.8.11 - supports JDK21 * style(lint): use new build variant configuration style documentation: https://developer.android.com/build/build-variants - defer configuration of build types / flavors with create/named, used in example - flavorDimensions is now a property so you += custom dimensions to it * style(lint): gradle .all --> .configureEach * style(lint): use imports vs fully qualified names * docs(gradle): update comment describing CI vCPU determination * style(lint): use deferred-configuration-compatible task registration/dependency * style(lint): deprecated kotlinOptions -> current compilerOptions * style(lint): project.buildDir -> project.layout.buildDirectory required a slightly different way of building the file tree for kotlin class location as input to the report, but despite being a little subtle it is not at all hard to understand --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2023-11-30 22:01:31 +01:00
tasks.register("robolectricSdkDownload-${version}", Copy) {
from sdkConfig
into mavenRobolectric
doLast {
ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery()
.forModule("org.robolectric", "android-all-instrumented", version)
.withArtifacts(MavenModule, MavenPomArtifact)
.execute()
for(component in result.resolvedComponents) {
def componentId = component.id
if(componentId instanceof ModuleComponentIdentifier) {
File pomFile = component.getArtifacts(MavenPomArtifact)[0].file
File dest = new File(mavenRobolectric, pomFile.name)
if (!dest.exists()) {
Files.copy(pomFile.toPath(), dest.toPath())
}
}
}
}
}
Dependency updates 20231130 (#14855) * build(deps): bump commons-io:commons-io from 2.15.0 to 2.15.1 Bumps commons-io:commons-io from 2.15.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump androidx.webkit:webkit from 1.8.0 to 1.9.0 Bumps androidx.webkit:webkit from 1.8.0 to 1.9.0. --- updated-dependencies: - dependency-name: androidx.webkit:webkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update Gradle Wrapper from 8.4 to 8.5. Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> * build(deps): remove JDK18, support JDK21 (LTS) * build(deps): adopt jacoco 0.8.11 - supports JDK21 * style(lint): use new build variant configuration style documentation: https://developer.android.com/build/build-variants - defer configuration of build types / flavors with create/named, used in example - flavorDimensions is now a property so you += custom dimensions to it * style(lint): gradle .all --> .configureEach * style(lint): use imports vs fully qualified names * docs(gradle): update comment describing CI vCPU determination * style(lint): use deferred-configuration-compatible task registration/dependency * style(lint): deprecated kotlinOptions -> current compilerOptions * style(lint): project.buildDir -> project.layout.buildDirectory required a slightly different way of building the file tree for kotlin class location as input to the report, but despite being a little subtle it is not at all hard to understand --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2023-11-30 22:01:31 +01:00
robolectricSdkDownload.configure { dependsOn "robolectricSdkDownload-${version}" }
}