|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 |
| -import net.ltgt.gradle.errorprone.CheckSeverity |
17 |
| -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
18 |
| - |
19 |
| - |
20 |
| - |
21 |
| -buildscript { |
22 |
| - apply from: rootProject.file('gradle/dependencies.gradle') |
23 |
| - repositories { |
24 |
| - google() |
25 |
| - mavenCentral() |
26 |
| - gradlePluginPortal() |
27 |
| - } |
28 |
| - dependencies { |
29 |
| - classpath deps.build.gradlePlugins.android |
30 |
| - classpath deps.build.gradlePlugins.errorprone |
31 |
| - classpath deps.build.gradlePlugins.kotlin |
32 |
| - classpath deps.build.gradlePlugins.spotless |
33 |
| - classpath deps.build.gradlePlugins.gradleMavenPublish |
34 |
| - } |
| 16 | +plugins { |
| 17 | + alias(libs.plugins.androidApplication) apply false |
| 18 | + alias(libs.plugins.androidLibrary) apply false |
| 19 | + alias(libs.plugins.kotlinAndroid) apply false |
| 20 | + alias(libs.plugins.kotlinKapt) apply false |
| 21 | + alias(libs.plugins.mavenPublish) apply false |
| 22 | + alias(libs.plugins.errorprone) apply false |
| 23 | + alias(libs.plugins.nullaway) apply false |
| 24 | + alias(libs.plugins.intellij) apply false |
| 25 | + alias(libs.plugins.spotless) apply false |
35 | 26 | }
|
36 |
| - |
37 |
| -Set<String> useErrorProneProjects = [ |
38 |
| - "memory-leaks", |
39 |
| - "tutorial1", |
40 |
| - "tutorial2" |
41 |
| -] |
42 |
| - |
43 |
| -def moduleFriends = [ |
44 |
| - 'rib-android': 'rib-base', |
45 |
| - 'rib-debug-utils': 'rib-base', |
46 |
| - 'rib-router-navigator': 'rib-base', |
47 |
| - 'rib-test': 'rib-base', |
48 |
| - 'rib-workflow-test': 'rib-workflow', |
49 |
| - 'rib-coroutines-test': 'rib-coroutines' |
50 |
| -] |
51 |
| - |
52 |
| -subprojects { |
53 |
| - buildscript { |
54 |
| - repositories { |
55 |
| - google() |
56 |
| - mavenCentral() |
57 |
| - gradlePluginPortal() |
58 |
| - } |
59 |
| - } |
60 |
| - |
61 |
| - repositories { |
62 |
| - google() |
63 |
| - mavenCentral() |
64 |
| - } |
65 |
| - |
66 |
| - apply plugin: 'com.diffplug.spotless' |
67 |
| - spotless { |
68 |
| - format 'misc', { |
69 |
| - target '**/*.md', '**/.gitignore' |
70 |
| - |
71 |
| - trimTrailingWhitespace() |
72 |
| - endWithNewline() |
73 |
| - } |
74 |
| - kotlin { |
75 |
| - target "**/*.kt" |
76 |
| - ktlint(deps.versions.ktlint).editorConfigOverride(['indent_size': '2', 'continuation_indent_size' : '4']) |
77 |
| - ktfmt(deps.versions.ktfmt).googleStyle() |
78 |
| - licenseHeaderFile rootProject.file('config/spotless/copyright.kt') |
79 |
| - trimTrailingWhitespace() |
80 |
| - endWithNewline() |
81 |
| - } |
82 |
| - java { |
83 |
| - target "src/*/java/**/*.java" |
84 |
| - googleJavaFormat(deps.versions.gjf) |
85 |
| - licenseHeaderFile rootProject.file('config/spotless/copyright.java') |
86 |
| - removeUnusedImports() |
87 |
| - trimTrailingWhitespace() |
88 |
| - endWithNewline() |
89 |
| - } |
90 |
| - groovyGradle { |
91 |
| - target '**/*.gradle' |
92 |
| - trimTrailingWhitespace() |
93 |
| - endWithNewline() |
94 |
| - } |
95 |
| - } |
96 |
| - |
97 |
| - afterEvaluate { |
98 |
| - boolean isAndroidApp = project.plugins.hasPlugin("com.android.application") |
99 |
| - boolean isAndroidLibrary = project.plugins.hasPlugin("com.android.library") |
100 |
| - boolean isIntelliJPlugin = project.plugins.hasPlugin("com.android.library") |
101 |
| - boolean usesErrorProne = project.name in useErrorProneProjects |
102 |
| - boolean isKotlinLibrary = project.plugins.hasPlugin("org.jetbrains.kotlin.jvm") || project.plugins.hasPlugin("org.jetbrains.kotlin.android") |
103 |
| - |
104 |
| - if ((isAndroidLibrary || isAndroidApp) && usesErrorProne) { |
105 |
| - def configurer = { variant -> |
106 |
| - variant.getJavaCompileProvider().configure { |
107 |
| - options.errorprone.nullaway { |
108 |
| - severity = CheckSeverity.ERROR |
109 |
| - annotatedPackages.add("com.uber") |
110 |
| - } |
111 |
| - options.errorprone.excludedPaths = ".*/build/generated/.*" |
112 |
| - } |
113 |
| - } |
114 |
| - if (isAndroidLibrary) { |
115 |
| - project.android.libraryVariants.configureEach(configurer) |
116 |
| - } |
117 |
| - if (isAndroidApp) { |
118 |
| - project.android.applicationVariants.configureEach(configurer) |
119 |
| - } |
120 |
| - project.android.testVariants.configureEach(configurer) |
121 |
| - project.android.unitTestVariants.configureEach(configurer) |
122 |
| - } |
123 |
| - if (isAndroidLibrary || isAndroidApp) { |
124 |
| - // TODO replace with https://issuetracker.google.com/issues/72050365 once released. |
125 |
| - project.android { |
126 |
| - if (isAndroidLibrary) { |
127 |
| - variantFilter { variant -> |
128 |
| - if (variant.buildType.name == 'debug') { |
129 |
| - variant.setIgnore(true) |
130 |
| - } |
131 |
| - } |
132 |
| - } |
133 |
| - if (isAndroidApp) { |
134 |
| - buildTypes { |
135 |
| - debug { |
136 |
| - matchingFallbacks = ['release'] |
137 |
| - } |
138 |
| - } |
139 |
| - variantFilter { variant -> |
140 |
| - if (variant.buildType.name == "release") { |
141 |
| - variant.setIgnore(true) |
142 |
| - } |
143 |
| - } |
144 |
| - } |
145 |
| - } |
146 |
| - } |
147 |
| - |
148 |
| - if (isKotlinLibrary) { |
149 |
| - def extraCompilerArgs = [ |
150 |
| - // See https://github.com/bazelbuild/bazel/issues/15144 |
151 |
| - "-Xjvm-default=enable", |
152 |
| - "-opt-in=kotlin.RequiresOptIn", |
153 |
| - ] |
154 |
| - if (project.name in moduleFriends.keySet()) { |
155 |
| - def friendName = moduleFriends[project.name] |
156 |
| - def friendProject = rootProject.subprojects.stream().filter { it.name == friendName }.findFirst().get() |
157 |
| - def outputJarPath = friendProject.plugins.hasPlugin("com.android.library") |
158 |
| - ? "build/intermediates/compile_library_classes_jar/release/classes.jar" |
159 |
| - : "build/libs/$friendName-${project.property('VERSION_NAME')}.jar" |
160 |
| - def friendPath="${project.rootDir}/libraries/${moduleFriends[project.name]}/$outputJarPath" |
161 |
| - extraCompilerArgs.add("-Xfriend-paths=$friendPath") |
162 |
| - } |
163 |
| - if (isAndroidLibrary || isAndroidApp) { |
164 |
| - project.android.sourceSets { |
165 |
| - main.java.srcDirs += 'src/main/kotlin' |
166 |
| - test.java.srcDirs += 'src/test/kotlin' |
167 |
| - androidTest.java.srcDirs += 'src/androidTest/kotlin' |
168 |
| - } |
169 |
| - |
170 |
| - tasks.withType(KotlinCompile).configureEach { |
171 |
| - kotlinOptions { |
172 |
| - freeCompilerArgs = extraCompilerArgs |
173 |
| - jvmTarget = "11" |
174 |
| - } |
175 |
| - } |
176 |
| - } else if(!isIntelliJPlugin) { |
177 |
| - project.compileKotlin { |
178 |
| - kotlinOptions { |
179 |
| - freeCompilerArgs = extraCompilerArgs |
180 |
| - jvmTarget = "11" |
181 |
| - } |
182 |
| - } |
183 |
| - project.compileTestKotlin { |
184 |
| - kotlinOptions { |
185 |
| - freeCompilerArgs = extraCompilerArgs |
186 |
| - jvmTarget = "11" |
187 |
| - } |
188 |
| - } |
189 |
| - } |
190 |
| - } |
191 |
| - } |
192 |
| -} |
193 |
| - |
194 |
| -tasks.register('clean', Delete) { |
195 |
| - delete rootProject.buildDir |
196 |
| -} |
197 |
| - |
198 |
| -apply from: rootProject.file('gradle/japicmp.gradle') |
0 commit comments