build.gradle 3.92 KB
Newer Older
Daniel Wolf's avatar
Daniel Wolf committed
1
2
3
4
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

5
group = 'com.frostnerd.utilskt'
Daniel Wolf's avatar
Daniel Wolf committed
6
ext {
Daniel Wolf's avatar
Daniel Wolf committed
7
8
    libraryGroupId = group
    libraryArtifactId = rootProject.name
Daniel Wolf's avatar
Daniel Wolf committed
9
    libraryVersion = '3.1.15'
Daniel Wolf's avatar
Daniel Wolf committed
10
}
Daniel Wolf's avatar
Daniel Wolf committed
11
12
13
14

android {
    compileSdkVersion ANDROID_COMPILE_SDK

Daniel Wolf's avatar
Daniel Wolf committed
15
16
17
18
19
20
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        kotlinOptions.jvmTarget = "1.8"
    }

Daniel Wolf's avatar
Daniel Wolf committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    defaultConfig {
        minSdkVersion ANDROID_MIN_SDK
        targetSdkVersion ANDROID_COMPILE_SDK
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            consumerProguardFiles 'library-rules.pro', 'release-rules.pro'
        }
    }
    testOptions {
        unitTests.returnDefaultValues = true
        unitTests {
            includeAndroidResources = true
        }
    }
Daniel Wolf's avatar
Daniel Wolf committed
41
42
43
44
45
46
47
48
49
50
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
51
52
    compileOptions {
        kotlinOptions.freeCompilerArgs += ['-module-name', "$libraryGroupId.$libraryArtifactId"]
Daniel Wolf's avatar
Daniel Wolf committed
53
    }
Daniel Wolf's avatar
Daniel Wolf committed
54
55
}

56
57
58
59
static def compileBinariesLocally() {
    return System.getenv("COMPILE_BINARIES") != null || System.getenv("NEXUS_USER") == null || System.getenv("NEXUS_PASSWORD") == null
}

Daniel Wolf's avatar
Daniel Wolf committed
60
61
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
62
    implementation "androidx.appcompat:appcompat:$APPCOMPAT_VERSION"
Daniel Wolf's avatar
Daniel Wolf committed
63

Daniel Wolf's avatar
Daniel Wolf committed
64
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
65
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$COROUTINE_VERSION"
Daniel Wolf's avatar
Daniel Wolf committed
66

67
    testImplementation 'junit:junit:4.13.1'
Daniel Wolf's avatar
Daniel Wolf committed
68
    //testImplementation "org.robolectric:robolectric:$ROBOELECTRIC_VERSION"
69
70
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Daniel Wolf's avatar
Daniel Wolf committed
71
72
73
74
75
76
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

77
78
79
80
81
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

82
83
84
85
86
87
88
89
90
91
92
93
afterEvaluate {
    publishing {
        publications {
            aar(MavenPublication) {
                groupId libraryGroupId
                version libraryVersion
                artifactId libraryArtifactId

                artifact("$buildDir/outputs/aar/library-release.aar")
                artifact (sourcesJar) {
                    classifier = 'sources'
                }
Daniel Wolf's avatar
Daniel Wolf committed
94

95
96
97
98
99
100
101
102
103
104
                pom.withXml {
                    def dependenciesNode = asNode().appendNode('dependencies')
                    configurations.implementation.allDependencies.each {
                        if(it.group != null && it.name != null && it.version != null &&
                                it.group != "" && it.name != "" && it.version != "" && it.name != "unspecified"){
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', it.group)
                            dependencyNode.appendNode('artifactId', it.name)
                            dependencyNode.appendNode('version', it.version)
                        }
Daniel Wolf's avatar
Daniel Wolf committed
105
106
107
108
                    }
                }
            }
        }
109
110
111
112
113
        repositories {
            maven {
                name 'nexus'
                url "https://nexus.frostnerd.com/repository/libs-release/"
                credentials {
Daniel Wolf's avatar
Daniel Wolf committed
114
115
                    username nexus_user
                    password nexus_password
116
                }}
Daniel Wolf's avatar
Daniel Wolf committed
117
118
119
        }
    }
}
Daniel Wolf's avatar
Daniel Wolf committed
120
publish.dependsOn("assembleRelease", "sourcesJar")