Skip to content

Commit c6a0cac

Browse files
committed
Enhance .gitignore and build configuration; add ktlint plugin and versioning improvements
1 parent 8872fd4 commit c6a0cac

File tree

7 files changed

+62
-32
lines changed

7 files changed

+62
-32
lines changed

.gitignore

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,56 @@
22
.gradle/
33
build/
44
*/build/
5+
!**/src/main/**/build/
6+
!**/src/test/**/build/
57

6-
# IDEA / IntelliJ / Android Studio
8+
# Gradle Cache and Local Files
9+
.gradle
10+
local.properties
11+
gradle-app.setting
12+
!gradle-wrapper.jar
13+
.gradletasknamecache
14+
15+
# IntelliJ IDEA / Android Studio
716
.idea/
8-
*.iml
17+
.idea
918
*.iws
19+
*.iml
1020
*.ipr
1121
out/
22+
!**/src/main/**/out/
23+
!**/src/test/**/out/
1224

1325
# Android
14-
local.properties
15-
captures/
16-
.externalNativeBuild/
17-
.cxx/
1826
*.apk
1927
*.ap_
2028
*.aab
29+
*.dex
30+
*.class
31+
captures/
32+
.externalNativeBuild/
33+
.cxx/
34+
35+
# Kotlin
36+
.kotlin/
37+
.kotlin
38+
*.kotlin_module
2139

2240
# VS Code
2341
.vscode/
42+
.vscode
2443
*.code-workspace
44+
.history/
2545
vista-plugin/.vscode/
2646

2747
# System
2848
.DS_Store
2949
Thumbs.db
50+
ehthumbs.db
51+
Desktop.ini
3052

31-
# Kotlin
32-
.kotlin/
53+
# Log Files
54+
*.log
55+
npm-debug.log*
56+
yarn-debug.log*
57+
yarn-error.log*

build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22
plugins {
33
alias(libs.plugins.android.application) apply false
44
alias(libs.plugins.kotlin.android) apply false
5-
}
5+
alias(libs.plugins.ktlint)
6+
}
7+
8+
subprojects {
9+
apply(plugin = "org.jlleitschuh.gradle.ktlint")
10+
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ junitVersion = "1.2.1"
77
espressoCore = "3.6.1"
88
appcompat = "1.7.0"
99
material = "1.12.0"
10+
ktlint = "12.1.0"
1011

1112
[libraries]
1213
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -19,4 +20,5 @@ material = { group = "com.google.android.material", name = "material", version.r
1920
[plugins]
2021
android-application = { id = "com.android.application", version.ref = "agp" }
2122
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
23+
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
2224

settings.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pluginManagement {
22
repositories {
33
google {
44
content {
5-
includeGroupByRegex("com\\.android.*") // Not strictly needed for a CLI plugin
5+
includeGroupByRegex("com\\.android.*") // Not strictly needed for a CLI plugin
66
includeGroupByRegex("com\\.google.*")
77
includeGroupByRegex("androidx.*")
88
}
@@ -25,4 +25,4 @@ dependencyResolutionManagement {
2525
google()
2626
mavenCentral()
2727
}
28-
}
28+
}

vista-plugin/bin/main/com/example/VersioningPlugin.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import org.gradle.api.Project
66
import java.io.File
77
import java.util.Properties
88

9-
109
class VersioningPlugin : Plugin<Project> {
1110
override fun apply(target: Project) {
1211
// Register a task to increment the version using the version.properties file
@@ -17,22 +16,23 @@ class VersioningPlugin : Plugin<Project> {
1716
println("⚠️ version.properties not found in ${target.rootDir.absolutePath}")
1817
return@doLast
1918
}
20-
19+
2120
// Load properties from the version file
22-
val properties = Properties().apply {
23-
versionFile.inputStream().use { load(it) }
24-
}
25-
21+
val properties =
22+
Properties().apply {
23+
versionFile.inputStream().use { load(it) }
24+
}
25+
2626
// Safely retrieve the current build number (defaulting to 0)
2727
val currentBuild = properties.getProperty("BUILD_NUMBER", "0").toIntOrNull() ?: 0
2828
val newBuild = currentBuild + 1
29-
29+
3030
// Update the property and persist changes back to the version file
3131
properties.setProperty("BUILD_NUMBER", newBuild.toString())
3232
versionFile.bufferedWriter().use { writer ->
3333
properties.store(writer, null)
3434
}
35-
35+
3636
println("✅ Updated build number to: $newBuild")
3737
}
3838
}

vista-plugin/build.gradle.kts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import org.gradle.api.tasks.Copy
21
import org.gradle.api.file.DuplicatesStrategy
3-
import com.gradle.publish.PluginBundleExtension
2+
import org.gradle.api.tasks.Copy
43

54
plugins {
65
`java-gradle-plugin`
@@ -24,8 +23,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
2423
}
2524
}
2625

27-
// Skip test task configuration since there are no tests
28-
tasks.withType<Test>().configureEach {
26+
tasks.named<Test>("test") {
2927
enabled = false
3028
}
3129

@@ -50,4 +48,4 @@ gradlePlugin {
5048

5149
tasks.withType<Copy>().configureEach {
5250
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
53-
}
51+
}

vista-plugin/src/main/kotlin/com/example/VersioningPlugin.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import org.gradle.api.Project
66
import java.io.File
77
import java.util.Properties
88

9-
109
class VersioningPlugin : Plugin<Project> {
1110
override fun apply(target: Project) {
1211
// Register a task to increment the version using the version.properties file
@@ -17,22 +16,23 @@ class VersioningPlugin : Plugin<Project> {
1716
println("⚠️ version.properties not found in ${target.rootDir.absolutePath}")
1817
return@doLast
1918
}
20-
19+
2120
// Load properties from the version file
22-
val properties = Properties().apply {
23-
versionFile.inputStream().use { load(it) }
24-
}
25-
21+
val properties =
22+
Properties().apply {
23+
versionFile.inputStream().use { load(it) }
24+
}
25+
2626
// Safely retrieve the current build number (defaulting to 0)
2727
val currentBuild = properties.getProperty("BUILD_NUMBER", "0").toIntOrNull() ?: 0
2828
val newBuild = currentBuild + 1
29-
29+
3030
// Update the property and persist changes back to the version file
3131
properties.setProperty("BUILD_NUMBER", newBuild.toString())
3232
versionFile.bufferedWriter().use { writer ->
3333
properties.store(writer, null)
3434
}
35-
35+
3636
println("✅ Updated build number to: $newBuild")
3737
}
3838
}

0 commit comments

Comments
 (0)