1- import java.security.MessageDigest
2-
3- plugins {
4- id ' com.android.application' version ' 8.7.2' apply false
5- id ' com.android.library' version ' 8.7.2' apply false
1+ plugins {
2+ id ' com.android.application' version ' 8.7.2'
63}
74
8- static void hashFileWithDigest (File fileToHash , MessageDigest digest ){
9- fileToHash. withInputStream { is ->
10- byte [] buffer = new byte [8192 ]
11- int read
12- while ((read = is. read(buffer)) != -1 ) {
13- digest. update(buffer, 0 , read)
5+ static def getDate () { return new Date (). format(' yyyyMMdd' ) }
6+
7+ def getVersionName = {
8+ // Get the last version tag, as well as the short head of the last commit
9+ ByteArrayOutputStream TAG = new ByteArrayOutputStream ()
10+ String semVer = " 1.1.3"
11+ // Used by the fallback for github actions
12+ ByteArrayOutputStream TAG_PART_COMMIT = new ByteArrayOutputStream ()
13+ String TAG_STRING
14+
15+ exec {
16+ try {
17+ commandLine ' git' , ' describe' , ' --tags'
18+ ignoreExitValue true
19+ standardOutput = TAG
20+ } catch (Exception e) {
21+ e. printStackTrace();
1422 }
1523 }
24+
25+ if (TAG . toString() == " " ) {
26+ exec {
27+ // Fallback for action builds
28+ try {
29+ commandLine ' git' , ' describe' , ' --always' , ' --tags'
30+ ignoreExitValue true
31+ standardOutput = TAG_PART_COMMIT
32+ } catch (Exception e) {
33+ }
34+ }
35+ }
36+
37+
38+ if (TAG . toString() != " " ){
39+ TAG_STRING = TAG . toString()
40+ }else {
41+ if (TAG_PART_COMMIT . toString(). trim() == " " ){
42+ // Fallback no repo
43+ return (" LOCAL-" + " ${ getDate()} " )
44+ }else {
45+ // Used by github actions
46+ TAG_STRING = ' copper-legacy-' + " ${ getDate()} " + " -" + TAG_PART_COMMIT . toString(). trim()
47+ }
48+
49+ }
50+
51+ return TAG_STRING . trim(). replace(" -g" , " -" ) + " -" + semVer
52+ }
53+
54+ def getCFApiKey = {
55+ String key = System . getenv(" CURSEFORGE_API_KEY" );
56+ if (key != null ) return key;
57+ File curseforgeKeyFile = new File (" ./curseforge_key.txt" );
58+ if (curseforgeKeyFile. canRead() && curseforgeKeyFile. isFile()) {
59+ return curseforgeKeyFile. text;
60+ }
61+ logger. warn(' BUILD: You have no CurseForge key, the curseforge api will get disabled !' );
62+ return " DUMMY" ;
1663}
1764
18- static void writeVersionFile (File jarFile , File versionFile ){
19- def sha1 = MessageDigest . getInstance(" SHA-1" )
20- hashFileWithDigest(jarFile, sha1)
21- versionFile. write(sha1. digest(). collect { String . format(" %02x" , it) }. join())
65+ configurations {
66+ instrumentedClasspath {
67+ canBeConsumed = false
68+ canBeResolved = true
69+ }
2270}
2371
24- static void writeVersionFile (File [] jarFileArray , File versionFile ){
25- def sha1 = MessageDigest . getInstance(" SHA-1" )
26- jarFileArray. each {jarFile ->
27- hashFileWithDigest(jarFile, sha1)
72+ android {
73+ namespace ' net.kdt.pojavlaunch'
74+
75+ compileSdk = 34
76+
77+ lintOptions {
78+ abortOnError false
79+ }
80+
81+ signingConfigs {
82+ customDebug {
83+ storeFile file(" debug.keystore" )
84+ storePassword " android"
85+ keyAlias " androiddebugkey"
86+ keyPassword " android"
87+ }
88+ customRelease {
89+ storeFile file(" aamc_upload.jks" )
90+ storePassword System . getenv(" GPLAY_KEYSTORE_PASSWORD" )
91+ keyAlias " android_github_release"
92+ keyPassword System . getenv(" GPLAY_KEYSTORE_PASSWORD" )
93+ }
94+ googlePlayBuild {
95+ storeFile file(" upload.jks" )
96+ storePassword System . getenv(" GPLAY_KEYSTORE_PASSWORD" )
97+ keyAlias " upload"
98+ keyPassword System . getenv(" GPLAY_KEYSTORE_PASSWORD" )
99+ }
100+ }
101+
102+ defaultConfig {
103+ applicationId " com.maxjubayeryt.copper"
104+ minSdkVersion 21
105+ targetSdkVersion 34
106+ versionCode 10000000
107+ versionName getVersionName()
108+ multiDexEnabled true // important
109+ resValue ' string' , ' curseforge_api_key' , getCFApiKey()
110+ externalNativeBuild {
111+ ndkBuild {
112+ // Fix for Windows command line length limit
113+ arguments " APP_SHORT_COMMANDS=true"
114+ }
115+ }
116+ }
117+
118+ buildTypes {
119+ debug {
120+ applicationIdSuffix ' .debug'
121+ minifyEnabled false
122+ shrinkResources false
123+ proguardFiles getDefaultProguardFile(' proguard-android-optimize.txt' ), ' proguard-rules.pro'
124+ signingConfig signingConfigs. customDebug
125+ resValue " string" , " app_name" , " Copper (Debug)"
126+ resValue " string" , " app_short_name" , " Copper (Debug)"
127+ resValue ' string' , ' application_package' , ' com.maxjubayeryt.copper.debug'
128+ resValue ' string' , ' storageProviderAuthorities' , ' com.maxjubayeryt.copper.scoped.gamefolder.debug'
129+ resValue ' string' , ' shareProviderAuthority' , ' com.maxjubayeryt.copper.scoped.controlfolder.debug'
130+ }
131+ proguard {
132+ initWith debug
133+ minifyEnabled true
134+ shrinkResources true
135+ }
136+ proguardNoDebug {
137+ initWith proguard
138+ debuggable false
139+ }
140+
141+ release {
142+ // Don't set to true or java.awt will be a.a or something similar.
143+ minifyEnabled false
144+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
145+ signingConfig signingConfigs. customRelease
146+ // defaultConfig already set
147+ // multiDexEnabled = true
148+ // debuggable = true
149+ resValue " string" , " app_name" , " Copper"
150+ resValue " string" , " app_short_name" , " Copper (Debug)"
151+ resValue ' string' , ' storageProviderAuthorities' , ' com.maxjubayeryt.copper.gamefolder'
152+ resValue ' string' , ' application_package' , ' com.maxjubayeryt.copper'
153+ }
154+ gplay {
155+ initWith release
156+ signingConfig signingConfigs. googlePlayBuild
157+ matchingFallbacks = [ ' release' ]
158+ }
159+ }
160+
161+ splits {
162+ abi {
163+ enable project. hasProperty(' abiSplits' )
164+ reset()
165+ include ' arm64-v8a' , ' armeabi-v7a' , ' x86' , ' x86_64'
166+ universalApk true
167+ }
28168 }
29- versionFile. write(sha1. digest(). collect { String . format(" %02x" , it) }. join())
30- }
169+
170+ ndkVersion = " 27.3.13750724"
171+
172+ externalNativeBuild {
173+ ndkBuild {
174+ path file(' src/main/jni/Android.mk' )
175+ }
176+ }
177+
178+ compileOptions {
179+ sourceCompatibility JavaVersion . VERSION_1_8
180+ targetCompatibility JavaVersion . VERSION_1_8
181+ }
182+
183+ bundle {
184+ language {
185+ enableSplit = false
186+ }
187+ }
188+
189+ packagingOptions {
190+ jniLibs {
191+ useLegacyPackaging = true
192+ }
193+ doNotStrip + = [
194+ " **/libcutils.so"
195+ ]
196+ pickFirst ' **/libbytehook.so'
197+ }
198+
199+ buildFeatures {
200+ prefab true
201+ buildConfig true
202+ }
203+
204+ buildToolsVersion = ' 34.0.0'
205+ }
206+
207+ afterEvaluate {
208+ // Explicit dependencies for which the apk relies on
209+ tasks. mergeDebugAssets. dependsOn(" :forge_installer:jar" , " :arc_dns_injector:jar" , " :methods_injector_agent:jar" , " :jre_lwjgl3glfw:jar" )
210+ tasks. mergeReleaseAssets. dependsOn(" :forge_installer:jar" , " :arc_dns_injector:jar" , " :methods_injector_agent:jar" , " :jre_lwjgl3glfw:jar" )
211+ }
212+
213+ dependencies {
214+ implementation ' javax.annotation:javax.annotation-api:1.3.2'
215+ implementation ' commons-codec:commons-codec:1.15'
216+ // implementation 'com.wu-man:android-bsf-api:3.1.3'
217+ implementation ' androidx.preference:preference:1.2.0'
218+ // implementation 'androidx.core:core:1.7.0'
219+ implementation ' androidx.drawerlayout:drawerlayout:1.2.0'
220+ implementation ' androidx.viewpager2:viewpager2:1.1.0-beta01'
221+ implementation ' androidx.annotation:annotation:1.5.0'
222+
223+ implementation " androidx.constraintlayout:constraintlayout:2.1.4"
224+
225+ implementation ' com.github.duanhong169:checkerboarddrawable:1.0.2'
226+ implementation ' com.github.PojavLauncherTeam:portrait-sdp:ed33e89cbc'
227+ implementation ' com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
228+ implementation ' com.github.Mathias-Boulay:ExtendedView:1.0.0'
229+ implementation ' com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
230+ implementation ' com.github.Mathias-Boulay:virtual-joystick-android:1.14'
231+
232+ // implementation 'com.intuit.sdp:sdp-android:1.0.5'
233+ // implementation 'com.intuit.ssp:ssp-android:1.0.5'
234+
235+ implementation ' org.tukaani:xz:1.8'
236+ // Our version of exp4j can be built from source at
237+ // https://github.com/PojavLauncherTeam/exp4j
238+ implementation ' net.sourceforge.htmlcleaner:htmlcleaner:2.6.1'
239+ implementation ' com.bytedance:bytehook:1.0.9'
240+
241+ // implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.0'
242+
243+ implementation ' top.fifthlight.touchcontroller:proxy-client-android:0.0.4'
244+
245+ implementation fileTree(dir : ' libs' , include : [' *.jar' , ' *.aar' ])
246+
247+ implementation " net.java.dev.jna:jna:5.13.0@aar"
248+
249+ }
0 commit comments