Skip to content
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
53 changes: 28 additions & 25 deletions MPChartLib/build.gradle → MPChartLib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
import info.git.versionHelper.getVersionText
import java.net.URI

plugins {
id "com.android.library"
id "maven-publish"
id "kotlin-android"
id "com.vanniktech.maven.publish" version "0.34.0"
id("com.android.library")
id("maven-publish")
id("kotlin-android")
id("com.vanniktech.maven.publish") version "0.34.0"
}

android {
namespace "com.github.mikephil.charting"
namespace = "com.github.mikephil.charting"
defaultConfig {
minSdkVersion 21
compileSdk 35
targetSdkVersion 35
minSdk = 21
compileSdk = 35

// VERSION_NAME no longer available as of 4.1
// https://issuetracker.google.com/issues/158695880
buildConfigField "String", "VERSION_NAME", "\"${getTag()}\""
buildConfigField("String", "VERSION_NAME", "\"${getVersionText()}\"")

consumerProguardFiles "proguard-lib.pro"
consumerProguardFiles.add(File("proguard-lib.pro"))
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildTypes {
release {
minifyEnabled false
isMinifyEnabled = false
}
}
buildFeatures {
buildConfig = true
}
testOptions {
unitTests.returnDefaultValues = true // this prevents "not mocked" error
unitTests.isReturnDefaultValues = true // this prevents "not mocked" error
}
}

dependencies {
implementation "androidx.annotation:annotation:1.9.1"
implementation "androidx.core:core:1.16.0"
implementation "androidx.activity:activity-ktx:1.10.1"
testImplementation "junit:junit:4.13.2"
implementation("androidx.annotation:annotation:1.9.1")
implementation("androidx.core:core:1.16.0")
implementation("androidx.activity:activity-ktx:1.10.1")
testImplementation("junit:junit:4.13.2")
}

tasks.register("androidSourcesJar", Jar) {
tasks.register<Jar>("androidSourcesJar") {
archiveClassifier.set("sources")
from android.sourceSets.main.java.srcDirs
from(android.sourceSets["main"].java.srcDirs)
}

group = "info.mxtracks"
version = "${getTag()}"
println "Build version $version"
var versionVersion = getVersionText()
println("Build version $versionVersion")

mavenPublishing {
pom {
name = "Android Chart"
description = "A powerful Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations"
description =
"A powerful Android chart view/graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging and animations"
inceptionYear = "2022"
url = "https://github.com/AppDevNext/AndroidChart/"
licenses {
Expand All @@ -81,9 +84,9 @@ mavenPublishing {
// Github packages
repositories {
maven {
version = version + "-SNAPSHOT"
version = "$versionVersion-SNAPSHOT"
name = "GitHubPackages"
url = "https://maven.pkg.github.com/AppDevNext/AndroidChart"
url = URI("https://maven.pkg.github.com/AppDevNext/AndroidChart")
credentials {
username = System.getenv("GITHUBACTOR")
password = System.getenv("GITHUBTOKEN")
Expand Down
50 changes: 0 additions & 50 deletions app/build.gradle

This file was deleted.

60 changes: 60 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import info.git.versionHelper.getGitCommitCount
import info.git.versionHelper.getVersionText
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
id("kotlin-android")
}

android {
namespace = "info.appdev.chartexample"
defaultConfig {
applicationId = "info.appdev.chartexample"
minSdk = 21
compileSdk = 35
targetSdk = 35
versionCode = getGitCommitCount()
versionName = getVersionText()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments.putAll(
mapOf(
"useTestStorageService" to "true",
),
)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles.addAll(listOf(getDefaultProguardFile("proguard-android.txt"), File("proguard-rules.pro")))
}
}
// https://stackoverflow.com/a/67635863/1079990
testOptions {
animationsDisabled = true
}
}

dependencies {
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("com.google.android.material:material:1.13.0")
implementation(project(":MPChartLib"))

androidTestImplementation("androidx.test.ext:junit-ktx:1.3.0")
androidTestImplementation("com.github.AppDevNext.Logcat:LogcatCoreLib:3.4")
androidTestUtil("androidx.test.services:test-services:1.6.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.7.0")
}
33 changes: 0 additions & 33 deletions build.gradle

This file was deleted.

19 changes: 19 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.13.0")
classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.20")
}
}

allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
2 changes: 2 additions & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gradle
build
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
32 changes: 32 additions & 0 deletions buildSrc/src/main/kotlin/info/git/versionHelper/GitVersionUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package info.git.versionHelper

import java.io.File
import java.util.concurrent.TimeUnit

@JvmOverloads
fun String.runCommand(workingDir: File = File("./")): String {
val parts = this.split("\\s".toRegex())
val proc = ProcessBuilder(*parts.toTypedArray())
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()

proc.waitFor(1, TimeUnit.MINUTES)
return proc.inputStream.bufferedReader().readText().trim()
}

fun getGitCommitCount(): Int {
val process = "git rev-list HEAD --count".runCommand()
return process.toInt() + 580
}

fun getVersionText(): String {
val processChanges = "git diff-index --name-only HEAD --".runCommand()
var dirty = ""
if (processChanges.trim().isNotEmpty())
dirty = "-DIRTY"

val processDescribe = "git describe".runCommand()
return processDescribe.trim() + dirty
}
Loading