258 lines
8.8 KiB
Groovy
258 lines
8.8 KiB
Groovy
apply plugin: 'application'
|
|
apply plugin: 'maven-publish'
|
|
|
|
group 'org.innercore.zotecoreloader'
|
|
version 'beta-1.2.0'
|
|
|
|
application {
|
|
mainClass = 'com.reider745.Main'
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
ivy {
|
|
name 'dex2jarV24Release'
|
|
url 'https://github.com/pxb1988/dex2jar/releases/download'
|
|
patternLayout {
|
|
artifact 'v[revision]/[artifact]-v[revision].[ext]'
|
|
}
|
|
metadataSources {
|
|
artifact()
|
|
}
|
|
content {
|
|
includeModule 'com.googlecode.dex2jar', 'dex-tools'
|
|
}
|
|
}
|
|
maven {
|
|
url 'https://repo.lanink.com/repository/maven-public/'
|
|
}
|
|
maven {
|
|
url 'https://repo.opencollab.dev/maven-releases/'
|
|
}
|
|
maven {
|
|
url 'https://repo.opencollab.dev/maven-snapshots/'
|
|
}
|
|
maven {
|
|
name "innercoreSnapshots"
|
|
url "https://maven.inner-core.org/snapshots"
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
// Isolated classpath for the forked codegen JVM (the :codegen subproject + JavaParser).
|
|
codegenClasspath
|
|
// The official v2.4 distribution is not published as a Maven module.
|
|
dex2jarV24Distribution
|
|
}
|
|
|
|
def dex2jarV24Directory = file("$buildDir/dependencies/dex2jar-v2.4")
|
|
def dex2jarV24Jars = [
|
|
'd2j-base-cmd-v2.4.jar',
|
|
'dex-ir-v2.4.jar',
|
|
'dex-reader-api-v2.4.jar',
|
|
'dex-reader-v2.4.jar',
|
|
'dex-tools-v2.4.jar',
|
|
'dex-translator-v2.4.jar',
|
|
'dex-writer-v2.4.jar',
|
|
'asm-9.5.jar',
|
|
'asm-analysis-9.5.jar',
|
|
'asm-commons-9.5.jar',
|
|
'asm-tree-9.5.jar',
|
|
'asm-util-9.5.jar'
|
|
]
|
|
def dex2jarV24ArchiveSha256 = 'ee7c45eb3c1d2474a6145d8d447e651a736a22d9664b6d3d3be5a5a817dda23a'
|
|
|
|
dependencies {
|
|
codegenClasspath project(':codegen')
|
|
dex2jarV24Distribution('com.googlecode.dex2jar:dex-tools:2.4@zip') {
|
|
transitive = false
|
|
}
|
|
|
|
// The repository POM is packaging=pom, so the JAR artifact must be explicit.
|
|
implementation 'com.reider745.nukkit-mot:Nukkit-MOT:1.5.0-SNAPSHOT@jar'
|
|
|
|
// https://mvnrepository.com/artifact/org.jetbrains/annotations
|
|
implementation 'org.jetbrains:annotations:26.0.1'
|
|
|
|
// https://central.sonatype.com/artifact/com.google.code.gson/gson/versions
|
|
implementation group: 'com.google.code.gson', name: 'gson', version: '2.7'
|
|
implementation group: 'org.mozilla.innercore', name: 'rhino', version: '1.7.15.1'
|
|
// https://central.sonatype.com/artifact/org.json/json/versions
|
|
implementation group: 'org.json', name: 'json', version: '20231013'
|
|
|
|
implementation 'com.cedarsoftware:json-io:4.9.12'
|
|
implementation fileTree(dir: dex2jarV24Directory, include: '*.jar')
|
|
implementation 'org.javassist:javassist:3.29.1-GA'
|
|
|
|
// Generated API-only Android compatibility stubs. This is the only
|
|
// intentionally vendored JAR; rebuild it with rebuildAndroidStubs.
|
|
implementation files('iclibs/android.jar')
|
|
compileOnly 'com.android.support:support-annotations:25.3.1'
|
|
|
|
compileOnly("org.projectlombok:lombok:1.18.44")
|
|
annotationProcessor("org.projectlombok:lombok:1.18.44")
|
|
|
|
testImplementation(platform("org.junit:junit-bom:5.10.0"))
|
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
}
|
|
|
|
tasks.test {
|
|
dependsOn 'generateApiBindingsTest'
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
def targetJavaVersion = 17
|
|
java {
|
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
|
if (JavaVersion.current() < javaVersion) {
|
|
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
|
}
|
|
|
|
withSourcesJar()
|
|
}
|
|
|
|
jar {
|
|
duplicatesStrategy 'exclude'
|
|
manifest {
|
|
attributes 'Main-Class': application.mainClass
|
|
}
|
|
from {
|
|
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
|
}
|
|
}
|
|
|
|
run {
|
|
workingDir 'target'
|
|
standardInput System.in
|
|
}
|
|
|
|
// Generates JS-binding base classes (com.zhekasmirnov.innercore.api.gen.*BindGenBase)
|
|
// from @ApiBinding-annotated sources, before compilation (the hand-written module classes
|
|
// extend the generated bases). The generator lives in the :codegen subproject and runs in a
|
|
// forked JVM so its JavaParser dependency stays isolated from Gradle's bundled copy.
|
|
def apiGenSourceRoot = file('src/main/java/org/innercore')
|
|
def apiGenOutputDir = layout.projectDirectory.dir('src/main/java/com/zhekasmirnov/innercore/api/gen')
|
|
|
|
def apiGenSourceTestRoot = file('src/test/java/org/innercore')
|
|
def apiGenOutputTestDir = layout.projectDirectory.dir('src/test/java/com/zhekasmirnov/innercore/api/gen')
|
|
|
|
tasks.register('prepareDex2jarV24', Sync) {
|
|
group = 'build setup'
|
|
description = 'Downloads and extracts the exact dex2jar v2.4 libraries used by the legacy build.'
|
|
|
|
def distribution = configurations.dex2jarV24Distribution
|
|
inputs.files(distribution)
|
|
from {
|
|
distribution.collect { zipTree(it) }
|
|
}
|
|
include dex2jarV24Jars.collect { "**/lib/$it" }
|
|
eachFile { details ->
|
|
details.path = details.name
|
|
}
|
|
includeEmptyDirs = false
|
|
into dex2jarV24Directory
|
|
|
|
doFirst {
|
|
def archive = distribution.singleFile
|
|
def checksumProperty = 'dex2jarV24ArchiveSha256Actual'
|
|
ant.checksum(file: archive, algorithm: 'SHA-256', property: checksumProperty)
|
|
def actualSha256 = ant.project.properties[checksumProperty]
|
|
if (actualSha256 != dex2jarV24ArchiveSha256) {
|
|
throw new GradleException("Unexpected dex2jar v2.4 archive SHA-256: $actualSha256")
|
|
}
|
|
}
|
|
|
|
doLast {
|
|
def missing = dex2jarV24Jars.findAll { !file("$dex2jarV24Directory/$it").isFile() }
|
|
if (!missing.isEmpty()) {
|
|
throw new GradleException("dex2jar v2.4 archive is missing expected libraries: $missing")
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register('generateApiBindingsTest', JavaExec) {
|
|
group = 'codegen'
|
|
description = 'Generates JS binding base classes from @ApiBinding-annotated sources.'
|
|
javaLauncher = javaToolchains.launcherFor {
|
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
|
if (JavaVersion.current() < javaVersion) {
|
|
languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
|
}
|
|
}
|
|
classpath = configurations.codegenClasspath
|
|
mainClass = 'org.innercore.codegen.Codegen'
|
|
args 'com.zhekasmirnov.innercore.api.gen', apiGenOutputTestDir.asFile.absolutePath, apiGenSourceTestRoot.absolutePath
|
|
inputs.files(fileTree(apiGenSourceRoot) { include '**/*.java' }).withPropertyName('apiBindingSources')
|
|
outputs.dir(apiGenOutputDir).withPropertyName('apiBindingOutput')
|
|
}
|
|
|
|
tasks.register('generateApiBindings', JavaExec) {
|
|
group = 'codegen'
|
|
description = 'Generates JS binding base classes from @ApiBinding-annotated sources.'
|
|
javaLauncher = javaToolchains.launcherFor {
|
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
|
if (JavaVersion.current() < javaVersion) {
|
|
languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
|
}
|
|
}
|
|
classpath = configurations.codegenClasspath
|
|
mainClass = 'org.innercore.codegen.Codegen'
|
|
args 'com.zhekasmirnov.innercore.api.gen', apiGenOutputDir.asFile.absolutePath, apiGenSourceRoot.absolutePath
|
|
inputs.files(fileTree(apiGenSourceRoot) { include '**/*.java' }).withPropertyName('apiBindingSources')
|
|
outputs.dir(apiGenOutputDir).withPropertyName('apiBindingOutput')
|
|
}
|
|
|
|
tasks.named('compileJava') {
|
|
dependsOn 'generateApiBindings', 'prepareDex2jarV24'
|
|
}
|
|
|
|
task rebuildAndroidStubs(type: JavaExec, dependsOn: classes) {
|
|
javaLauncher = javaToolchains.launcherFor {
|
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
|
if (JavaVersion.current() < javaVersion) {
|
|
languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
|
}
|
|
}
|
|
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
mainClass = 'com.reider745.api.hooks.instrument.RebuildJavadoc'
|
|
args '.todo/android.jar', 'iclibs/android.jar', 'proxy'
|
|
}
|
|
|
|
task rebuildZoteStubs(type: JavaExec, dependsOn: jar) {
|
|
javaLauncher = javaToolchains.launcherFor {
|
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
|
if (JavaVersion.current() < javaVersion) {
|
|
languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
|
}
|
|
}
|
|
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
mainClass = 'com.reider745.api.hooks.RebuildJavadoc'
|
|
args "build/libs/${project.name}-${project.version}.jar", ".todo/${project.name}-${project.version}.jar"
|
|
}
|
|
|
|
tasks.jar {
|
|
archiveFileName.set("${project.name}-${project.version}.jar")
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
maven(MavenPublication) {
|
|
from components.java
|
|
}
|
|
}
|
|
repositories {
|
|
maven {
|
|
name = "innercore-releases"
|
|
url = uri("https://maven.inner-core.org/releases")
|
|
credentials {
|
|
username = System.getenv("MAVEN_USERNAME")
|
|
password = System.getenv("MAVEN_PASSWORD")
|
|
}
|
|
}
|
|
}
|
|
}
|