Skip to content

Commit

Permalink
Use java-gradle-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vvb2060 committed Feb 19, 2023
1 parent d4b4351 commit dddded2
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 131 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf

*.bat text eol=crlf
*.jar binary
38 changes: 3 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
# Built application files
*.jar
*.zip
*.tar
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# IntelliJ IDEA and Android Studio files
.idea/
*.iml

# Gradle Wrapper
!gradle/wrapper/gradle-wrapper.jar

# Pablo
pablo.properties
/.gradle/
/local.properties
/.idea/
40 changes: 0 additions & 40 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,5 @@ allprojects {
version = "0.4.5"

val javaVersion by extra(JavaVersion.VERSION_11)
val kotlinVersion by extra("1.8.0")
val pabloVersion by extra("1.3.1")

val asmVersion by extra("9.2")
val gripVersion by extra("0.8.1")
val logbackVersion by extra("1.4.5")

val junitVersion by extra("4.13.2")

val androidToolsVersion by extra("7.4.1")
val androidxAppcompatVersion by extra("1.4.0")
val androidxAnnotationVersion by extra("1.3.0")

val androidxRulesVersion by extra("1.4.0")
val androidxRunnerVersion by extra("1.4.0")
val androidxTestExtJunitVersion by extra("1.1.3")
val androidxEspressoVersion by extra("3.4.0")

val androidBuildToolsVersion by extra("33.0.1")
val androidCompileSdkVersion by extra(33)
val androidMinSdkVersion by extra(16)
val androidTargetSdkVersion by extra(androidCompileSdkVersion)

buildscript {
repositories {
google()
mavenLocal()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:$androidToolsVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}

repositories {
google()
mavenLocal()
mavenCentral()
}
}
11 changes: 4 additions & 7 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ java {

publishing {
publications {
register<MavenPublication>("lsparanoid") {
artifactId = "core"
register<MavenPublication>(rootProject.name) {
artifactId = project.name
group = group
version = version
from(components.getByName("java"))
pom {
name.set("core")
description.set("String obfuscator for Android applications")
url.set("https://github.com/LSPosed/LSParanoid")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://github.com/libxposed/service/blob/master/LICENSE")
url.set("https://github.com/LSPosed/LSParanoid/blob/master/LICENSE.txt")
}
}
developers {
Expand All @@ -41,9 +41,6 @@ publishing {
url.set("https://github.com/LSPosed/LSParanoid")
}
}
afterEvaluate {
from(components.getByName("java"))
}
}
}
repositories {
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
generated/
/generated/
32 changes: 16 additions & 16 deletions gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import com.android.build.gradle.tasks.SourceJarTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val androidToolsVersion: String by extra
val javaVersion: JavaVersion by extra
val kotlinVersion: String by extra

plugins {
idea
kotlin("jvm") version ("1.8.0")
kotlin("jvm")
`java-gradle-plugin`
`maven-publish`
signing
}
Expand All @@ -28,13 +27,8 @@ kotlin {

dependencies {
implementation(project(":core"))
compileOnly(gradleApi())
compileOnly("com.android.tools.build:gradle:$androidToolsVersion")
compileOnly("com.android.tools.build:gradle-api:$androidToolsVersion")
implementation(project(":processor"))
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
annotationProcessor("com.google.auto.service:auto-service:1.0.1")
implementation("com.google.auto.service:auto-service-annotations:1.0.1")
compileOnly("com.android.tools.build:gradle-api:$androidToolsVersion")
}

val generatedDir = File(projectDir, "generated")
Expand Down Expand Up @@ -78,20 +72,29 @@ idea {
}
}

gradlePlugin {
plugins {
create(rootProject.name) {
id = project.group as String
implementationClass = "org.lsposed.lsparanoid.plugin.ParanoidPlugin"
}
}
}

publishing {
publications {
register<MavenPublication>("lsparanoid") {
artifactId = "gradle-plugin"
val gradlePluginName = "pluginMaven" // https://github.com/gradle/gradle/issues/10384
create<MavenPublication>(gradlePluginName) {
artifactId = project.name
group = group
version = version
pom {
name.set("gradle-plugin")
description.set("String obfuscator for Android applications")
url.set("https://github.com/LSPosed/LSParanoid")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://github.com/libxposed/service/blob/master/LICENSE")
url.set("https://github.com/LSPosed/LSParanoid/blob/master/LICENSE.txt")
}
}
developers {
Expand All @@ -105,9 +108,6 @@ publishing {
url.set("https://github.com/LSPosed/LSParanoid")
}
}
afterEvaluate {
from(components.getByName("java"))
}
}
}
repositories {
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
bootstrap=false
android.useAndroidX=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
28 changes: 8 additions & 20 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
plugins {
kotlin("jvm") version "1.8.0"
kotlin("jvm")
`maven-publish`
signing
}

val javaVersion: JavaVersion by extra
val asmVersion: String by extra
val kotlinVersion: String by extra
val gripVersion: String by extra
val logbackVersion: String by extra
val junitVersion: String by extra
val androidToolsVersion: String by extra

java {
sourceCompatibility = javaVersion
Expand All @@ -27,29 +21,26 @@ kotlin {
}

dependencies {
compileOnly(gradleApi())
implementation(project(":core"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("com.joom.grip:grip:$gripVersion")
implementation("org.ow2.asm:asm:$asmVersion")
implementation("org.ow2.asm:asm-commons:$asmVersion")
testImplementation("junit:junit:$junitVersion")
implementation("com.joom.grip:grip:0.8.1")
implementation("org.ow2.asm:asm-commons:9.4")
}

publishing {
publications {
register<MavenPublication>("lsparanoid") {
artifactId = "processor"
register<MavenPublication>(rootProject.name) {
artifactId = project.name
group = group
version = version
from(components.getByName("java"))
pom {
name.set("processor")
description.set("String obfuscator for Android applications")
url.set("https://github.com/LSPosed/LSParanoid")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://github.com/libxposed/service/blob/master/LICENSE")
url.set("https://github.com/LSPosed/LSParanoid/blob/master/LICENSE.txt")
}
}
developers {
Expand All @@ -63,9 +54,6 @@ publishing {
url.set("https://github.com/LSPosed/LSParanoid")
}
}
afterEvaluate {
from(components.getByName("java"))
}
}
}
repositories {
Expand Down
21 changes: 17 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
kotlin("jvm") version "1.8.10"
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "lsparanoid"

include(":core", ":processor", ":gradle-plugin")

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}

0 comments on commit dddded2

Please sign in to comment.