1+ import org.jetbrains.dokka.DokkaConfiguration.Visibility
2+ import org.jetbrains.dokka.gradle.DokkaTask
3+ import java.io.FileInputStream
4+ import java.net.URI
5+ import java.util.Properties
6+
7+ plugins {
8+ alias(libs.plugins.android.library)
9+ alias(libs.plugins.jetbrains.kotlin.android)
10+ alias(libs.plugins.google.ksp)
11+ alias(libs.plugins.jetbrains.dokka)
12+ id(" maven-publish" )
13+ id(" com.github.ben-manes.versions" ) version " 0.46.0"
14+ }
15+
16+ extra.apply {
17+ set(" versionMajor" , 0 )
18+ set(" versionMedium" , 0 )
19+ set(" versionMinorPublished" , 204 ) // should increment after public release
20+ set(" libraryId" , libraryId())
21+ set(" libraryGroupId" , libraryId())
22+ set(" libraryArtifactId" , libraryArtifactId())
23+ set(" defaultRepo" , " " )
24+ }
25+
26+ fun libraryArtifactId (): String {
27+ return if (project.hasProperty(" LIB_ART_ID" )) {
28+ project.property(" LIB_ART_ID" ) as String
29+ } else {
30+ " core"
31+ }
32+ }
33+
34+ fun libraryId (): String {
35+ return if (project.hasProperty(" LIB_ID" )) {
36+ project.property(" LIB_ID" ) as String
37+ } else {
38+ " circle.modularwallets"
39+ }
40+ }
41+
42+ fun buildNum (): Int {
43+ return if (project.hasProperty(" BUILD_NUM" )) {
44+ project.property(" BUILD_NUM" ).toString().toInt()
45+ } else {
46+ 0
47+ }
48+ }
49+
50+ fun majorNumber (): Int {
51+ return if (project.hasProperty(" MAJOR_NUMBER" )) {
52+ project.property(" MAJOR_NUMBER" ).toString().toInt()
53+ } else {
54+ extra[" versionMajor" ] as Int
55+ }
56+ }
57+
58+ fun isInternalBuild (): Boolean {
59+ return majorNumber() == 0
60+
61+ }
62+
63+ fun apiVersion (): String {
64+ return if (isInternalBuild()) {
65+ " ${majorNumber()} .${extra[" versionMedium" ]} .${extra[" versionMinorPublished" ]} -${buildNum()} " // internal build's buildNum is action build number
66+ } else {
67+ " ${majorNumber()} .${extra[" versionMedium" ]} .${buildNum()} " // release build's buildNum is extracted from the git tag
68+ }
69+ }
70+
71+ fun libraryVersion (): String {
72+ val ver = apiVersion()
73+ return if (project.hasProperty(" SNAPSHOT" )) {
74+ " ${ver} -SNAPSHOT"
75+ } else {
76+ ver
77+ }
78+ }
79+
80+ fun nexusRepo (): String {
81+ return if (project.hasProperty(" NEXUS_REPO" )) {
82+ project.property(" NEXUS_REPO" ) as String
83+ } else {
84+ extra[" defaultRepo" ] as String
85+ }
86+ }
87+
88+ fun nexusUsername (): String {
89+ return if (project.hasProperty(" NEXUS_USERNAME" )) {
90+ project.property(" NEXUS_USERNAME" ) as String
91+ } else {
92+ " "
93+ }
94+ }
95+
96+ fun nexusPassword (): String {
97+ return if (project.hasProperty(" NEXUS_PASSWORD" )) {
98+ project.property(" NEXUS_PASSWORD" ) as String
99+ } else {
100+ " "
101+ }
102+ }
103+
104+ android {
105+ namespace = " com.circle.modularwallets.core"
106+ compileSdk = 34
107+
108+ defaultConfig {
109+ minSdk = 28
110+ version = libraryVersion()
111+ buildConfigField(" String" , " version" , " \" ${version} \" " )
112+ buildConfigField(" boolean" , " INTERNAL_BUILD" , " ${isInternalBuild()} " )
113+ testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
114+ testInstrumentationRunnerArguments + = mapOf (
115+ " notPackage" to " com.circle.modularwallets.core.manual"
116+ )
117+ }
118+
119+ buildTypes {
120+ debug {
121+ enableAndroidTestCoverage = true
122+ enableUnitTestCoverage = true
123+ }
124+ release {
125+ isMinifyEnabled = true
126+ proguardFiles(
127+ getDefaultProguardFile(" proguard-android-optimize.txt" ),
128+ " proguard-rules.pro"
129+ )
130+ }
131+ }
132+ compileOptions {
133+ sourceCompatibility = JavaVersion .VERSION_1_8
134+ targetCompatibility = JavaVersion .VERSION_1_8
135+ }
136+ kotlinOptions {
137+ jvmTarget = " 1.8"
138+ }
139+ buildFeatures {
140+ buildConfig = true
141+ }
142+ }
143+
144+ dependencies {
145+ ksp(libs.moshi.ksp)
146+ implementation(libs.androidx.credentials)
147+ implementation(libs.androidx.credentials.auth)
148+ implementation(libs.retrofit2.converter.moshi)
149+ implementation(libs.moshi.kotlin)
150+ implementation(libs.web3j)
151+ implementation(libs.retrofit2.retrofit)
152+ implementation(libs.retrofit2.converter.gson)
153+ implementation(libs.gson)
154+ implementation(libs.okhttp3.logging.interceptor)
155+ implementation(libs.androidx.core.ktx)
156+ implementation(libs.androidx.appcompat)
157+ implementation(libs.material)
158+ testImplementation(libs.junit)
159+ androidTestImplementation(libs.androidx.junit)
160+ androidTestImplementation(libs.androidx.espresso.core)
161+ androidTestImplementation(libs.kotlinx.coroutines.test)
162+ androidTestImplementation(libs.web3j)
163+
164+ testImplementation(libs.junit)
165+ androidTestImplementation(libs.androidx.junit)
166+ androidTestImplementation(libs.androidx.espresso.core)
167+
168+ // Add Mockito dependency
169+ testImplementation(libs.mockito.core)
170+ testImplementation(libs.mockito.android)
171+ androidTestImplementation(libs.mockito.core)
172+ androidTestImplementation(libs.mockito.android)
173+ }
174+
175+ afterEvaluate {
176+ configure<PublishingExtension > {
177+ publications {
178+ create<MavenPublication >(" release" ) {
179+ from(components[" release" ])
180+ groupId = extra[" libraryGroupId" ] as String
181+ artifactId = extra[" libraryArtifactId" ] as String
182+ version = libraryVersion()
183+ }
184+ }
185+
186+ repositories {
187+ maven {
188+ name = " CircleModularwallets"
189+ url = URI (nexusRepo())
190+ isAllowInsecureProtocol = true
191+ credentials {
192+ username = nexusUsername()
193+ password = nexusPassword()
194+ }
195+ }
196+ }
197+ }
198+ }
0 commit comments