Skip to content

Commit

Permalink
new compose & kotlin 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mimoccc committed May 20, 2024
1 parent b985d2d commit 562b742
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 130 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,18 @@ google-services.json
/web/app.nginx
/web/app.service
/web/package.json

# kotlin v 2.0
.kotlin
.kotlin/
/.kotlin/

dependencies.md

documentation/app
documentation/app/
/documentation/app/

documentation/lib
/documentation/lib
/documentation/lib/
62 changes: 0 additions & 62 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,65 +48,3 @@ appConfig {
}

}

//ospackage {
// packageName = 'foo'
// version = '1.2.3'
// release = '1'
// arch = I386
// os = LINUX
//
// installUtils file('scripts/rpm/utils.sh')
// preInstall file('scripts/rpm/preInstall.sh')
// postInstall file('scripts/rpm/postInstall.sh')
// preUninstall 'touch /tmp/myfile'
// postUninstall file('scripts/rpm/postUninstall.sh')
//
// requires('qux')
//
// into '/opt/foo'
//
// from(jar.outputs.files) {
// into 'lib'
// }
// from(configurations.runtime) {
// into 'lib'
// }
// from('lib') {
// into 'lib'
// }
// from('scripts') {
// into 'bin'
// exclude 'database'
// fileMode = 0550
// }
// from('src/main/resources') {
// fileType CONFIG | NOREPLACE
// into 'conf'
// }
// from('home') {
// // Creating directory entries (or not) in the RPM is normally left up to redline-rpm library.
// // Use this to explicitly create an entry -- for setting directory fileMode on system directories.
// createDirectoryEntry = true
// fileMode = 0500
// into 'home'
// }
// from('endorsed') {
// // Will tell redline-rpm not to auto create directories, which
// // is sometimes necessary to avoid rpm directory conflicts
// addParentDirs = false
// into '/usr/share/tomcat/endorsed'
// }
//
//}
//
//buildRpm {
// requires('bar', '2.2', GREATER | EQUAL)
// requires('baz', '1.0.1', LESS)
// link('/etc/init.d/foo’, '/opt/foo/bin/foo.init')
//}
//
//buildDeb {
// requires('bat', '1.0.1')
// link('/etc/init.d/foo', '/opt/foo/bin/foo.upstart')
//}
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation(libs.moshi.kotlin)
implementation(libs.kotlin.mockito)
implementation(libs.junit)
implementation(libs.kotlin.compose.compiler)
// implementation(libs.apk.parser)
// implementation(libs.gradle.docker.plugin)
// implementation(libs.korim.jvm)
Expand Down
13 changes: 11 additions & 2 deletions buildSrc/src/main/kotlin/org/mjdev/gradle/extensions/ProjectExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.gradle.api.Task
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.plugins.ExtraPropertiesExtension
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME
import org.gradle.api.tasks.SourceSet.TEST_SOURCE_SET_NAME
Expand All @@ -34,6 +35,7 @@ import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.withType
import org.gradle.plugin.use.PluginDependency
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down Expand Up @@ -287,9 +289,16 @@ inline fun <reified T : Task> Project.registerTask(
}
}

fun <T : Plugin<*>> Project.apply(type: KClass<T>): T = plugins.apply(type.java)
inline fun <reified T : Plugin<Project>> Project.applyPlugin(): T =
plugins.apply(T::class.java)

fun Project.apply(id: String): Plugin<*> = plugins.apply(id)
fun <T:Plugin<Project>> Project.applyPlugin(type: KClass<T>): T =
plugins.apply(type.java)

fun Project.applyPlugin(type: Provider<PluginDependency>) =
applyPlugin(type.get().pluginId)

fun Project.applyPlugin(id: String): Plugin<*> = plugins.apply(id)

