Modify move maven configs from .gradle to .maven directory and make it to json file

This commit is contained in:
2023-04-15 00:55:55 +08:00
parent eeacd4f7d0
commit 3ddd4b3c0d
4 changed files with 17 additions and 18 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
*.iml
.gradle
.maven
/local.properties
/.idea/caches
/.idea/libraries

View File

@@ -1,4 +1,5 @@
//file:noinspection unused
import groovy.json.JsonSlurper
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
@@ -24,23 +25,18 @@ ext {
}
/**
* 获取授权文件内容 - 用于 Maven 的提交
*
* 若编译失败请将路径替换为自己的或置空
* @param name
* @return [String]
* 获取 Maven 授权信息 - 用于 Maven 的提交
* @param childProjectDir 子项目的目录
* @return [Object]
*/
static String getFileContent(String name) {
String result = ""
@SuppressWarnings('unused')
static Object getMavenCredentials(File childProjectDir) {
def slurper = new JsonSlurper()
try {
FileReader reader = new FileReader("/Users/fankes/Project/Android/Xposed/YukiHookAPI/.gradle/" + name)
BufferedReader buff = new BufferedReader(reader)
result = buff.readLine()
buff.close()
reader.close()
return slurper.parse(new File("${childProjectDir.getParent()}/.maven/credentials.json"))
} catch (Throwable ignored) {
return slurper.parseText('{"username":"-NEEDED-","password":"-NEEDED-"}')
}
return result
}
task clean(type: Delete) {

View File

@@ -70,8 +70,9 @@ publishing {
name = rootProject.ext.ossName
url = rootProject.ext.ossUrl
credentials {
username = getFileContent("OSSRH_USERNAME")
password = getFileContent("OSSRH_PASSWORD")
def configs = getMavenCredentials(projectDir)
username = configs.username
password = configs.password
}
}
}

View File

@@ -89,8 +89,9 @@ publishing {
name = rootProject.ext.ossName
url = rootProject.ext.ossUrl
credentials {
username = getFileContent("OSSRH_USERNAME")
password = getFileContent("OSSRH_PASSWORD")
def configs = getMavenCredentials(projectDir)
username = configs.username
password = configs.password
}
}
}