Skip to content

Commit

Permalink
Sync from GPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Omico committed Nov 4, 2024
1 parent 147da9f commit c6cf8c4
Show file tree
Hide file tree
Showing 32 changed files with 208 additions and 95 deletions.
41 changes: 40 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
* text eol=lf
* text=auto eol=lf

*.gradle text diff=java
*.gradle.kts text diff=kotlin
*.groovy text diff=java
*.htm text diff=html
*.html text diff=html
*.java text diff=java
*.json text diff=json
*.kt text diff=kotlin
*.md text diff=markdown
*.properties text
*.scala text diff=java
*.xml text
*.yml text
.gitattributes text
.gitignore text
LICENSE text
consumer-rules.pro text
gradlew text
proguard-rules.pro text
yarn.lock text

*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

*.class binary
*.dll binary
*.gif binary
*.ico binary
*.jar binary
*.jks binary
*.jpeg binary
*.jpg binary
*.png binary
*.so binary
*.tif binary
*.tiff binary
*.traineddata binary
*.webp binary
*.keystore binary
9 changes: 3 additions & 6 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ on:

concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: false
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
gradle-build:
name: Gradle Build
runs-on: ubuntu-latest
env:
DEPENDENCY_GRAPH_EXCLUDE_PROJECTS: ':(gradm|initialization|project)'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -32,9 +30,8 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
validate-wrappers: true
dependency-graph: generate-and-upload
dependency-graph-exclude-projects: ':(gradm|initialization|project)'

- run: ./gradlew build --no-daemon --stacktrace

Expand All @@ -47,7 +44,7 @@ jobs:
gradle-submit-dependency-graph:
name: Gradle Submit Dependency Graph
uses: OmicoDev/gradle-project-initializer-template/.github/workflows/gradle-submit-dependency-graph.yml@main
if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: gradle-build
permissions:
contents: write
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/local.properties

!/.idea/detekt.xml
!/.idea/jsonSchemas.xml
26 changes: 11 additions & 15 deletions build-logic/gradm/gradm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ versions:
datastore: "1.1.1"
lifecycle: "2.8.2"
navigation: "2.8.0-beta03"
consensus: "0.9.0"
gradle: "8.8"
consensus: "0.15.0"
desugarJdkLibs: "2.1.2"
gradle: "8.10.2"
hiddenApiBypass: "4.3"
kotlin: "2.0.0"
kotlin.coroutines: "1.8.1"
material: "1.13.0-alpha03"
okhttp: "5.0.0-alpha.10"
plugins:
android: "8.5.0"
develocity: "3.17.5"
android: "8.7.2"
develocity: "3.18.1"
spotless: "7.0.0.BETA1"
shizuku: "13.1.5"

Expand All @@ -34,16 +35,7 @@ plugins:
com.diffplug.spotless: ${versions.plugins.spotless}
com.gradle.develocity: ${versions.plugins.develocity}
noUpdates:
com.android.application: ${versions.plugins.android}
com.android.library: ${versions.plugins.android}
org.jetbrains.kotlin.android: ${versions.kotlin}
org.jetbrains.kotlin.jvm: ${versions.kotlin}
org.jetbrains.kotlin.plugin.compose: ${versions.kotlin}
omico:
me.omico.consensus.api: ${versions.consensus}
me.omico.consensus.git: ${versions.consensus}
me.omico.consensus.publishing: ${versions.consensus}
me.omico.consensus.spotless: ${versions.consensus}

dependencies:
google:
Expand Down Expand Up @@ -99,6 +91,10 @@ dependencies:
navigation-compose:
alias: androidx.navigation.compose
version: ${versions.androidx.navigation}
com.android.tools:
desugar_jdk_libs_nio:
alias: desugarJdkLibs.nio
version: ${versions.desugarJdkLibs}
com.android.tools.build:
gradle:
alias: androidGradlePlugin
Expand Down Expand Up @@ -136,6 +132,6 @@ dependencies:
version: ${versions.hiddenApiBypass}
omico:
me.omico.consensus:
consensus-dsl:
alias: me.omico.consensus.dsl
consensus-gradle-plugins:
alias: consensusGradlePlugins
version: ${versions.consensus}
2 changes: 1 addition & 1 deletion build-logic/gradm/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "ca-gradm"
rootProject.name = "ca-build-logic-gradm"

