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

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

android {
    compileSdkVersion ANDROID_COMPILE_SDK

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

Daniel Wolf's avatar
Daniel Wolf committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    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
42
43
44
45
46
47
48
49
50
51
    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'
    }
52
53
    compileOptions {
        kotlinOptions.freeCompilerArgs += ['-module-name', "$libraryGroupId.$libraryArtifactId"]
Daniel Wolf's avatar
Daniel Wolf committed
54
    }
Daniel Wolf's avatar
Daniel Wolf committed
55
56
}

57
58
59
60
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
61
62
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
63
    implementation "androidx.appcompat:appcompat:$APPCOMPAT_VERSION"
Daniel Wolf's avatar
Daniel Wolf committed
64

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

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

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

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
    outputFormat = 'javadoc'
    outputDirectory = "$buildDir/javadoc"
}

task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
    classifier = 'javadoc'
    from "$buildDir/javadoc"
}

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
afterEvaluate {
    publishing {
        publications {
            aar(MavenPublication) {
                groupId libraryGroupId
                version libraryVersion
                artifactId libraryArtifactId

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

109
110
111
112
113
114
115
116
117
118
                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
119
120
121
122
                    }
                }
            }
        }
123
124
125
126
127
        repositories {
            maven {
                name 'nexus'
                url "https://nexus.frostnerd.com/repository/libs-release/"
                credentials {
Daniel Wolf's avatar
Daniel Wolf committed
128
129
                    username nexus_user
                    password nexus_password
130
                }}
Daniel Wolf's avatar
Daniel Wolf committed
131
132
133
        }
    }
}
134
publish.dependsOn("assembleRelease", "sourcesJar", "javadocJar")