-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b90e3d
commit d364495
Showing
18 changed files
with
290 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "io.astrum.mindsync.buildlogic.analysis" | ||
version = extra["app.plugins.version"].toString() | ||
|
||
dependencies { | ||
implementation(libs.gradle.detekt) | ||
implementation(libs.gradle.owasp.depcheck) | ||
implementation(project(":common")) | ||
} |
37 changes: 37 additions & 0 deletions
37
build-logic/analysis-convention/src/main/kotlin/detekt-convention.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import io.astrum.mindsync.buildlogic.common.AppConfiguration | ||
import io.astrum.mindsync.buildlogic.common.extensions.catalogLib | ||
import io.gitlab.arturbosch.detekt.Detekt | ||
|
||
plugins { | ||
id("io.gitlab.arturbosch.detekt") | ||
} | ||
|
||
detekt { | ||
toolVersion = "1.23.3" | ||
parallel = true | ||
ignoreFailures = false | ||
autoCorrect = true | ||
buildUponDefaultConfig = true | ||
config.setFrom(files("$rootDir/config/detekt.yml")) | ||
} | ||
|
||
tasks.withType<Detekt>().configureEach { | ||
jvmTarget = AppConfiguration.jvmTargetStr | ||
setSource(files(projectDir)) | ||
include("**/*.kt", "**/*.kts") | ||
exclude("**/resources/**", "**/build/**") | ||
reports { | ||
xml.required.set(true) | ||
html.required.set(true) | ||
txt.required.set(true) | ||
sarif.required.set(true) | ||
md.required.set(true) | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
detektPlugins(catalogLib("detekt-compose")) | ||
detektPlugins(catalogLib("detekt-compose2")) | ||
detektPlugins(catalogLib("detekt-formatting")) | ||
} |
26 changes: 26 additions & 0 deletions
26
build-logic/analysis-convention/src/main/kotlin/security-owasp-convention.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import org.gradle.kotlin.dsl.configure | ||
import org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension | ||
import org.owasp.dependencycheck.reporting.ReportGenerator | ||
|
||
plugins{ | ||
id("org.owasp.dependencycheck") | ||
} | ||
|
||
configure<DependencyCheckExtension> { | ||
failBuildOnCVSS = 9F | ||
formats = listOf( | ||
ReportGenerator.Format.HTML.toString(), | ||
ReportGenerator.Format.JUNIT.toString(), | ||
ReportGenerator.Format.XML.toString(), | ||
ReportGenerator.Format.SARIF.toString() | ||
) | ||
suppressionFile = "${rootProject.rootDir}/config/owasp/owasp-supression.xml" | ||
|
||
// remove plugin dependencies, for configs see | ||
// https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management | ||
val validConfigurations = listOf("compileClasspath", "runtimeClasspath", "default") | ||
scanConfigurations = configurations.names | ||
.filter { validConfigurations.contains(it) } | ||
.toList() | ||
outputDirectory = layout.buildDirectory.dir("reports/owasp").get().asFile.absolutePath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "io.astrum.mindsync.buildlogic.common" | ||
version = extra["app.plugins.version"].toString() | ||
|
||
|
||
dependencies { | ||
// implementation(libs.gradle.compose) | ||
// implementation(libs.gradle.android) | ||
// implementation(libs.gradle.sentry) | ||
implementation(libs.gradle.kotlin) | ||
// implementation(libs.gradle.kotlin.serialization) | ||
// implementation(libs.gradle.devtools.ksp) | ||
} |
15 changes: 15 additions & 0 deletions
15
build-logic/common/src/main/kotlin/io/astrum/mindsync/buildlogic/common/AppConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.astrum.mindsync.buildlogic.common | ||
|
||
import org.gradle.api.JavaVersion | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget as KtJvmTarget | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion as KtVersion | ||
|
||
object AppConfiguration { | ||
const val appName = "Mindsync" | ||
const val packageName = "io.astrum.mindsync" | ||
|
||
val useJavaVersion = JavaVersion.VERSION_17 | ||
val jvmTarget = KtJvmTarget.fromTarget(useJavaVersion.toString()) | ||
val jvmTargetStr = jvmTarget.target | ||
val kotlinVersion = KtVersion.KOTLIN_1_9 | ||
} |
64 changes: 64 additions & 0 deletions
64
...common/src/main/kotlin/io/astrum/mindsync/buildlogic/common/extensions/CommonExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@file:Suppress("UNUSED") | ||
package io.astrum.mindsync.buildlogic.common.extensions | ||
|
||
import io.astrum.mindsync.buildlogic.common.AppConfiguration | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.Configuration | ||
import org.gradle.api.artifacts.ExternalModuleDependency | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.tasks.TaskContainer | ||
import org.gradle.api.tasks.compile.JavaCompile | ||
import org.gradle.kotlin.dsl.DependencyHandlerScope | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
val Project.libs: VersionCatalog get() = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
val Project.fullPackageName get() = AppConfiguration.packageName + path.replace(':', '.') | ||
|
||
fun Project.catalogVersion(alias: String) = libs.findVersion(alias).get().toString() | ||
fun Project.catalogLib(alias: String) = libs.findLibrary(alias).get() | ||
fun Project.catalogBundle(alias: String) = libs.findBundle(alias).get() | ||
|
||
fun KotlinDependencyHandler.catalogVersion(alias: String) = project.catalogVersion(alias) | ||
fun KotlinDependencyHandler.catalogLib(alias: String) = project.catalogLib(alias) | ||
fun KotlinDependencyHandler.catalogBundle(alias: String) = project.catalogBundle(alias) | ||
|
||
fun KotlinDependencyHandler.implementation( | ||
dependencyNotation: Provider<*>, | ||
configure: ExternalModuleDependency.() -> Unit | ||
) { | ||
implementation(dependencyNotation.get().toString(), configure) | ||
} | ||
|
||
fun DependencyHandlerScope.implementation( | ||
provider: Provider<*>, | ||
dependencyConfiguration: ExternalModuleDependency.() -> Unit = {}, | ||
) { | ||
"implementation"(provider, dependencyConfiguration) | ||
} | ||
|
||
|
||
fun Project.coerceComposeVersion(configuration: Configuration) { | ||
val independentGroups = setOf("compiler", "material3") | ||
configuration.resolutionStrategy.eachDependency { | ||
if (requested.group.startsWith("androidx.compose") && independentGroups.none(requested.group::contains)) { | ||
useVersion(libs.findVersion("compose").get().requiredVersion) | ||
because("I need the changes in lazyGrid") | ||
} | ||
} | ||
} | ||
|
||
fun TaskContainer.commonTasks() { | ||
withType<JavaCompile>().configureEach { | ||
sourceCompatibility = AppConfiguration.jvmTargetStr | ||
targetCompatibility = AppConfiguration.jvmTargetStr | ||
} | ||
withType<KotlinCompile>().configureEach { | ||
project.configureKotlinJvm() | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...mon/src/main/kotlin/io/astrum/mindsync/buildlogic/common/extensions/KotlinJvmExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.astrum.mindsync.buildlogic.common.extensions | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* Configure base Kotlin options for JVM (non-Android) | ||
*/ | ||
fun Project.configureKotlinJvm() { | ||
extensions.configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
configureKotlin() | ||
} | ||
|
||
/** | ||
* Configure base Kotlin options | ||
*/ | ||
private fun Project.configureKotlin() { | ||
// Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947 | ||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
freeCompilerArgs = freeCompilerArgs + listOf( | ||
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi", | ||
"-opt-in=androidx.compose.material.ExperimentalMaterialApi", | ||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi", | ||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", | ||
"-opt-in=kotlinx.coroutines.FlowPreview" | ||
) | ||
} | ||
} | ||
val kotlinOptions = "kotlinOptions" | ||
if (extensions.findByName(kotlinOptions) != null) { | ||
extensions.configure(kotlinOptions, Action<KotlinJvmOptions> { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
freeCompilerArgs = freeCompilerArgs + listOf( | ||
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi", | ||
"-opt-in=androidx.compose.material.ExperimentalMaterialApi", | ||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi", | ||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", | ||
"-opt-in=kotlinx.coroutines.FlowPreview" | ||
) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
org.gradle.parallel=true | ||
org.gradle.caching=true | ||
org.gradle.configureondemand=true | ||
org.gradle.configuration-cache=true | ||
|
||
|
||
app.plugins.version=0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
rootProject.name = "build-logic" | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
versionCatalogs { | ||
register("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
// Keep in sync with ../settings.gradle.kts | ||
buildCache { | ||
local { | ||
directory = rootDir.parentFile.resolve(".gradle/build-cache") | ||
} | ||
} | ||
|
||
|
||
include(":common") | ||
//include(":android-convention") | ||
//include(":multiplatform-convention") | ||
include("analysis-convention") | ||
//include("documentation-convention") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd"> | ||
</suppressions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters