Skip to content

Commit 4e7c184

Browse files
committed
Create a common gradle files
1 parent 13aa577 commit 4e7c184

File tree

10 files changed

+267
-371
lines changed

10 files changed

+267
-371
lines changed

buildSrc/build-dependencies.gradle.kts

-40
This file was deleted.

buildSrc/build.gradle.kts

+23-24
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,29 @@ kotlinDslPluginOptions {
3333
experimentalWarning.set(false)
3434
}
3535

36-
apply(from = "build-dependencies.gradle.kts")
37-
38-
val gradleAndroid: String by extra
39-
val gradleVersions: String by extra
40-
val kotlin: String by extra
41-
val kotlinAllOpen: String by extra
42-
val navigation: String by extra
43-
val jacoco: String by extra
44-
val fabric: String by extra
45-
val dokka: String by extra
46-
val ktlint: String by extra
47-
val detekt: String by extra
48-
val spotless: String by extra
36+
object PluginsVersions {
37+
const val GRADLE_ANDROID = "3.5.1"
38+
const val GRADLE_VERSIONS = "0.22.0"
39+
const val KOTLIN = "1.3.50"
40+
const val NAVIGATION = "2.1.0-beta02"
41+
const val JACOCO = "0.15.0"
42+
const val FABRIC = "1.31.0"
43+
const val DOKKA = "0.9.18"
44+
const val KTLINT = "0.34.2"
45+
const val SPOTLESS = "3.24.1"
46+
const val DETEKT = "1.0.1"
47+
}
4948

