MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    请问一下有什么方法能将Mirai-core项目打包成可执行文件吗?

    开发交流
    4
    6
    282
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sh4wn-Fr4nk1in last edited by

      请问一下有什么方法能将Mirai-core项目打包成可执行文件吗?

      1 Reply Last reply Reply Quote 0
      • Him188
        Him188 last edited by Him188

        目前没有一键工具,如果是 console 可以自己将如下结构打包:

        plugins/插件.jar
        mcl-installer.exe
        

        其中 mcl-installer.exe 是安装器,https://github.com/iTXTech/mcl-installer

        1 Reply Last reply Reply Quote 0
        • Nambers
          Nambers 摸鱼 last edited by Nambers

          可以用shadowjar打包成jar然后确定主类,用java -jar运行

          import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
          
          plugins {
              java
              application
              val kotlinVersion = "1.4.30"
              kotlin("jvm") version kotlinVersion
              id("com.github.johnrengelman.shadow") version "6.1.0"
          
          }
          
          tasks {
              named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
                  this.isZip64 = true
              }
          }
          application {
              mainClass.set("org.example.mirai.plugin.KotlinMainKt")
              mainClassName = "org.example.mirai.plugin.KotlinMainKt"
          }
          group = "tech.eritquearcus"
          version = "2.5.0-patch-2"
          
          repositories {
              maven{ url =uri("https://maven.aliyun.com/nexus/content/groups/public/")}
              jcenter()
              mavenCentral()
              mavenLocal()
          }
          
          tasks.withType(KotlinJvmCompile::class.java) {
              kotlinOptions.jvmTarget = "1.8"
          }
          
          dependencies {
              implementation("org.fusesource.jansi:jansi:1.18")
              implementation("com.google.code.gson:gson:2.8.6")
              api("net.mamoe:mirai-core:2.5.0")
              // https://mvnrepository.com/artifact/org.json/json
              implementation("org.json:json:20201115")
          }
          

          这是我的gradle.kt配置,配置好后运行shadowjar任务就可以了

          RainChan S 2 Replies Last reply Reply Quote 0
          • RainChan
            RainChan 摸鱼 @Nambers last edited by

            @nambers 其实也可以使用application插件,他会自动生成启动脚本,只不过他不会吧所有依赖打包成一个jar文件

            Nambers 1 Reply Last reply Reply Quote 0
            • Nambers
              Nambers 摸鱼 @RainChan last edited by

              @rainchan 喔okok, 不过我觉得shadowjar打包起来挺省事的hhhh

              1 Reply Last reply Reply Quote 0
              • S
                Sh4wn-Fr4nk1in @Nambers last edited by

                @nambers 感谢

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact