英文:
How to set the ABL PROPATH for procedures in a JAR?
问题
我有一个Java(Groovy)的命令行应用程序,还使用了一些Progress ABL代码。该应用程序在构建(使用gradle)时会被打包成一个可执行的JAR*以便分发。r-code(编译后的ABL代码)包含在这个JAR中。我尝试过多种不同的方法来设置PROPATH,但无法让它在JAR中找到r-code。即使应用程序本身是从JAR内部运行的,r-code是否必须在使用之前从存档中提取出来?从源代码目录运行构建后的JAR效果很好,但我认为那仅是因为源代码(.p文件)在文件系统上的相对路径中。我该怎么做?
是否有更好的方法,将r-code与JAR一起打包到tarball中以便分发,而不是将r-code包含在JAR内?例如:
情况1:
app.tar.gz
-app.jar
-Java/Groovy类
-捆绑的依赖项
-rcode/*.r
情况2:
app.tar.gz
-app.jar
-Java/Groovy类
-捆绑的依赖项
-rcode/*.r
情况1会导致上述PROPATH问题,但我还没有测试过情况2。
*即使用 $ java -jar app.jar
来运行构建后的应用程序。我计划在JAR中包含一个启动shell脚本,以便轻松启动。JAR的主类是经过编译的Java代码,根据输入参数,将根据需要运行ABL过程之一。
英文:
I have a Java (Groovy) CLI application that also uses some Progress ABL code. The application when built (gradle) is packaged into an executable JAR* for distribution. The r-code (compiled ABL code) is included in this JAR. I have tried setting the PROPATH a number of different ways, but I can't get it to find the r-code in the JAR. Does the r-code have to be extracted from the archive before it can be used even though the application itself is running from inside the JAR? Running the built JAR from the source code directory works fine, but I think that's just because the source .p files are in the relative path on the filesystem. How can I do this?
Is a better approach to package the r-code with the JAR in a tarball for distribution instead of including the r-code in the JAR itself? For example:
Scenario 1:
app.tar.gz
-app.jar
-Java/Groovy classes
-Bundled dependencies
-rcode/*.r
Scenario 2:
app.tar.gz
-app.jar
-Java/Groovy classes
-Bundled dependencies
-rcode/*.r
Scenario 1 leads to the PROPATH question described above, but I haven't tested Scenario 2.
*I.e. use $ java -jar app.jar
to run the built application. I'm planning to include a startup shell script with the JAR for easy startup. The JAR main class is compiled Java which, depending on input arguments, will run one of the ABL procedures as needed.
答案1
得分: 3
> 是否必须从存档中提取r代码,然后才能在应用程序本身从JAR内部运行时使用?
简短的回答是是的,AVM无法从除了过程库之外的任何存档中读取ABL代码(源代码和/或r代码)。
> 与将r代码直接包含在JAR中相比,将r代码与JAR一起打包到tarball中以进行分发是否是更好的方法?
如果使用过程库,您需要将PL显式添加到PROPATH
中。如果将(r-)代码部署在(例如)zip文件中,您可以将其提取到AVM的工作目录中,然后一切都应该正常工作。这取决于运行ABL代码的内容,工作目录在何处。
使用过程库(而不是“松散”的r代码)还有其他好处,但我不确定它们在这里是否合适。
英文:
> Does the r-code have to be extracted from the archive before it can be
> used even though the application itself is running from inside the
> JAR?
Short answer is yes, the AVM cannot read ABL code (source and/or r-code) in any archive other than a procedure library .
> Is a better approach to package the r-code with the JAR in a tarball
> for distribution instead of including the r-code in the JAR itself?
If you use a procedure library, you will need to explicitly add the PL to PROPATH
. If you deploy the (r-)code in (say) a zip file, you can extract it into the AVM's working directory and things should just work. It depends on what's running that ABL code, as to where the working directory is.
There are other benefits to using procedure libraries (as opposed to "loose" r-code) but I'm not sure whether they're appropriate here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论