5049
dependencies {
51-
implementation(gradleAndroid)
52-
implementation(gradleVersions)
53-
implementation(kotlin)
54-
implementation(kotlinAllOpen)
55-
implementation(navigation)
56-
implementation(jacoco)
57-
implementation(fabric)
58-
implementation(dokka)
59-
implementation(ktlint)
60-
implementation(detekt)
61-
implementation(spotless)
50+
implementation("com.android.tools.build:gradle:${PluginsVersions.GRADLE_ANDROID}")
51+
implementation("com.github.ben-manes:gradle-versions-plugin:${PluginsVersions.GRADLE_VERSIONS}")
52+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${PluginsVersions.KOTLIN}")
53+
implementation("org.jetbrains.kotlin:kotlin-allopen:${PluginsVersions.KOTLIN}")
54+
implementation("androidx.navigation:navigation-safe-args-gradle-plugin:${PluginsVersions.NAVIGATION}")
55+
implementation("com.vanniktech:gradle-android-junit-jacoco-plugin:${PluginsVersions.JACOCO}")
56+
implementation("io.fabric.tools:gradle:${PluginsVersions.FABRIC}")
57+
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${PluginsVersions.DOKKA}")
58+
implementation("com.pinterest:ktlint:${PluginsVersions.KTLINT}")
59+
implementation("com.diffplug.spotless:spotless-plugin-gradle:${PluginsVersions.SPOTLESS}")
60+
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${PluginsVersions.DETEKT}")
6261
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright 2019 vmadalin.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package commons
18+
19+
import BuildAndroidConfig
20+
import BuildProductDimensions
21+
import ProductFlavorDevelop
22+
import ProductFlavorProduction
23+
import ProductFlavorQA
24+
import dependencies.Dependencies
25+
import dependencies.AnnotationProcessorsDependencies
26+
import extensions.addTestsDependencies
27+
import extensions.implementation
28+
import extensions.kapt
29+
30+
plugins {
31+
id("com.android.dynamic-feature")
32+
id("kotlin-android")
33+
id("kotlin-android-extensions")
34+
id("kotlin-kapt")
35+
id("kotlin-allopen")
36+
id("androidx.navigation.safeargs.kotlin")
37+
}
38+
39+
android {
40+
compileSdkVersion(BuildAndroidConfig.COMPILE_SDK_VERSION)
41+
42+
defaultConfig {
43+
minSdkVersion(BuildAndroidConfig.MIN_SDK_VERSION)
44+
targetSdkVersion(BuildAndroidConfig.TARGET_SDK_VERSION)
45+
}
46+
47+
compileOptions {
48+
sourceCompatibility = JavaVersion.VERSION_1_8
49+
targetCompatibility = JavaVersion.VERSION_1_8
50+
}
51+
52+
kotlinOptions {
53+
jvmTarget = JavaVersion.VERSION_1_8.toString()
54+
}
55+
56+
dataBinding {
57+
isEnabled = true
58+
}
59+
60+
androidExtensions {
61+
isExperimental = true
62+
}
63+
64+
flavorDimensions(BuildProductDimensions.ENVIRONMENT)
65+
productFlavors {
66+
ProductFlavorDevelop.libraryCreate(this)
67+
ProductFlavorQA.libraryCreate(this)
68+
ProductFlavorProduction.libraryCreate(this)
69+
}
70+
71+
sourceSets {
72+
getByName("main") {
73+
java.srcDir("src/main/kotlin")
74+
}
75+
getByName("test") {
76+
java.srcDir("src/test/kotlin")
77+
}
78+
}
79+
80+
lintOptions {
81+
lintConfig = rootProject.file(".lint/config.xml")
82+
isCheckAllWarnings = true
83+
isWarningsAsErrors = true
84+
}
85+
}
86+
87+
dependencies {
88+
implementation(project(BuildModules.APP))
89+
implementation(project(BuildModules.CORE))
90+
91+
implementation(Dependencies.KOTLIN)
92+
implementation(Dependencies.APPCOMPAT)
93+
implementation(Dependencies.COROUTINES)
94+
implementation(Dependencies.COROUTINES_ANDROID)
95+
implementation(Dependencies.NAVIGATION_FRAGMENT)
96+
implementation(Dependencies.NAVIGATION_UI)
97+
implementation(Dependencies.LIFECYCLE_EXTENSIONS)
98+
implementation(Dependencies.LIFECYCLE_VIEWMODEL)
99+
implementation(Dependencies.CORE_KTX)
100+
implementation(Dependencies.FRAGMENT_KTX)
101+
implementation(Dependencies.CONSTRAIN_LAYOUT)
102+
implementation(Dependencies.DAGGER)
103+
implementation(Dependencies.TIMBER)
104+
implementation(Dependencies.LOGGING)
105+
implementation(Dependencies.GLIDE)
106+
107+
kapt(AnnotationProcessorsDependencies.DAGGER)
108+
kapt(AnnotationProcessorsDependencies.DATABINDING)
109+
kapt(AnnotationProcessorsDependencies.GLIDE)
110+
kapt(AnnotationProcessorsDependencies.ROOM)
111+
112+
addTestsDependencies()
113+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright 2019 vmadalin.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package commons
18+
19+
import BuildAndroidConfig
20+
import BuildProductDimensions
21+
import ProductFlavorDevelop
22+
import ProductFlavorProduction
23+
import ProductFlavorQA
24+
import dependencies.Dependencies
25+
import dependencies.AnnotationProcessorsDependencies
26+
import extensions.addTestsDependencies
27+
import extensions.implementation
28+
import extensions.kapt
29+
30+
plugins {
31+
id("com.android.library")
32+
id("kotlin-android")
33+
id("kotlin-android-extensions")
34+
id("kotlin-kapt")
35+
id("kotlin-allopen")
36+
}
37+
38+
android {
39+
compileSdkVersion(BuildAndroidConfig.COMPILE_SDK_VERSION)
40+
41+
defaultConfig {
42+
minSdkVersion(BuildAndroidConfig.MIN_SDK_VERSION)
43+
targetSdkVersion(BuildAndroidConfig.TARGET_SDK_VERSION)
44+
}
45+
46+
compileOptions {
47+
sourceCompatibility = JavaVersion.VERSION_1_8
48+
targetCompatibility = JavaVersion.VERSION_1_8
49+
}
50+
51+
kotlinOptions {
52+
jvmTarget = JavaVersion.VERSION_1_8.toString()
53+
}
54+
55+
dataBinding {
56+
isEnabled = true
57+
}
58+
59+
androidExtensions {
60+
isExperimental = true
61+
}
62+
63+
flavorDimensions(BuildProductDimensions.ENVIRONMENT)
64+
productFlavors {
65+
ProductFlavorDevelop.libraryCreate(this)
66+
ProductFlavorQA.libraryCreate(this)
67+
ProductFlavorProduction.libraryCreate(this)
68+
}
69+
70+
sourceSets {
71+
getByName("main") {
72+
java.srcDir("src/main/kotlin")
73+
}
74+
getByName("test") {
75+
java.srcDir("src/test/kotlin")
76+
}
77+
}
78+
}
79+
80+
dependencies {
81+
implementation(Dependencies.KOTLIN)
82+
implementation(Dependencies.COROUTINES)
83+
implementation(Dependencies.COROUTINES_ANDROID)
84+
implementation(Dependencies.DAGGER)
85+
implementation(Dependencies.TIMBER)
86+
87+
kapt(AnnotationProcessorsDependencies.DAGGER)
88+
89+
addTestsDependencies()
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2019 vmadalin.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package commons
18+
19+
import dependencies.Dependencies
20+
import extensions.implementation
21+
22+
plugins {
23+
id("kotlin")
24+
}
25+
26+
dependencies {
27+
implementation(Dependencies.KOTLIN)
28+
}

buildSrc/src/main/kotlin/plugins/spotless.gradle.kts

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ configure<SpotlessExtension> {
7070
}
7171

7272
kotlinGradle {
73-
target("**/*.gradle.kts", "*.gradle.kts")
73+
target(
74+
fileTree(
75+
mapOf(
76+
"dir" to ".",
77+
"include" to listOf("**/*.gradle.kts", "*.gradle.kts"),
78+
"exclude" to listOf("**/build/**")
79+
)
80+
)
81+
)
7482
licenseHeaderFile(
7583
rootProject.file("COPYRIGHT"),
7684
"package|import|tasks|apply|plugins|include|val|object|interface"

0 commit comments

Comments
 (0)