Adding an external folder to the Play class path

I am a playback platform and new to SBT.

In my Play for Java project, in one of the classes, I need to read property files outside of my Play application using ResourceBundle.getBundle ().

I can already do this in Play Console mode by adding the following to my build.sbt unmanagedClasspath in the Runtime + = file ("/ mybundle")

Since I need to run the application in "Production" mode, I tried to play the disk, then unzip the zip file, then went to "bin", and then ran the created shell script in the bin folder.

I found out that my class was unable to read the package. (this is normal in "Play Console" mode). Then I noticed that in the generated shell script to start playback, the following exists

declare -r app_classpath="$lib_dir/com.foo.abc-web-1.0-SNAPSHOT.jar:$lib_dir/com.foo.abc-common-1.0-SNAPSHOT.jar

I am modifying this line to add my folder so that it becomes

declare -r app_classpath="/mybundle:$lib_dir/com.foo.simpleproject-web-1.0-SNAPSHOT.jar:$lib_dir/com.foo.abc-common-1.0-SNAPSHOT.jar

then restart my play application using the shell script and my application can read the package correctly.

However, the above work must be done manually, and I would like to externalize it.

What I'm trying to solve is the following: 1. Is there a way so that the package folder that I specify in my build.sbt file can be reused in playback mode?

  • Or, if the above is not possible, during dist playback, is there a way to tell my folder (ie "/ mybundle") to be added to app_classpath as above?

  • build.sbt Play Play?

BTW -classpath script, .. . /simpleproject -classpath "/mybundle" " : -cp". , -classpath -cp.

- ? .

+4
2

? , :

unmanagedResourceDirectories in Compile += file("/mybundle")

, , SBT native packager, script, . script, dist/bin/my-start-script.sh , bin , . , :

libdir=...
java -classpath "/mybundle:$libdir/*" ...
+1

​​ build.sbt:

scriptClasspath in bashScriptDefines ~= (cp => "../../mybundle" +: cp)

declare -r app_classpath="$lib_dir/../../mybundle:$lib_dir/../conf/:etc...

script. , .

0

Source: https://habr.com/ru/post/1533899/


All Articles