pluginManagement {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion build-logic/initialization/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "ca-initialization"
rootProject.name = "ca-build-logic-initialization"

pluginManagement {
includeBuild("../gradm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ develocity {
val isOffline = providers.provider { gradle.startParameter.isOffline }
onlyIf { !isOffline.getOrElse(false) }
}
obfuscation {
val isCi = providers.environmentVariable("CI").getOrElse("false").toBooleanStrict()
if (isCi) return@obfuscation
username { "hidden" }
hostname { "hidden" }
ipAddresses { listOf("0.0.0.0") }
externalProcessName { "non-build-process" }
}
}
}
5 changes: 1 addition & 4 deletions build-logic/project/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ plugins {
dependencies {
implementation(androidGradlePlugin)
implementation(com.diffplug.spotless)
implementation(consensusGradlePlugins)
implementation(gradmGeneratedJar)
implementation(kotlinGradlePlugin)
implementation(me.omico.consensus.api)
implementation(me.omico.consensus.dsl)
implementation(me.omico.consensus.git)
implementation(me.omico.consensus.spotless)
implementation(org.jetbrains.kotlin.plugin.compose)
}
2 changes: 1 addition & 1 deletion build-logic/project/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "ca-project"
rootProject.name = "ca-build-logic-project"

pluginManagement {
includeBuild("../gradm")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
import me.omico.consensus.root.consensusRootProjectConfiguration
import me.omico.gradle.project.PROJECT_JAVA_VERSION

plugins {
kotlin("android")
id("com.android.application")
id("ca.android.base")
id("ca.android.compose")
}

android {
defaultConfig {
versionCode = version.toString().replace(".", "").toInt()
versionName = version.toString()
versionCode = consensusRootProjectConfiguration.versionCode
versionName = consensusRootProjectConfiguration.versionName
}
buildFeatures {
buildConfig = true
}
kotlinOptions {
jvmTarget = "11"
jvmTarget = PROJECT_JAVA_VERSION.toString()
}
buildTypes {
release {
@Suppress("UnstableApiUsage")
vcsInfo.include = false
}
}
}

androidComponents {
onVariants(selector().withBuildType("release")) { variant ->
variant.packaging.resources.excludes.addAll(
"DebugProbesKt.bin",
"META-INF/*.version",
"kotlin-tooling-metadata.json",
)
}
}
18 changes: 15 additions & 3 deletions build-logic/project/src/main/kotlin/ca.android.base.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import me.omico.gradle.project.configureCommonAndroid
import me.omico.gradle.project.configureAndroidCommonExtension
import me.omico.gradm.dependency.DesugarJdkLibs

plugins {
id("com.android.base")
}

configureCommonAndroid(
compileSdk = 34,
// Android 11+
configureAndroidCommonExtension(
domain = "me.omico",
compileSdk = 35,
minSdk = 30,
namespace = "me.omico.${
name
.replace("-", ".")
.replace("ca", "currentactivity")
.removeSuffix(".app")
}",
coreLibraryDesugaringDependency = DesugarJdkLibs.nio,
)

plugins.withId("org.jetbrains.kotlin.plugin.compose") {
configureAndroidCommonExtension {
buildFeatures {
compose = true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ plugins {
id("com.android.library")
id("ca.android.base")
}

android {
kotlinOptions {
jvmTarget = "11"
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import me.omico.gradle.project.configureCommonAndroidCompose

plugins {
id("com.android.base")
kotlin("plugin.compose")
}

configureCommonAndroidCompose()

composeCompiler {
metricsDestination = file("build/composeMetrics")
reportsDestination = file("build/composeReports")
Expand Down
28 changes: 22 additions & 6 deletions build-logic/project/src/main/kotlin/ca.root.git.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import me.omico.consensus.dsl.requireRootProject
import me.omico.consensus.api.dsl.requireRootProject

plugins {
id("me.omico.consensus.git")
Expand All @@ -12,12 +12,28 @@ consensus {
preCommit {
appendLine("#!/bin/sh")
appendLine()
if (file("gradlew").exists()) {
appendLine("# Give gradlew execute permission")
appendLine("git ls-files \"*gradlew\" | xargs git update-index --add --chmod=+x")
appendLine()
}
correctGradleWrapperScriptPermissions()
appendLine()
checkGitAttributes()
appendLine()
}
}
}
}

fun StringBuilder.correctGradleWrapperScriptPermissions() {
if (!file("gradlew").exists()) return
appendLine("# Give gradlew execute permission")
appendLine("git ls-files \"*gradlew\" | xargs git update-index --add --chmod=+x")
}

fun StringBuilder.checkGitAttributes() {
if (!file(".gitattributes").exists()) return
appendLine("# Check for missing attributes")
appendLine("missing_attributes=\$(git ls-files | git check-attr -a --stdin | grep 'text: auto' || printf '\\n')")
appendLine("if [ -n \"\$missing_attributes\" ]; then")
appendLine(" echo 'Some files are missing the text attribute. Please add the following to .gitattributes:'")
appendLine(" echo \"\$missing_attributes\" | sed 's/: text: auto//g' | sed 's/^/ /'")
appendLine(" exit 1")
appendLine("fi")
}
14 changes: 2 additions & 12 deletions build-logic/project/src/main/kotlin/ca.root.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import me.omico.consensus.dsl.requireRootProject

plugins {
id("me.omico.consensus.root")
id("ca.gradm")
id("ca.root.git")
id("ca.root.spotless")
}

requireRootProject()

consensus {
allprojects {
group = gradleProperty("project.group")
version = gradleProperty("project.version")
}
}

val wrapper: Wrapper by tasks.named<Wrapper>("wrapper") {
tasks.named<Wrapper>("wrapper") {
gradleVersion = versions.gradle
distributionType = Wrapper.DistributionType.BIN
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import me.omico.consensus.dsl.requireRootProject
import me.omico.consensus.api.dsl.requireRootProject
import me.omico.consensus.spotless.ConsensusSpotlessTokens

plugins {
Expand All @@ -18,7 +18,7 @@ consensus {
targets = ConsensusSpotlessTokens.Kotlin.targets + setOf(
"build-logic/**/src/main/kotlin/**/*.kt",
),
licenseHeaderFile = rootProject.file("spotless/copyright.kt"),
licenseHeaderFile = rootProject.file("spotless/copyright.kt").takeIf(File::exists),
)
kotlinGradle()
}
Expand Down
Loading

0 comments on commit c6cf8c4

Please sign in to comment.