简体   繁体   中英

Running a maven project and a python file through shell script

I am working on a maven project that has its source file in JAVA. I had to add some functionality in the project through some already written code. But these new files were written in PYTHON. Hence I decided to make a shell script that can run both the java and python files with desired args. But since my java source files are in the maven project, I am not able to write a shell script without exploiting the structure of the maven project. So, how can I run the above files without ruining the structure of my maven project?

As Andersen mentioned that Maven can compile and execute.java files, it means it is only specific to java. For python files, you need setup.py to build python based project. You can not directly call a function written in Python from Java class. Now coming back to your requirements, I can think that you have to build separately java project using Maven with the command mvn clean install and you have to run setup.py if available in python project. Since you cannot call a python function from java class, you have to create an exe file in python using pyinstaller or using py2exe and you invoke the exe file from java. The above I mentioned in one of the approaches. Another approach is to rewrite the python code in java and build using maven. This will be the good approach based upon the requirement. Besides, if you are interested to build java project using Maven and you want to build python project, you can write a.bat file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM