0

I am deploying a Python app that has a package requiring some Java dependencies. I added a requirements.txt file as well as a pom.xml file to my repo and it seems that the Java dependencies aren't being picked up. Is there anything I need to add to my Procfile to make this work?

Some more context below:

I'm trying to deploy and use SuTime -- a python wrapper for a JAVA-based model by the Stanford NLP group -- with Heroku.

I am not familiar with Java and trying to figure out how to install the required dependencies.

The documentation mentions running the following command, which worked for me locally, but I haven't had any luck with Heroku. I guess it's just trying to generate a pom.xml file which if I'm not mistaken is the equivalent of requirements.txt for Java.

mvn dependency:copy-dependencies -DoutputDirectory=./jars -f $(python3 -c 'import importlib; import pathlib; print(pathlib.Path(importlib.util.find_spec("sutime").origin).parent / "pom.xml")')
  • 1
    Thanks for updating this. I have it open in a tab and will play with it a bit later. The order of operations here is tricky (you need Java to run Maven, but the Maven dependency file is part of a Python library) and you also need to run a custom build command. It's not as straightforward as most other "need Python and Java in the same Heroku app" questions. – ChrisGPT was on strike Feb 10 '22 at 19:25
  • Appreciate it, Chris, thank you. – Christian Adib Feb 10 '22 at 19:33
  • @Chris, I think I can simply just add the Maven dependency file to my Python repo if it helps with the concurrency issue. In that case, I would just need to tell Heroku to build the dependencies. Unless I'm missing something. – Christian Adib Feb 10 '22 at 20:53
  • 1
    I don't think it's that simple. To install Java dependencies you need another buildpack, and buildpacks run in a particular order. Your last buildpack should be the one for the language your app is built in—Python in your case. But your Java dependencies are declared _in_ one of your Python dependencies. If you try to run the command you show above before your Python dependencies are installed, they won't be found. I'm not sure if there's a way to run your main buildpack before others. – ChrisGPT was on strike Feb 10 '22 at 21:24
  • 1
    On top of that, `mvn dependency:copy-dependencies` isn't a standard command that gets run for Java dependencies, and as far as I know neither the Python buildpack nor the JRE buildpack supports custom commands. So you'll probably need a _third_ buildpack to run that command. Options are to cobble this together with existing buildpacks (likely possible but will require some trial and error) or to create your own buildpack. – ChrisGPT was on strike Feb 10 '22 at 21:26

0 Answers0