Skip to content

Commit

Permalink
build: restructure widget modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tynn committed Jan 11, 2024
1 parent 770ad81 commit 5feaa33
Show file tree
Hide file tree
Showing 67 changed files with 115 additions and 112 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ result of the recovered `AString` is equal to the original result.

## License

Copyright (C) 2020-2023 Christian Schmitz
Copyright (C) 2020-2024 Christian Schmitz

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
107 changes: 107 additions & 0 deletions binding/adapters/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import com.android.build.api.attributes.ProductFlavorAttr

plugins {
alias libs.plugins.android
alias libs.plugins.kotlin.kapt
}

android {
namespace "${group}.binding.adapters"

buildFeatures {
androidResources true
dataBinding true
}

buildTypes {
databinding {
matchingFallbacks = ['release']
}
}

flavorDimensions += 'source'

variantFilter {
ignore = buildType.name != 'databinding'
}
}

final extension = project(':extension')
extension.evaluationDependsOnChildren()

final adapters = project
extension.subprojects {
if (android.buildFeatures.dataBinding) return

adapters.android {
productFlavors.register name
sourceSets.named(name) {
root "$projectDir/src/main"
}
}

final adaptersApi = "${name}Api"
configurations {
api.dependencies.configureEach {
try {
adapters.dependencies.add adaptersApi, it
} catch (ignored) {
}
}

databinding {
transitive false
canBeResolved true
canBeConsumed false

attributes.attribute ProductFlavorAttr.of('source'),
objects.named(ProductFlavorAttr, project.name)
}
}

dependencies {
databinding adapters
}

final androidDatabinding = tasks.register('androidDatabinding', Copy) {
into layout.buildDirectory.dir("intermediates/data_binding_artifact/$name")
from configurations.databinding.incoming.artifactView {
attributes {
attribute ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, 'android-databinding'
}
}.files
include '**/*.json'
}

android.libraryVariants.configureEach {
packageLibraryProvider.configure {
from androidDatabinding, {
eachFile {
relativePath = relativePath.prepend 'data-binding'
}
}
}

configurations.matching {
it.name =~ /^$name(Api|Runtime)Elements$/
}.configureEach {
outgoing.variants {
add 'android-databinding' {
artifact androidDatabinding, {
type 'android-databinding'
}
}
}
}
}
}

afterEvaluate {
final emptyTasks = ['assemble', 'build', 'check', 'lint', 'test']
tasks.matching {
it.name in emptyTasks
}.configureEach {
enabled false
dependsOn.clear()
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
api project(':widget:core')
api project(':extension:core')
api libs.androidx.appcompat

compileOnly libs.androidx.databinding.common
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
}

dependencies {
api project(':widget:appcompat')
api project(':extension:appcompat')
api libs.google.material

compileOnly libs.androidx.databinding.common
Expand Down
2 changes: 1 addition & 1 deletion gradle/convention/src/integration-test.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
['check', 'connectedCheck'].each {
['check', 'connectedCheck', 'lint'].each {
tasks.named(it) { task ->
final path = ":${project.name}:${task.name}"
dependsOn gradle.includedBuild('integration').task(path)
Expand Down
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ dependencyResolutionManagement {
include ':astring:bom'
include ':astring:catalog'

include ':binding:adapters'
include ':compose'

include ':widget:core'
include ':widget:appcompat'
include ':widget:material'
include ':widget:binding:adapters'
include ':extension:core'
include ':extension:appcompat'
include ':extension:material'

includeBuild 'integration'

Expand Down
104 changes: 0 additions & 104 deletions widget/binding/adapters/build.gradle

This file was deleted.

0 comments on commit 5feaa33

Please sign in to comment.