forked from cashapp/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
195 lines (178 loc) · 5.42 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
buildscript {
dependencies {
classpath libs.kotlin.gradlePlugin
classpath libs.kotlin.serializationPlugin
classpath libs.androidGradlePlugin
classpath libs.gradleMavenPublishPlugin
classpath libs.dokkaPlugin
classpath libs.spotlessPlugin
classpath libs.buildConfigPlugin
classpath libs.zipline.gradlePlugin
classpath libs.paparazzi.gradlePlugin
classpath 'app.cash.redwood.build:gradle-plugin'
classpath 'app.cash.redwood:redwood-gradle-plugin'
}
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
}
apply plugin: 'org.jetbrains.dokka'
allprojects {
repositories {
mavenCentral()
google()
}
tasks.withType(AbstractTestTask).configureEach {
testLogging {
if (System.getenv("CI") == "true") {
events = ["failed", "skipped", "passed"]
}
exceptionFormat "full"
}
// Force tests to always run to avoid caching issues.
outputs.upToDateWhen { false }
}
plugins.withId('java-base') {
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
if (project.path.startsWith(':redwood-')) {
plugins.withId('org.jetbrains.kotlin.jvm') {
kotlin {
explicitApi()
}
}
plugins.withId('org.jetbrains.kotlin.multiplatform') {
kotlin {
explicitApi()
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile).configureEach { task ->
// Only enable strict mode for non-test sources.
if (!task.name.toLowerCase().contains('test')) {
task.kotlinOptions {
freeCompilerArgs += '-Xexplicit-api=strict'
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile).configureEach { task ->
task.kotlinOptions {
freeCompilerArgs += [
'-progressive', // https://kotlinlang.org/docs/whatsnew13.html#progressive-mode
]
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile).configureEach { task ->
task.kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += [
'-Xjvm-default=all',
]
}
}
// Disable the release linking tasks because we never need it for iOS sample applications.
// TODO Switch to https://youtrack.jetbrains.com/issue/KT-54424 when it is supported.
plugins.withId('org.jetbrains.kotlin.multiplatform') {
kotlin {
targets.withType(KotlinNativeTarget) {
binaries.all {
if (it.buildType == NativeBuildType.RELEASE) {
it.linkTask.enabled = false
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask).configureEach {
if (it.name.contains("Release")) {
it.enabled = false
}
}
}
plugins.withType(com.android.build.gradle.BasePlugin).configureEach {
project.android {
compileSdk 32
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdk 21
targetSdk 30
}
lint {
checkDependencies true
checkReleaseBuilds false // Full lint runs as part of 'build' task.
}
}
android.composeOptions {
kotlinCompilerExtensionVersion libs.versions.androidxComposeCompiler.get()
}
}
// Disable the release build type because we never need it for sample applications.
plugins.withId('com.android.application') {
project.android {
variantFilter { variant ->
if (variant.buildType.name == 'release') {
variant.ignore = true
}
}
}
}
plugins.withId('com.vanniktech.maven.publish.base') {
group = project.property("GROUP") as String
version = project.property("VERSION_NAME") as String
publishing {
repositories {
maven {
name = "LocalMaven"
url = file("${rootProject.buildDir}/localMaven").toURI().toString()
}
/**
* Want to push to an internal repository for testing?
* Set the following properties in ~/.gradle/gradle.properties.
*
* internalUrl=YOUR_INTERNAL_URL
* internalUsername=YOUR_USERNAME
* internalPassword=YOUR_PASSWORD
*
* Then run the following command to publish a new internal release:
*
* ./gradlew publishAllPublicationsToInternalRepository
*/
def internalUrl = providers.gradleProperty("internalUrl")
if (internalUrl.isPresent()) {
maven {
name = "internal"
url = providers.gradleProperty("internalUrl")
credentials(PasswordCredentials)
}
}
}
}
}
apply plugin: 'com.diffplug.spotless'
spotless {
kotlin {
target("src/*/kotlin/**/*.kt")
licenseHeaderFile(rootProject.file('gradle/license-header.txt'))
// Spotless doesn't read .editorconfig yet: https://github.com/diffplug/spotless/issues/142
ktlint('0.46.1').editorConfigOverride([
'disabled_rules': 'filename',
'insert_final_newline': 'true',
'end_of_line': 'lf',
'charset': 'utf-8',
'indent_size': '2',
'ij_kotlin_allow_trailing_comma': 'true',
'ij_kotlin_allow_trailing_comma_on_call_site': 'true',
'ij_kotlin_imports_layout': '*',
])
}
}
}