Adding classpath entries using Gradle's Application plugin

后端 未结 5 514
攒了一身酷
攒了一身酷 2021-02-01 18:57

I\'m using Gradle\'s Application plugin to generate the install for a standalone java application. I have a configuration file I need to put on the classpath but I can\'t seem t

5条回答
  •  野性不改
    2021-02-01 19:38

    Another workaround for this issue (GRADLE-2333) is proposed by Alexandr Fadeev here.

    Here is (a bit modified) Alexandr's solution that solved the problem for me on Gradle-1.6:

    startScripts {
      classpath += files('src/dist/XxxAPlaceHolderForAConfigxxX')
      doLast {
        def windowsScriptFile = file getWindowsScript()
        def unixScriptFile    = file getUnixScript()
        windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib\\XxxAPlaceHolderForAConfigxxX', '%APP_HOME%\\config')
        unixScriptFile.text  = unixScriptFile.text.replace('$APP_HOME/lib/XxxAPlaceHolderForAConfigxxX', '$APP_HOME/config')
      }
    }
    

    It's a bit uglier than Josh's solution, but it allows you to preserve the exact directory layout (/src/dist/conf and $APP_HOME/conf) mentioned in the original question.

提交回复
热议问题