PluginSharedLibraries.kt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2019-2022 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/dev/LICENSE
  8. */
  9. package net.mamoe.console.integrationtest.testpoints
  10. import net.mamoe.console.integrationtest.AbstractTestPoint
  11. import org.objectweb.asm.ClassWriter
  12. import org.objectweb.asm.Opcodes
  13. import java.io.File
  14. import java.util.zip.ZipEntry
  15. import java.util.zip.ZipOutputStream
  16. internal object PluginSharedLibraries : AbstractTestPoint() {
  17. override fun beforeConsoleStartup() {
  18. if (System.getenv("CI").orEmpty().toBoolean()) {
  19. println("CI env")
  20. File("config/Console/PluginDependencies.yml").writeText(
  21. "repoLoc: 'https://repo.maven.apache.org/maven2'"
  22. )
  23. }
  24. File("plugin-shared-libraries").mkdirs()
  25. File("plugin-shared-libraries/libraries.txt").writeText(
  26. """
  27. io.github.karlatemp:unsafe-accessor:1.6.2
  28. """.trimIndent()
  29. )
  30. ZipOutputStream(File("plugin-shared-libraries/test.jar").outputStream().buffered()).use { zipOutput ->
  31. zipOutput.putNextEntry(ZipEntry("net/mamoe/console/it/psl/PluginSharedLib.class"))
  32. ClassWriter(0).also { writer ->
  33. writer.visit(
  34. Opcodes.V1_8,
  35. 0,
  36. "net/mamoe/console/it/psl/PluginSharedLib",
  37. null,
  38. "java/lang/Object",
  39. null
  40. )
  41. }.toByteArray().let { zipOutput.write(it) }
  42. }
  43. }
  44. }