inline fun <reified T : Task> Project.task(scoped: T.() -> Unit = {}): T {
val task = tasks.withType<T>().first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.StartParameter
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.logging.Logger
Expand Down Expand Up @@ -305,8 +306,8 @@ fun Task.mustRunAfter(taskScope: () -> Task) {
mustRunAfter(taskScope())
}

fun <T : Plugin<*>> Task.apply(type: KClass<T>): T =
project.apply(type)
fun <T : Plugin<Project>> Task.apply(type: KClass<T>) =
project.applyPlugin(type)

fun Task.kotlinCompileOptions(scoped: KotlinCompile.() -> Unit) =
project.kotlinCompileOptions(scoped)
Expand Down
33 changes: 17 additions & 16 deletions buildSrc/src/main/kotlin/org/mjdev/gradle/plugin/AppPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import io.gitlab.arturbosch.detekt.DetektPlugin
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.LockMode
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.dokka.Platform
Expand Down Expand Up @@ -44,7 +43,7 @@ import org.mjdev.gradle.extensions.kotlinCompileOptions
import org.mjdev.gradle.extensions.detektTask
import org.mjdev.gradle.extensions.dokkaTask
import org.mjdev.gradle.extensions.releaseNotesCreateTask
import org.mjdev.gradle.extensions.apply
import org.mjdev.gradle.extensions.applyPlugin
import org.mjdev.gradle.extensions.projectName
import org.mjdev.gradle.extensions.webServiceCreateTask
import org.mjdev.gradle.extensions.loadRootPropertiesFile
Expand All @@ -69,20 +68,21 @@ class AppPlugin : BasePlugin() {
val appConfig: AppConfig = extension<AppConfig>(AppConfig.configFieldName)
fromBuildPropertiesFile(appConfig, AppConfig.configPropertiesFile)
loadRootPropertiesFile(appConfig.versionPropertiesFile)
apply(plugin = "com.android.application")
apply(plugin = "kotlin-kapt")
apply(plugin = "kotlin-android")
apply(plugin = "kotlin-parcelize")
apply(plugin = "com.google.devtools.ksp")
apply(plugin = "com.google.dagger.hilt.android")
apply(plugin = "dagger.hilt.android.plugin")
apply(plugin = "io.objectbox")
apply(plugin = "org.jetbrains.dokka")
apply(MarkdownPlugin::class)
apply(DetektPlugin::class)
apply(KotlinterPlugin::class)
applyPlugin(libs.plugins.android.application)
applyPlugin(libs.plugins.kotlin.kapt)
applyPlugin(libs.plugins.kotlin.android)
applyPlugin(libs.plugins.kotlin.parcelize)
applyPlugin(libs.plugins.google.devtools.ksp)
applyPlugin(libs.plugins.google.dagger.hilt.android)
applyPlugin(libs.plugins.dagger.hilt.android)
applyPlugin(libs.plugins.objectbox)
applyPlugin(libs.plugins.gradle.dokka)
applyPlugin(libs.plugins.kotlin.compose.compiler)
applyPlugin<MarkdownPlugin>()
applyPlugin<DetektPlugin>()
applyPlugin<KotlinterPlugin>()
registerTask<CleanProjectTask>()
registerTask<CheckNewLibsTask>() {
registerTask<CheckNewLibsTask> {
mustRunAfter(cleanProjectTask())
}
registerTask<CreatePropsTask> {
Expand All @@ -109,7 +109,7 @@ class AppPlugin : BasePlugin() {
targetCompatibility = AppConfig.javaVersion
}
composeOptions {
kotlinCompilerExtensionVersion = AppConfig.kotlinCompilerVersion
// enableStrongSkippingMode = true
}
defaultConfig {
applicationId = appConfig.namespace
Expand Down Expand Up @@ -283,6 +283,7 @@ class AppPlugin : BasePlugin() {
}
}
kotlinCompileOptions {
@Suppress("DEPRECATION")
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = AppConfig.javaVersion.toString()
Expand Down
30 changes: 16 additions & 14 deletions buildSrc/src/main/kotlin/org/mjdev/gradle/plugin/LibPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import io.gitlab.arturbosch.detekt.DetektPlugin
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.LockMode
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.dokka.Platform
Expand All @@ -34,30 +33,32 @@ import org.mjdev.gradle.extensions.ksp
import org.mjdev.gradle.extensions.kotlinCompileOptions
import org.mjdev.gradle.extensions.detektTask
import org.mjdev.gradle.extensions.dokkaTask
import org.mjdev.gradle.extensions.apply
import org.mjdev.gradle.extensions.fromBuildPropertiesFile
import org.mjdev.gradle.extensions.loadRootPropertiesFile
import org.mjdev.gradle.extensions.projectName
import org.mjdev.gradle.extensions.registerTask
import org.mjdev.gradle.tasks.CreatePropsTask
import org.mjdev.gradle.extensions.applyPlugin

@Suppress("UnstableApiUsage")
class LibPlugin : BasePlugin() {
override fun Project.work() {
val libConfig: LibConfig = extension<LibConfig>(LibConfig.configFieldName)
fromBuildPropertiesFile(libConfig, LibConfig.configPropertiesFile)
loadRootPropertiesFile(libConfig.versionPropertiesFile)
apply(plugin = "kotlin-android")
apply(plugin = "com.android.library")
apply(plugin = "kotlin-kapt")
apply(plugin = "kotlin-parcelize")
apply(plugin = "com.google.devtools.ksp")
apply(plugin = "com.google.dagger.hilt.android")
apply(plugin = "dagger.hilt.android.plugin")
apply(plugin = "io.objectbox")
apply("org.jetbrains.dokka")
apply(DetektPlugin::class)
apply(KotlinterPlugin::class)
applyPlugin(libs.plugins.android.library)
applyPlugin(libs.plugins.kotlin.kapt)
applyPlugin(libs.plugins.kotlin.android)
applyPlugin(libs.plugins.kotlin.parcelize)
applyPlugin(libs.plugins.google.devtools.ksp)
applyPlugin(libs.plugins.google.devtools.ksp)
applyPlugin(libs.plugins.google.dagger.hilt.android)
applyPlugin(libs.plugins.dagger.hilt.android)
applyPlugin(libs.plugins.objectbox)
applyPlugin(libs.plugins.gradle.dokka)
applyPlugin(libs.plugins.kotlin.compose.compiler)
applyPlugin<DetektPlugin>()
applyPlugin<KotlinterPlugin>()
registerTask<CreatePropsTask> {
propsFilePath = LibConfig.configPropertiesFile
propsClass = LibConfig::class.java
Expand All @@ -74,7 +75,7 @@ class LibPlugin : BasePlugin() {
buildConfig = LibConfig.buildConfigEnabled
}
composeOptions {
kotlinCompilerExtensionVersion = LibConfig.kotlinCompilerVersion
// enableStrongSkippingMode = true
}
defaultConfig {
minSdk = LibConfig.minSdk
Expand Down Expand Up @@ -148,6 +149,7 @@ class LibPlugin : BasePlugin() {
}
}
kotlinCompileOptions {
@Suppress("DEPRECATION")
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = LibConfig.javaVersion.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ open class AppConfig : BuildConfigs() {
const val compileSdk = 34
const val minSdk = 21

const val kotlinCompilerVersion = "1.5.8"
const val jacocoVersion = "0.8.8"

const val multiDexEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ open class LibConfig : BuildConfigs() {
const val compileSdk = 34
const val minSdk = 21

const val kotlinCompilerVersion = "1.5.8"
const val jacocoVersion = "0.8.8"

val javaVersion = JavaVersion.VERSION_17
Expand Down
2 changes: 1 addition & 1 deletion config/version.app.prop
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
#
majorVersion=1
minorVersion=3
patchVersion=0
patchVersion=1
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ kotlin.mpp.applyDefaultHierarchyTemplate=false
createReports=true
systemProp.javax.xml.accessExternalDTD=http
systemProp.javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
kotlin.experimental.tryK2=true
Loading

0 comments on commit 562b742

Please sign in to comment.