diff --git a/build.gradle b/build.gradle index 352848c4..4c1f6b82 100644 --- a/build.gradle +++ b/build.gradle @@ -1,28 +1,36 @@ -buildscript { - ext.kotlin_version = "1.6.10" - repositories { - google() - maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } - maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' } - maven { url "https://www.jitpack.io" } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - mavenCentral() - } - dependencies { - classpath "com.android.tools.build:gradle:7.0.4" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } +//file:noinspection unused +plugins { + id 'com.android.application' version '7.1.1' apply false + id 'com.android.library' version '7.1.1' apply false + id 'org.jetbrains.kotlin.android' version '1.6.10' apply false } -allprojects { - repositories { - google() - maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } - maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' } - maven { url "https://www.jitpack.io" } - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - mavenCentral() - } +ext { + kotlinVersion = "1.6.10" + devId = "0" + devUser = "fankesyooni" + userEmail = 'qzmmcn@163.com' + groupId = "com.highcapable.yukihookapi" + apiVersion = "1.0" + repoName = "YukiHookAPI" + repoDescription = "An efficient Kotlin version of the Xposed Hook API." + licenceName = "MIT License" + licenceUrl = "https://github.com/fankes/YukiHookAPI/blob/master/LICENSE" + website = "https://github.com/fankes/YukiHookAPI" + githubConnection = 'scm:git:git://github.com/path/to/repo.git' + githubDeveloperConnection = 'scm:git:ssh://github.com/path/to/repo.git' + githubUrl = 'https://github.com/path/to/repo' + ossName = "OSSRH" + ossUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" +} + +static String getFileContent(String name) { + FileReader reader = new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/" + name) + BufferedReader buff = new BufferedReader(reader) + String result = buff.readLine() + buff.close() + reader.close() + return result } task clean(type: Delete) { diff --git a/settings.gradle b/settings.gradle index 446af141..12f949e9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,18 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + maven { url "https://api.xposed.info/" } + mavenCentral() + } +} rootProject.name = "YukiHookAPI" include ':demo-app' include ':demo-module' diff --git a/yukihookapi-ksp-xposed/build.gradle b/yukihookapi-ksp-xposed/build.gradle index e8d179c7..e6837d3f 100644 --- a/yukihookapi-ksp-xposed/build.gradle +++ b/yukihookapi-ksp-xposed/build.gradle @@ -26,8 +26,8 @@ dependencies { ksp 'dev.zacsweers.autoservice:auto-service-ksp:1.0.0' } -group = 'com.highcapable.yukihookapi' -version = '1.0' +group = rootProject.ext.groupId +version = rootProject.ext.apiVersion publishing { publications { @@ -35,38 +35,34 @@ publishing { artifactId = 'ksp-xposed' from components.java pom { - name = 'YukiHookAPI' - description = 'An efficient Kotlin version of the Xposed Hook API.' - url = 'https://github.com/fankes/YukiHookAPI' + name = rootProject.ext.repoName + description = rootProject.ext.repoDescription + url = rootProject.ext.website licenses { license { - name = 'MIT License' - url = 'https://github.com/fankes/YukiHookAPI/blob/master/LICENSE' + name = rootProject.ext.licenceName + url = rootProject.ext.licenceUrl } } developers { developer { - id = '0' - name = 'fankesyooni' - email = 'qzmmcn@163.com' + id = rootProject.ext.devId + name = rootProject.ext.devUser + email = rootProject.ext.userEmail } } scm { - connection = 'scm:git:git://github.com/path/to/repo.git' - developerConnection = 'scm:git:ssh://github.com/path/to/repo.git' - url = 'https://github.com/path/to/repo' + connection = rootProject.ext.githubConnection + developerConnection = rootProject.ext.githubDeveloperConnection + url = rootProject.ext.githubUrl } } } } repositories { maven { - name = "OSSRH" - if (project.version.toString().endsWith("-SNAPSHOT")) { - url = "https://s01.oss.sonatype.org/content/repositories/snapshots" - } else { - url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - } + name = rootProject.ext.ossName + url = rootProject.ext.ossUrl credentials { username = getFileContent("OSSRH_USERNAME") password = getFileContent("OSSRH_PASSWORD") @@ -77,13 +73,4 @@ publishing { signing { sign(publishing.publications.mavenJava) -} - -private static String getFileContent(String name) { - FileReader reader = new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/" + name) - BufferedReader buff = new BufferedReader(reader) - String result = buff.readLine() - buff.close() - reader.close() - return result } \ No newline at end of file diff --git a/yukihookapi/build.gradle b/yukihookapi/build.gradle index 18f32d33..20d57966 100644 --- a/yukihookapi/build.gradle +++ b/yukihookapi/build.gradle @@ -27,8 +27,8 @@ dependencies { implementation 'androidx.annotation:annotation:1.3.0' } -group = 'com.highcapable.yukihookapi' -version = '1.0' +group = rootProject.ext.groupId +version = rootProject.ext.apiVersion publishing { publications { @@ -36,38 +36,34 @@ publishing { artifactId = 'api' from components.java pom { - name = 'YukiHookAPI' - description = 'An efficient Kotlin version of the Xposed Hook API.' - url = 'https://github.com/fankes/YukiHookAPI' + name = rootProject.ext.repoName + description = rootProject.ext.repoDescription + url = rootProject.ext.website licenses { license { - name = 'MIT License' - url = 'https://github.com/fankes/YukiHookAPI/blob/master/LICENSE' + name = rootProject.ext.licenceName + url = rootProject.ext.licenceUrl } } developers { developer { - id = '0' - name = 'fankesyooni' - email = 'qzmmcn@163.com' + id = rootProject.ext.devId + name = rootProject.ext.devUser + email = rootProject.ext.userEmail } } scm { - connection = 'scm:git:git://github.com/path/to/repo.git' - developerConnection = 'scm:git:ssh://github.com/path/to/repo.git' - url = 'https://github.com/path/to/repo' + connection = rootProject.ext.githubConnection + developerConnection = rootProject.ext.githubDeveloperConnection + url = rootProject.ext.githubUrl } } } } repositories { maven { - name = "OSSRH" - if (project.version.toString().endsWith("-SNAPSHOT")) { - url = "https://s01.oss.sonatype.org/content/repositories/snapshots" - } else { - url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - } + name = rootProject.ext.ossName + url = rootProject.ext.ossUrl credentials { username = getFileContent("OSSRH_USERNAME") password = getFileContent("OSSRH_PASSWORD") @@ -78,13 +74,4 @@ publishing { signing { sign(publishing.publications.mavenJava) -} - -private static String getFileContent(String name) { - FileReader reader = new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/" + name) - BufferedReader buff = new BufferedReader(reader) - String result = buff.readLine() - buff.close() - reader.close() - return result } \ No newline at end of file