Skip to content

Commit

Permalink
chore: Merge branch Claudemirovsky/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 authored Jan 15, 2024
2 parents 50bd5f2 + 2b1b071 commit db5b666
Show file tree
Hide file tree
Showing 124 changed files with 1,619 additions and 1,472 deletions.
7 changes: 0 additions & 7 deletions .github/runner-files/ci-gradle.properties

This file was deleted.

29 changes: 10 additions & 19 deletions .github/workflows/build_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,31 @@ name: CI Pull Request
on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
name: Build pull request
runs-on: ubuntu-latest

steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout pull request
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11

- name: Copy CI gradle.properties
run: |
mkdir -p ~/.gradle
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
- name: Generate android.jar
run: |
./AndroidCompat/getAndroid.sh
java-version: 17
distribution: zulu

- name: Build project
uses: gradle/gradle-command-action@v2
uses: gradle/gradle-build-action@v2
with:
arguments: :server:shadowJar
arguments: :inspector:shadowJar
31 changes: 11 additions & 20 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,31 @@ name: CI build
on:
push:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build project
runs-on: ubuntu-latest

steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Clone repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11

- name: Copy CI gradle.properties
run: |
mkdir -p ~/.gradle
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
- name: Generate android.jar
run: |
./AndroidCompat/getAndroid.sh
java-version: 17
distribution: zulu

- name: Build project
uses: gradle/gradle-command-action@v2
uses: gradle/gradle-build-action@v2
with:
arguments: :server:shadowJar
arguments: :inspector:shadowJar
31 changes: 11 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,41 @@ on:
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build artifacts and create draft release
runs-on: ubuntu-latest

steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout ${{ github.ref }}
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 11

- name: Copy CI gradle.properties
run: |
mkdir -p ~/.gradle
cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties
- name: Generate android.jar
run: |
./AndroidCompat/getAndroid.sh
java-version: 17
distribution: zulu

- name: Build project
uses: gradle/gradle-command-action@v2
uses: gradle/gradle-build-action@v2
with:
arguments: :server:shadowJar
arguments: :inspector:shadowJar

- name: Upload Release
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "server/build/*.jar"
file: "inspector/build/*.jar"
tags: true
draft: true
verbose: true
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,3 @@ local.properties
# Ignore Gradle build output directory
build

server/src/main/resources/webUI
server/tmp/
server/tachiserver-data/

# bundle asset downlaods
OpenJDK*.zip
electron-*.zip
rcedit-*
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.kodein.di.singleton

