Skip to content

Commit

Permalink
Adding ktlint gradle library (#1)
Browse files Browse the repository at this point in the history
* Adding ktlint gradle library

* Adding build gradle

* switch to java 11

* Update github-ci.yml

* update to java 17
  • Loading branch information
andresmr authored Jul 4, 2023
1 parent 0e540de commit b9434d5
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 23 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ jobs:
run: |
echo Add other actions to build,
echo test, and deploy your project.
# Grant permissions for gradlew
# Set java version to 17
- name: set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'

# Grant permissions for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
#- name: Kotlin checkstyle
# run: ./gradlew ktlintCheck
- name: Build with Gradle
- name: Kotlin checkstyle
run: ./gradlew ktlintCheck
- name: Run tests
run: ./gradlew test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ bin/
### Mac OS ###
.DS_Store

local.properties
local.properties
/java_pid44785.hprof
12 changes: 9 additions & 3 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("org.jetbrains.compose")
id("com.android.application")
kotlin("android")
id("org.jlleitschuh.gradle.ktlint")
}

group = "org.hisp.dhis"
Expand All @@ -22,13 +23,18 @@ android {
versionName = "1.0-SNAPSHOT"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
namespace = "org.hisp.dhis.android"
}
}

ktlint {
verbose.set(true)
outputToConsole.set(true)
}
4 changes: 2 additions & 2 deletions android/src/main/java/org/hisp/dhis/android/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.hisp.dhis.android

import org.hisp.dhis.common.App
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme
import org.hisp.dhis.common.App

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -15,4 +15,4 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
}
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ plugins {
id("com.android.application") apply false
id("com.android.library") apply false
id("org.jetbrains.compose") apply false
}
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
}
12 changes: 9 additions & 3 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
id("org.jlleitschuh.gradle.ktlint")
}

group = "org.hisp.dhis"
Expand Down Expand Up @@ -53,8 +54,13 @@ android {
targetSdk = 33
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
namespace = "org.hisp.dhis.common"
}
}

ktlint {
verbose.set(true)
outputToConsole.set(true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package org.hisp.dhis.common

actual fun getPlatformName(): String {
return "Android"
}
}
4 changes: 2 additions & 2 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.hisp.dhis.common

import androidx.compose.material.Text
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -14,7 +14,7 @@ fun App() {
val platformName = getPlatformName()

Button(onClick = {
text = "Hello, ${platformName}"
text = "Hello, $platformName"
}) {
Text(text)
}
Expand Down
3 changes: 3 additions & 0 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/Platform.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.hisp.dhis.common

expect fun getPlatformName(): String
3 changes: 0 additions & 3 deletions common/src/commonMain/kotlin/org/hisp/dhis/common/platform.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import androidx.compose.runtime.Composable
@Composable
fun AppPreview() {
App()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package org.hisp.dhis.common

actual fun getPlatformName(): String {
return "Desktop"
}
}

0 comments on commit b9434d5

Please sign in to comment.