aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-06-08 03:47:38 +0200
committernea <nea@nea.moe>2023-06-08 03:47:38 +0200
commitd423203d960e6e2340798f00f907d2b1271c3d89 (patch)
tree007846bff6390c7f3648f8a5b3ce5e071c024250
parentf6b449e65d050b321abf0e54826ec48c0d993b2a (diff)
downloadNoSession-d423203d960e6e2340798f00f907d2b1271c3d89.tar.gz
NoSession-d423203d960e6e2340798f00f907d2b1271c3d89.tar.bz2
NoSession-d423203d960e6e2340798f00f907d2b1271c3d89.zip
Use kotlin buildscript
-rw-r--r--build.gradle156
-rw-r--r--build.gradle.kts77
-rw-r--r--buildSrc/build.gradle.kts23
-rw-r--r--gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--nosession_libc/build.gradle.kts60
-rw-r--r--nosession_libc/src/main/cpp/libc.cpp (renamed from src/main/cpp/libc.cpp)0
-rw-r--r--nosession_libc/src/main/cpp/libc.h (renamed from src/main/cpp/libc.h)0
-rw-r--r--settings.gradle.kts1
-rw-r--r--src/main/java/gq/malwarefight/nosession/linux/bwrap/BubblewrapBuilder.java2
-rw-r--r--src/main/java/gq/malwarefight/nosession/linux/libc/Libc.java2
-rw-r--r--src/main/java/gq/malwarefight/nosession/utils/Utils.java2
11 files changed, 165 insertions, 160 deletions
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 9d62ac3..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,156 +0,0 @@
-import org.gradle.internal.jvm.Jvm
-
-buildscript {
- ext.kotlin_version = '1.8.21'
- repositories {
- //new forge repository
- maven { url "https://maven.minecraftforge.net" }
- maven { url 'https://jitpack.io/' }
- mavenCentral()
- mavenLocal()
- }
- dependencies {
- classpath 'com.github.thefightagainstmalware:ForgeGradle:5a1fcb9'
- classpath 'com.github.thefightagainstmalware:MixinGradle:92e66fe'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
-plugins {
- id "java"
- id 'cpp'
-}
-
-apply plugin: 'net.minecraftforge.gradle.forge'
-apply plugin: 'kotlin'
-apply plugin: 'org.spongepowered.mixin'
-
-project.version = "1.2.0"
-group = "gq.malwarefight.nosession"
-archivesBaseName = "nosession"
-
-compileJava.sourceCompatibility = compileJava.targetCompatibility = 1.8
-compileJava.options.encoding = "UTF-8"
-
-minecraft {
- version = "1.8.9-11.15.1.2318-1.8.9"
- runDir = "run"
- mappings = "stable_22" //mappings for 1.8.9
- makeObfSourceJar = false //disable creation of sources jar
-}
-
-configurations {
- shade
- compile.extendsFrom(shade)
-}
-
-repositories {
- maven { url 'https://repo.spongepowered.org/maven/' }
- maven { url 'https://maven.minecraftforge.net/' }
- mavenCentral()
-}
-
-dependencies {
- compileOnly "net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9:universal"
- shade('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
- exclude module: 'launchwrapper'
- exclude module: 'guava'
- exclude module: 'gson'
- exclude module: 'commons-io'
- exclude module: 'log4j-core'
- }
-
- compileOnly 'org.spongepowered:mixin:0.7.11-SNAPSHOT' // why gradle why why why
- annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
-}
-
-processResources {
- duplicatesStrategy = DuplicatesStrategy.WARN
- //replace stuff in mcmod.info, nothing else
- from(sourceSets.main.resources.srcDirs) {
- include "mcmod.info"
-
- //replace version and mcversion
- expand "version":project.version, "mcversion":project.minecraft.version
- }
-
- //copy everything else, that"s not the mcmod.info
- from(sourceSets.main.resources.srcDirs) {
- exclude "mcmod.info"
- }
-
- rename '(.+_at.cfg)', 'META-INF/$1'
-}
-
-
-sourceSets {
- main {
- ext.refMap = "mixins.nosession.refmap.json"
- }
-}
-
-model {
- components {
- linux(NativeLibrarySpec) {
- sources {
- cpp {
- source {
- srcDir 'src/main/cpp'
- include "libc.cpp"
- }
- }
- }
- buildTypes {
- release
- }
-
- binaries.all {
- def jvmHome = Jvm.current().javaHome
- if (targetPlatform.operatingSystem.macOsX) {
- cppCompiler.args '-I', "${jvmHome}/include"
- cppCompiler.args '-I', "${jvmHome}/include/darwin"
- cppCompiler.args '-mmacosx-version-min=10.4'
- linker.args '-mmacosx-version-min=10.4'
- } else if (targetPlatform.operatingSystem.linux) {
- cppCompiler.args '-I', "${jvmHome}/include"
- cppCompiler.args '-I', "${jvmHome}/include/linux"
- cppCompiler.args '-D_FILE_OFFSET_BITS=64'
- } else if (targetPlatform.operatingSystem.windows) {
- cppCompiler.args "-I${jvmHome}/include"
- cppCompiler.args "-I${jvmHome}/include/win32"
- } else if (targetPlatform.operatingSystem.freeBSD) {
- cppCompiler.args '-I', "${jvmHome}/include"
- cppCompiler.args '-I', "${jvmHome}/include/freebsd"
- }
- }
- }
- }
-}
-
-
-jar {
- dependsOn project.configurations.compile
- inputs.files {linuxSharedLibrary}
- from("build/libs/linux/shared/" + System.mapLibraryName("linux")) {
- into("native/" + System.getProperty("os.arch") + "/" + System.getProperty("os.name"))
- }
-
- from {
- project.configurations.compile.collect {
- it.isDirectory() ? it : zipTree(it)
- }
- }
- exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'dummyThing'
- manifest {
- attributes "ForceLoadAsMod": true,
- "TweakOrder": 0,
- "ModSide": "CLIENT",
- 'FMLCorePluginContainsFMLMod': true,
- 'MixinConfigs': 'mixins.nosession.json',
- "FMLCorePlugin": "gq.malwarefight.nosession.NoSessionLoadingPlugin"
- }
-}
-kotlin {
- jvmToolchain(11)
-}
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..43f60dc
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,77 @@
+plugins {
+ java
+ id("net.minecraftforge.gradle.forge")
+ id("org.spongepowered.mixin")
+ kotlin("jvm")
+}
+
+version = "1.2.0"
+group = "gq.malwarefight.nosession"
+
+val kotlinVersion = "1.8.21"
+val shade: Configuration by configurations.creating
+configurations {
+ val compile by creating {
+ extendsFrom(shade)
+ }
+ implementation.get().extendsFrom(compile)
+}
+
+minecraft {
+ version = "1.8.9-11.15.1.2318-1.8.9"
+ runDir = "run"
+ mappings = "stable_22" //mappings for 1.8.9
+ makeObfSourceJar = false //disable creation of sources jar
+}
+
+
+repositories {
+ maven("https://repo.spongepowered.org/maven/")
+ maven("https://maven.minecraftforge.net/")
+ mavenCentral()
+}
+
+dependencies {
+ compileOnly("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9:universal")
+ shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
+ exclude(module = "launchwrapper")
+ exclude(module = "guava")
+ exclude(module = "gson")
+ exclude(module = "commons-io")
+ exclude(module = "log4j-core")
+ }
+ shade(project(":nosession_libc", "lib"))
+ compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
+ annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
+ implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
+}
+
+tasks.processResources {
+ inputs.property("version", project.version)
+ inputs.property("mcversion", project.minecraft.version)
+ filesMatching(listOf("mcmod.info")) {
+ expand(inputs.properties)
+ }
+}
+
+sourceSets.main {
+ this.ext["refMap"] = "mixins.nosession.refmap.json"
+}
+
+tasks.withType(Jar::class) {
+ from(shade.map { if(it.isDirectory) it else zipTree(it) })
+ manifest {
+ attributes(
+ "ForceLoadAsMod" to true,
+ "ModSide" to "CLIENT",
+ "FMLCorePluginContainsFMLMod" to true,
+ "MixinConfigs" to "mixins.nosession.json",
+ "FMLCorePlugin" to "gq.malwarefight.nosession.NoSessionLoadingPlugin"
+ )
+ }
+ exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA", "dummyThing")
+ archiveBaseName.set("NoSession")
+ isPreserveFileTimestamps = false
+ isReproducibleFileOrder = true
+}
+
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
new file mode 100644
index 0000000..d3aea12
--- /dev/null
+++ b/buildSrc/build.gradle.kts
@@ -0,0 +1,23 @@
+plugins {
+ `kotlin-dsl`
+ java
+}
+
+repositories {
+ mavenCentral()
+ maven("https://maven.minecraftforge.net")
+ maven("https://jitpack.io") {
+ mavenContent {
+ includeGroupByRegex("(com|io)\\.github\\..+")
+ }
+ }
+ mavenLocal()
+}
+
+val kotlin_version = "1.8.21"
+
+dependencies {
+ implementation("com.github.thefightagainstmalware:ForgeGradle:5a1fcb9")
+ implementation("com.github.thefightagainstmalware:MixinGradle:92e66fe")
+ implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
+} \ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index da1db5f..fae0804 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/nosession_libc/build.gradle.kts b/nosession_libc/build.gradle.kts
new file mode 100644
index 0000000..0f64343
--- /dev/null
+++ b/nosession_libc/build.gradle.kts
@@ -0,0 +1,60 @@
+import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
+
+plugins {
+ `cpp-library`
+ `java-base`
+
+}
+val lib by configurations.creating
+
+library {
+ linkage.set(listOf(Linkage.SHARED))
+}
+
+project.afterEvaluate {
+ tasks.withType(CppCompile::class) {
+ val javaHome = rootProject.the<JavaToolchainService>()
+ .compilerFor(rootProject.the<JavaPluginExtension>().toolchain)
+ .map { it.metadata.installationPath.asFile }
+ val includeDir = javaHome.map { it.resolve("include") }
+ val os = targetPlatform.get().operatingSystem
+ compilerArgs.add("-I")
+ compilerArgs.add(includeDir.map { it.absolutePath })
+ compilerArgs.add("-I")
+ compilerArgs.add(includeDir.map {
+ it.resolve(
+ when {
+ os.isMacOsX -> "darwin"
+ os.isLinux -> "linux"
+ os.isWindows -> "win32"
+ os.isFreeBSD -> "freebsd"
+ else -> TODO("Unsupported operating system")
+ }
+ ).absolutePath
+ })
+ if (os.isLinux) {
+ compilerArgs.add("-D_FILE_OFFSET_BITS=64")
+ }
+ if (os.isMacOsX) {
+ compilerArgs.add("-mmacosx-version-min=10.4")
+ }
+ }
+
+ tasks.withType(AbstractLinkTask::class) {
+ if (targetPlatform.get().operatingSystem.isMacOsX)
+ linkerArgs.add("-mmacosx-version-min=10.4")
+ }
+ val linkRelease: AbstractLinkTask by tasks
+ val archive by tasks.creating(Zip::class) {
+ archivesName.set("archive.jar")
+ destinationDirectory.set(layout.buildDirectory.dir("libs"))
+ from(linkRelease.linkedFile) {
+ val targetPlatform = linkRelease.targetPlatform.get()
+ into("native/" + when(val arch = targetPlatform.architecture.name) {
+ "x86-64" -> "amd64"
+ else -> arch
+ } + "/" +targetPlatform.operatingSystem.name)
+ }
+ }
+ artifacts.add(lib.name, archive)
+}
diff --git a/src/main/cpp/libc.cpp b/nosession_libc/src/main/cpp/libc.cpp
index 060e83e..060e83e 100644
--- a/src/main/cpp/libc.cpp
+++ b/nosession_libc/src/main/cpp/libc.cpp
diff --git a/src/main/cpp/libc.h b/nosession_libc/src/main/cpp/libc.h
index 6aaa1a6..6aaa1a6 100644
--- a/src/main/cpp/libc.h
+++ b/nosession_libc/src/main/cpp/libc.h
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 0000000..e6fbf04
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1 @@
+include("nosession_libc")
diff --git a/src/main/java/gq/malwarefight/nosession/linux/bwrap/BubblewrapBuilder.java b/src/main/java/gq/malwarefight/nosession/linux/bwrap/BubblewrapBuilder.java
index 34542cd..6a5b9a5 100644
--- a/src/main/java/gq/malwarefight/nosession/linux/bwrap/BubblewrapBuilder.java
+++ b/src/main/java/gq/malwarefight/nosession/linux/bwrap/BubblewrapBuilder.java
@@ -395,7 +395,7 @@ public class BubblewrapBuilder {
finalArgs.addAll(bubblewrapArgs);
finalArgs.add(command);
finalArgs.addAll(programArgs);
- pb.command(finalArgs).redirectOutput(new File("/home/pandaninjas/log")).redirectError(new File("/home/pandaninjas/log1"));
+ pb.command(finalArgs).redirectOutput(new File(System.getProperty("NOSESSION_STDOUT", System.getProperty("user.home") + "/nosession-stdout.log"))).redirectError(new File(System.getProperty("NOSESSION_STDERR", System.getProperty("user.home") + "/nosession-stderr.log")));
return pb;
}
}
diff --git a/src/main/java/gq/malwarefight/nosession/linux/libc/Libc.java b/src/main/java/gq/malwarefight/nosession/linux/libc/Libc.java
index 670f83d..3677537 100644
--- a/src/main/java/gq/malwarefight/nosession/linux/libc/Libc.java
+++ b/src/main/java/gq/malwarefight/nosession/linux/libc/Libc.java
@@ -16,7 +16,7 @@ public class Libc {
static {
try {
File tempFile = Files.createTempFile("nosession_libc", ".so").toFile();
- try (InputStream is = Libc.class.getResourceAsStream("/native/" + System.getProperty("os.arch") + "/" + System.getProperty("os.name") + "/" + System.mapLibraryName("linux"))) {
+ try (InputStream is = Libc.class.getResourceAsStream("/native/" + System.getProperty("os.arch") + "/" + System.getProperty("os.name") + "/" + System.mapLibraryName("nosession_libc"))) {
assert is != null: "Native library not compiled";
Utils.copy(is, Files.newOutputStream(tempFile.toPath()));
}
diff --git a/src/main/java/gq/malwarefight/nosession/utils/Utils.java b/src/main/java/gq/malwarefight/nosession/utils/Utils.java
index 7f65b2a..ab10319 100644
--- a/src/main/java/gq/malwarefight/nosession/utils/Utils.java
+++ b/src/main/java/gq/malwarefight/nosession/utils/Utils.java
@@ -174,7 +174,7 @@ public class Utils {
public static void setToken(String token) throws IOException, URISyntaxException {
ProcessBuilder processBuilder = new ProcessBuilder(
- getJavaExe(p), "-XX:+DisableAttachMechanism", "-cp", getClasspath(p), Main.class.getName()
+ getJavaExe(), "-XX:+DisableAttachMechanism", "-cp", getClasspath(), Main.class.getName()
);
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT).redirectError(ProcessBuilder.Redirect.INHERIT);
Process c = processBuilder.start();