class ConfigKodeinModule {
fun create() = DI.Module("ConfigManager") {
//Config module
// Config module
bind<ConfigManager>() with singleton { GlobalConfigManager }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ package xyz.nulldev.ts.config
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import ch.qos.logback.classic.Level
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigRenderOptions
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging

/**
* Manages app config.
Expand All @@ -20,7 +20,7 @@ open class ConfigManager {
private val generatedModules = mutableMapOf<Class<out ConfigModule>, ConfigModule>()
val config by lazy { loadConfigs() }

//Public read-only view of modules
// Public read-only view of modules
val loadedModules: Map<Class<out ConfigModule>, ConfigModule>
get() = generatedModules

Expand All @@ -41,21 +41,16 @@ open class ConfigManager {
* Load configs
*/
fun loadConfigs(): Config {
//Load reference configs
// Load reference configs
val compatConfig = ConfigFactory.parseResources("compat-reference.conf")

val config = ConfigFactory.empty()
.withFallback(compatConfig)
.resolve()
.withFallback(compatConfig)
.resolve()

// set log level early
setLogLevel(Level.DEBUG)


logger.debug {
"Loaded config:\n" + config.root().render(ConfigRenderOptions.concise().setFormatted(true))
}

return config
}

Expand All @@ -64,9 +59,7 @@ open class ConfigManager {
}

fun registerModules(vararg modules: ConfigModule) {
modules.forEach {
registerModule(it)
}
modules.forEach(::registerModule)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ package xyz.nulldev.ts.config
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import com.typesafe.config.Config

/**
* Abstract config module.
*/
abstract class ConfigModule(config: Config, moduleName: String = "")
@Suppress("UNUSED_PARAMETER")
abstract class ConfigModule(config: Config, moduleName: String = "")
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ package xyz.nulldev.ts.config
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import ch.qos.logback.classic.Level
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.DelegatingKLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import org.slf4j.Logger
import ch.qos.logback.classic.Logger as LogbackLogger

fun setLogLevel(level: Level) {
(KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger).level = level
val ktlogger = KotlinLogging.logger(Logger.ROOT_LOGGER_NAME)

@Suppress("UNCHECKED_CAST")
val slf4jLogger = (ktlogger as DelegatingKLogger<Logger>).underlyingLogger
(slf4jLogger as LogbackLogger).level = level
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package xyz.nulldev.ts.config.util
import com.typesafe.config.Config

operator fun Config.get(key: String) = getString(key)
?: throw IllegalStateException("Could not find value for config entry: $key!")
?: throw IllegalStateException("Could not find value for config entry: $key!")
41 changes: 14 additions & 27 deletions AndroidCompat/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
plugins {
application
kotlin("plugin.serialization")
}

dependencies {
// Android stub library
implementation(fileTree("lib/"))
// implementation(fileTree("lib/"))
implementation(androidcompat.android.jar)

// XML
compileOnly("xmlpull:xmlpull:1.1.3.4a")
// Android version of SimpleDateFormat
implementation(androidcompat.icu4j)

// AndroidX annotations
compileOnly(androidcompat.android.annotations)

// Config API
implementation(project(":AndroidCompat:Config"))

// APK sig verifier
compileOnly("com.android.tools.build:apksig:7.1.2")

// AndroidX annotations
compileOnly("androidx.annotation:annotation:1.3.0")

// substitute for duktape-android
implementation("org.mozilla:rhino-runtime:1.7.14") // slimmer version of 'org.mozilla:rhino'
implementation("org.mozilla:rhino-engine:1.7.14") // provides the same interface as 'javax.script' a.k.a Nashorn
// Jackson annotations
implementation(androidcompat.jackson.annotations)

// Kotlin wrapper around Java Preferences, makes certain things easier
val multiplatformSettingsVersion = "0.8.1"
implementation("com.russhwolf:multiplatform-settings-jvm:$multiplatformSettingsVersion")
implementation("com.russhwolf:multiplatform-settings-serialization-jvm:$multiplatformSettingsVersion")
implementation(androidcompat.bundles.settings)

// Android version of SimpleDateFormat
implementation("com.ibm.icu:icu4j:70.1")
}
// Rhino, an pure-java alternative to duktape-android / QuickJS
implementation(androidcompat.bundles.rhino)

tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
// XML
compileOnly(androidcompat.xmlpull)
}
6 changes: 5 additions & 1 deletion AndroidCompat/getAndroid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function Remove-Files-Zip($zipfile, $paths)
$stream.Dispose()
}

Write-Output "Removing useless resources..."
Remove-Files-Zip $android_jar 'res/*'
Remove-Files-Zip $android_jar 'resources.arsc'

Write-Output "Removing org.json..."
Remove-Files-Zip $android_jar 'org/json/*'

Expand Down Expand Up @@ -95,7 +99,7 @@ function Dedupe($path)
}

Dedupe "AndroidCompat/src/main/java"
Dedupe "server/src/main/kotlin"
Dedupe "inspector/src/main/kotlin"

Write-Output "Copying Android.jar to library folder..."
Move-Item -Force $android_jar "AndroidCompat/lib/android.jar"
Expand Down
6 changes: 5 additions & 1 deletion AndroidCompat/getAndroid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ curl "https://android.googlesource.com/platform/prebuilts/sdk/+/6cd31be5e4e25901
# We need to remove any stub classes that we have implementations for
echo "Patching JAR..."

echo "Removing useless resources..."
zip --delete android.jar res/*
zip --delete android.jar resources.arsc

echo "Removing org.json..."
zip --delete android.jar org/json/*

Expand Down Expand Up @@ -84,7 +88,7 @@ function dedup() {

popd
dedup AndroidCompat/src/main/java
dedup server/src/main/kotlin
dedup inspector/src/main/kotlin

echo "Copying Android.jar to library folder..."
mv tmp/android.jar AndroidCompat/lib
Expand Down
Loading

0 comments on commit db5b666

Please sign in to comment.