1515 */
1616
1717apply plugin : ' com.android.library'
18- apply plugin : ' signing'
18+ apply plugin : ' kotlin-android'
19+ apply plugin : ' org.jetbrains.dokka-android'
20+ apply plugin : ' jacoco'
1921
20- String getVersionString () {
21- String v = VERSION_NAME . replaceAll(" .(0)\$ " , " ." + buildNumber())
22- v = isTag() ? v : v + " -SNAPSHOT"
23- return v
22+ jacoco {
23+ toolVersion = ' 0.8.0'
2424}
2525
26- group = GROUP
27- version = getVersionString()
28-
26+ tasks . withType( Test ) {
27+ jacoco . includeNoLocationClasses = true
28+ }
2929
30- if (isReleaseBuild()) {
31- status = ' release '
32- } else {
33- status = ' integration '
30+ repositories {
31+ google()
32+ jcenter()
33+ mavenCentral()
3434}
3535
3636android {
3737 compileSdkVersion 27
38- buildToolsVersion " 27.0.3"
39-
38+ buildToolsVersion = " 27.0.3"
4039 defaultConfig {
4140 minSdkVersion 14
4241 targetSdkVersion 27
43- versionCode 1
44- versionName " 1.0"
45- }
46-
47- compileOptions {
48- sourceCompatibility JavaVersion . VERSION_1_7
49- targetCompatibility JavaVersion . VERSION_1_7
42+ testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner"
5043 }
5144 buildTypes {
45+ debug {
46+ testCoverageEnabled true
47+ }
5248 release {
5349 minifyEnabled false
5450 proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
@@ -60,4 +56,81 @@ dependencies {
6056 implementation ' com.android.support:support-v13:27.1.1'
6157}
6258
63- apply from : ' ../maven_push.gradle'
59+ dokka {
60+ noStdlibLink = false
61+ includeNonPublic = false
62+ skipEmptyPackages = true
63+ outputFormat = ' html'
64+ outputDirectory = " $buildDir /javadoc"
65+ }
66+
67+ afterEvaluate { project ->
68+ task dokkaJavadoc(type : org.jetbrains.dokka.gradle.DokkaAndroidTask ) {
69+ outputFormat = ' javadoc'
70+ outputDirectory = " $buildDir /javadoc"
71+ inputs. dir ' src/main/java'
72+ }
73+
74+ task javadocJar(type : Jar , dependsOn : dokkaJavadoc) {
75+ classifier = ' javadoc'
76+ from " $buildDir /javadoc"
77+ }
78+
79+ task sourcesJar(type : Jar ) {
80+ classifier = ' sources'
81+ from android. sourceSets. main. java. srcDirs
82+ }
83+
84+ artifacts {
85+ archives sourcesJar
86+ archives javadocJar
87+ }
88+ }
89+
90+ task jacocoUnitTestReport (type : JacocoReport , group : ' verification' , dependsOn : [' testDebugUnitTest' ]) {
91+ reports {
92+ xml. enabled = true
93+ html. enabled = true
94+ }
95+
96+ def fileFilter = [' **/R.class' , ' **/R$*.class' , ' **/BuildConfig.*' , ' **/Manifest*.*' , ' **/*Test*.*' , ' android/**/*.*' ]
97+ def debugTree = fileTree(dir : " $project . buildDir /intermediates/classes/debug" , excludes : fileFilter)
98+ def mainSrc = " $project . projectDir /src/main/java"
99+
100+ sourceDirectories = files([mainSrc])
101+ classDirectories = files([debugTree])
102+ executionData = fileTree(dir : project. buildDir, includes : [
103+ ' jacoco/testDebugUnitTest.exec' , ' outputs/code-coverage/connected/*coverage.ec'
104+ ])
105+ }
106+
107+ task jacocoFullTestReport (type : JacocoReport , group : ' verification' , dependsOn : [' testDebugUnitTest' , ' createDebugCoverageReport' ]) {
108+ reports {
109+ xml. enabled = true
110+ html. enabled = true
111+ }
112+
113+ def fileFilter = [' **/R.class' , ' **/R$*.class' , ' **/BuildConfig.*' , ' **/Manifest*.*' , ' **/*Test*.*' , ' android/**/*.*' ]
114+ def debugTree = fileTree(dir : " $project . buildDir /intermediates/classes/debug" , excludes : fileFilter)
115+ def mainSrc = " $project . projectDir /src/main/java"
116+
117+ sourceDirectories = files([mainSrc])
118+ classDirectories = files([debugTree])
119+ executionData = fileTree(dir : project. buildDir, includes : [
120+ ' jacoco/testDebugUnitTest.exec' , ' outputs/code-coverage/connected/*coverage.ec'
121+ ])
122+ }
123+
124+ task copyAndroidCoverage (type : Copy ) {
125+ /* afterEvaluate {
126+ dependsOn jacocoFullTestReport
127+ }*/
128+ from ' build/reports/jacoco/jacocoFullTestReport/jacocoFullTestReport.xml'
129+ into ' ./'
130+ rename { String fileName ->
131+ fileName = " integration.xml"
132+ }
133+ }
134+
135+ apply from : " ${ rootDir} /publish.gradle"
136+
0 commit comments