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

Simplify deployment #68

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 0 additions & 30 deletions .buildsystem/deploy-sonatype.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: ./gradlew build publishAllPublicationsToLocalRepository
run: ./gradlew build
- name: Build sample
run: ./gradlew -p sample marathonDebugAndroidTest --dry-run
run: ./gradlew -p sample marathon --dry-run
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# Marathon
Cross-platform test runner for Android projects
Test runner for Android projects

## Main focus
- **stability** of test execution adjusting for flakiness in the environment and in the tests.
- **performance** using high parallelization (handling dozens of devices)

## Documentation
Please check the official [documentation](https://malinskiy.github.io/marathon/) for installation, configuration and more

<br />

### Testing Local Changes
If you want to make a small update and test it locally before pushing a branch, you can follow these steps:
- make sure you have been grated access to the repo
- clone the repo on your local machine and do a build ```./gradlew clean assemble```
- clone the repo on your local machine and build ```./gradlew build```
- make your changes and verify that the tests pass
- deploy to local maven with ```./gradlew publishToMavenLocal -PreleaseMode=SNAPSHOT```
- to use the artifact in your other Repo, make sure you set `mavenLocal()` before other repositories in your buildScript node in settings.gradle
- to use the artifact in your other Repo, make sure you set `mavenLocal()` before other repositories in your `pluginManagement` node in settings.gradle
- to check that the deploy stage was successful, check the pom file in your local maven directory
(e.g. `vim ~/.m2/repository/marathon/marathon.gradle.plugin/0.5.4-SNAPSHOT/marathon.gradle.plugin-0.5.4-SNAPSHOT.pom`)
- note that the artifact name to import will begin with "com.malinskiy.marathon" (e.g. ```implementation "com.malinskiy.marathon:marathon-gradle-plugin:0.5.4-SNAPSHOT"```)
- note that the artifact name to import will begin with "com.github.badoo.marathon" (e.g. ```implementation "com.github.badoo.marathon:marathon-gradle-plugin:0.5.4-SNAPSHOT"```)

License
-------
Expand Down
37 changes: 19 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -17,32 +18,32 @@ configure<DetektExtension> {
}

allprojects {
group = "com.malinskiy.marathon"
group = "com.github.badoo.marathon"

repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
plugins.withId("org.jetbrains.kotlin.jvm") {
dependencies.add("implementation", dependencies.platform(Libraries.kotlinBom))
dependencies.add("implementation", dependencies.platform(Libraries.kotlinCoroutinesBom))
}

project.plugins.withId("org.jetbrains.kotlin.jvm") {
project.dependencies.add("implementation", project.dependencies.platform(Libraries.kotlinBom))
project.dependencies.add("implementation", project.dependencies.platform(Libraries.kotlinCoroutinesBom))
}

extensions.findByType<JavaPluginExtension>()?.run {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
plugins.withId("java") {
extensions.configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}
}

project.tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.addAll(
"-opt-in=kotlin.RequiresOptIn"
)
}
}
}

tasks.register<Delete>("clean") {
delete(project.layout.buildDirectory)
delete(layout.buildDirectory)
}
49 changes: 5 additions & 44 deletions buildSrc/src/main/kotlin/Deployment.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.creating
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.the
import org.gradle.plugins.signing.SigningExtension
import java.net.URI

object Deployment {
val user = System.getenv("SONATYPE_USERNAME")
val password = System.getenv("SONATYPE_PASSWORD")
val githubUser = System.getenv("GITHUB_MAVEN_USERNAME")
val githubPassword = System.getenv("GITHUB_MAVEN_PASSWORD")
var releaseMode: String? = null
var versionSuffix: String? = null
var deployUrl: String? = null

val snapshotDeployUrl = System.getenv("SONATYPE_SNAPSHOTS_URL")
?: "https://oss.sonatype.org/content/repositories/snapshots/"
val releaseDeployUrl = System.getenv("SONATYPE_RELEASES_URL")
?: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val githubDeployUrl = "https://maven.pkg.github.com/Malinskiy"
val githubDeployUrl = "https://maven.pkg.github.com/badoo"

fun initialize(project: Project) {
val releaseMode: String? by project
Expand All @@ -37,10 +28,6 @@ object Deployment {

Deployment.releaseMode = releaseMode
Deployment.versionSuffix = versionSuffix
Deployment.deployUrl = when (releaseMode) {
"RELEASE" -> Deployment.releaseDeployUrl
else -> Deployment.snapshotDeployUrl
}

initializePublishing(project)
initializeSigning(project)
Expand All @@ -51,40 +38,14 @@ object Deployment {

project.plugins.apply("maven-publish")

val javaPlugin = project.the(JavaPluginExtension::class)

val sourcesJar by project.tasks.creating(org.gradle.api.tasks.bundling.Jar::class) {
archiveClassifier.set("sources")
from(javaPlugin.sourceSets["main"].allSource)
}
val javadocJar by project.tasks.creating(org.gradle.api.tasks.bundling.Jar::class) {
archiveClassifier.set("javadoc")
from(javaPlugin.docsDir)
dependsOn("javadoc")
}

project.configure<PublishingExtension> {
publications {
create("default", MavenPublication::class.java) {
create<MavenPublication>("default") {
Deployment.customizePom(project, pom)
from(project.components["java"])
artifact(sourcesJar)
artifact(javadocJar)
}
}
repositories {
maven {
name = "Local"
setUrl("${project.rootDir}/build/repository")
}
maven {
name = "OSSHR"
credentials {
username = Deployment.user
password = Deployment.password
}
url = URI.create(Deployment.deployUrl)
}
maven {
name = "GitHub"
credentials {
Expand Down Expand Up @@ -116,7 +77,7 @@ object Deployment {
fun customizePom(project: Project, pom: MavenPom?) {
pom?.apply {
name.set(project.name)
url.set("https://github.com/Malinskiy/marathon")
url.set("https://github.com/badoo/marathon")
description.set("Android test runner")

licenses {
Expand All @@ -135,7 +96,7 @@ object Deployment {
}

scm {
url.set("https://github.com/Malinskiy/marathon")
url.set("https://github.com/badoo/marathon")
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions sample/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
android.useAndroidX=true

androidPluginVersion=8.5.0
androidPluginVersion=8.5.1
kotlinVersion=1.9.24
marathonVersion=0.5.4-SNAPSHOT
10 changes: 6 additions & 4 deletions sample/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
pluginManagement {
repositories {
google()
maven { url "$rootDir/../build/repository" }
gradlePluginPortal()
mavenCentral()
google()
maven { url "https://jitpack.io" }
}
plugins {
id "com.android.application" version "$androidPluginVersion"
id "com.android.library" version "$androidPluginVersion"
id "org.jetbrains.kotlin.android" version "$kotlinVersion"
id "marathon" version "$marathonVersion"
}

includeBuild("..")
}

dependencyResolutionManagement {
Expand All @@ -20,6 +21,7 @@ dependencyResolutionManagement {
}
}

rootProject.name = "multi-module"
rootProject.name = "sample"

include ":app"
include ":library"
11 changes: 10 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginManagement {
repositories {
maven { url = uri("$rootDir/build/repository") }
gradlePluginPortal()
mavenCentral()
}
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.22"
Expand All @@ -10,7 +10,16 @@ pluginManagement {
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
}
}

rootProject.name = "marathon"

include("core")
include("vendor:vendor-android:base")
include("vendor:vendor-android:ddmlib")
Expand Down
Loading