Skip to content

Commit

Permalink
chore: Dependencies management and publishing workflow updates (#20)
Browse files Browse the repository at this point in the history
* chore: updated dependencies management

* chore: updated process to upload artifacts

* chore: added ci workflow for snapshot

* chore: ignore idea file changes

* chore: updated git ignore to cater idea files

* chore: fixed untracked files

* chore: added missing dependencies
  • Loading branch information
Shahroz16 authored Sep 24, 2021
1 parent f6c1844 commit 299d243
Show file tree
Hide file tree
Showing 24 changed files with 285 additions and 320 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/snapshot-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Snapshot builds

on:
push:
branches:
- develop

jobs:
publish:
name: Snapshot build and publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
- name: Release build
# assembleRelease for all modules, excluding non-library modules: samples, docs
run: ./gradlew assembleRelease -x :app:assembleRelease -x
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar
- name: Add MODULE_VERSION env property with commit short sha
run: echo "MODULE_VERSION=`echo ${GITHUB_SHA} | cut -c1-8`-snapshot" >> $GITHUB_ENV
- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository
env:
OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }}
SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }}
SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }}
# SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SNAPSHOT: true
15 changes: 4 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
/.idea/*
!/.idea/codeInsightSettings.xml
!/.idea/codeStyles/
!/.idea/inspectionProfiles/

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
Expand Down
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

30 changes: 0 additions & 30 deletions .idea/jarRepositories.xml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

85 changes: 13 additions & 72 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import customerio.android.Dependencies

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

hilt {
enableTransformForLocalTests = true // to get unit tests (robolectric) working: https://developer.android.com/training/dependency-injection/hilt-testing
}
apply from: "${rootDir}/scripts/android-config.gradle"

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "io.customer.example"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -43,72 +37,19 @@ android {
unitTests {
// From: http://robolectric.org/getting-started/
includeAndroidResources = true
returnDefaultValues = true
}
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

// Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

// Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"

// Truth
testImplementation "com.google.truth:truth:1.0.1"
androidTestImplementation "com.google.truth:truth:1.0.1"
androidTestImplementation 'androidx.test.ext:truth:1.3.0'
testImplementation 'androidx.test.ext:truth:1.3.0'

// Mockito
def mockitoVersion = '3.3.3'
def mockitoKotlinVersion = '2.2.0'
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion", {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
}
androidTestImplementation "org.mockito:mockito-android:$mockitoVersion"
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion", {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
}

// JUnit
def junitVersion = '4.13.2'
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "junit:junit:$junitVersion"
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation 'androidx.test.ext:junit:1.1.2'

// Robolectric
testImplementation "org.robolectric:robolectric:4.5.1"

// Android Testing Support Library's runner and rules
def androidTestLibVersion = "1.3.0"
androidTestImplementation "androidx.test:core-ktx:$androidTestLibVersion"
androidTestImplementation "androidx.test:runner:$androidTestLibVersion"
androidTestImplementation "androidx.test:rules:$androidTestLibVersion"
testImplementation "androidx.test:core-ktx:$androidTestLibVersion"
testImplementation "androidx.test:runner:$androidTestLibVersion"
testImplementation "androidx.test:rules:$androidTestLibVersion"
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

// Espresso UI Testing
def espressoVersion = '3.3.0'
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
testImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
testImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
testImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
implementation project(":sdk")
implementation Dependencies.androidxAppCompat
implementation Dependencies.androidxCoreKtx
implementation Dependencies.materialComponents

androidTestImplementation Dependencies.junit4
testImplementation Dependencies.junit4
testImplementation Dependencies.androidxTestJunit
testImplementation Dependencies.robolectric
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:supportsRtl="true"
android:name=".MainApplication"
android:theme="@style/Theme.App">
<activity android:name="io.customer.example.MainActivity">
<activity android:name="io.customer.example.MainActivity"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/io/customer/example/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.customer.example

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MainApplication : Application()
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -15,4 +15,4 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package io.customer.example

import android.content.Context
import androidx.test.core.app.ApplicationProvider.getApplicationContext
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ExampleRobolectricTest {

val context: Context
get() = getApplicationContext<MainApplication>()

@Test
fun canAccessR() {
assertThat(context.getString(R.string.app_name)).isEqualTo("Customer.io SDK Example")
Assert.assertEquals(1, 1)
}
}
42 changes: 12 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.32"
ext.hilt_version = '2.33-beta'

ext {
githubRepoOrg = "customerio"
githubRepoName = "customerio-android"
developerId = "customerio"
developerName = "Customer.io Team"
developerEmail = "win@customer.io"
import customerio.android.Dependencies

// these are default values for each module. See sdk/build.gradle for example of how to overwrite values before publishing
modulePackageName = "<overwrite-me>" // example: "io.customer.sdk"
moduleName = "<overwrite-me>" // example: sdk"
moduleFormalName = "<overwrite-me>" // example: "Customer.io Android SDK" // human readable name
moduleDescription = "<overwrite-me>" // example: "Official Customer.io SDK for Android"
moduleSourceCodeLocalDir = "<overwrite-me>" // For Dokka for source code linking. Path to local source code. Example: "sdk/src/main/java"
moduleSourceCodeLinkUrl = "<overwrite-me>" // For Dokka to link to remote source code. Path to remote source code path that matches local. example: "https://github.com/customerio/customerio-android/blob/main/sdk/src/main/java"
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply plugin: 'org.jetbrains.dokka'

moduleUrl = "https://github.com/customerio/customerio-android"
moduleSourceCodeUrl = "https://github.com/customerio/customerio-android"
moduleSourceCodeConnection = "scm:git@github.com:customerio/customerio-android.git"
moduleLicenseName = "MIT"
moduleLicenseUrl = "https://github.com/customerio/customerio-android/blob/main/LICENSE"
}
buildscript {

repositories {
maven { url "https://plugins.gradle.org/m2/" }
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.32"

classpath Dependencies.androidGradlePlugin
classpath Dependencies.kotlinGradlePlugin
classpath Dependencies.gradleNexusPublishPlugin
classpath Dependencies.dokka
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -49,4 +29,6 @@ allprojects {

task clean(type: Delete) {
delete rootProject.buildDir
}
}

apply from: "${rootDir}/scripts/publish-root.gradle"
9 changes: 9 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.gradle.kotlin.dsl.`kotlin-dsl`

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
8 changes: 8 additions & 0 deletions buildSrc/src/main/kotlin/customerio/android/Configurations.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package customerio.android

object Configurations {
const val compileSdk = 30
const val targetSdk = 30
const val minSdk = 21
const val artifactGroup = "io.customer.android"
}
Loading

0 comments on commit 299d243

Please sign in to comment.