Executing java program and writing files inside the files structure of Bazel - bazel-java

I’m using a “ctx.action.run” command to execute a java.jar program.
The java program uses as imputs “bazel-bin/src/files”, which are a preprocessing step of a special C precompilation. This java edit the precompilated files and mix them, and the returns this post-edited file that have to be written in the bazel file structure.
The java program can’t run inside the bazel sandbox?
I tried installing the program under the bazel structure of directories, but the error persists
How bazel permit the java execution in it sandbox? and how this java program can write insithe files structure of bazel?

If you are using ctx.action.run this is how we execute the binary target. Can you elaborate your query with more details like what is error or problem seeing while doing the above.

Related

"Failed to load dynlib/dll" error for libdmtx.dll when running an executable generated by auto-py-to-exe

I am using the library pylibdmtx to generate a data matrix in my python script. Since the library uses the dll libdmtx.dll, I added it to the "Additional Files" (--add-data) section of auto-py-to-exe.
When I run the executable on my computer where I wrote developed the python project, the executable works perfectly but when I transfer the executable to a different computer and try running it there, I get the Failed to load dynlib/dll error.
I checked the temp folder that the executable was creating and using and found libdmtx.dll to be present there. I am not sure why the executable works only on my computer but not the others. Am I missing adding any other dependencies for libdmtx.dll?
Image of the error when the executable is run

Why are Java binaries necessary in Sonar?

I'm trying to check if there are any difference between an analysis with only source code and with source code and the .jar generated after compiling.
If I delete the '-Dsonar.java.binaries' property I get this error:
ERROR: Error during SonarQube Scanner execution
ERROR: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The command I'm using:
sonar-scanner '-Dsonar.host.url=http://192.168.1.25' '-Dsonar.projectKey=org.javaProject:myProject' '-Dsonar.projectName=myProject' '-Dsonar.sourceEncoding=UTF-8' '-Dsonar.sources=src' '-Djavax.net.ssl.trustStore=/certs'
Do you know if it is possible only to analyze source code without any binary file?
For SonarQube to be of any significant value, it should be run as part of a build, after the code is compiled and unit tests are run. I frankly don't know if it's possible to run a scan without class files, but I don't suggest you try to pursue that.
If you really only want to look at static analysis issues, I believe there is a "Sonar Lint" tool that runs in Eclipse or possibly other desktop tools.

How can I build liquidfun library with cmake?

I am trying to run SFML-LiquidFun-Water-master open source file (https://github.com/alextrevisan/SFML-LiquidFun-Water) on VS2015, but it had some errors (such as there is no proper library "Box2D", "Liquidfun"), I realized that I have to install liquidfun librabry and bring it to the source code which I want to run. I downloaded liquidfun library from https://github.com/google/liquidfun and Cmake from https://cmake.org/ and followed instructions based on here http://google.github.io/liquidfun/Building/html/md__building_windows.html but It keep saying that there is no such command name Cmake whatever.. What am I supposed to do to run source code thank you!!

Packaging a Jython program in an executable jar

I am trying to package a jython program into an executable jar which the user can simply double-click to run without installing jython ahead of time. Ultimately, I would like to include an additional library which I wrote with the jar, but at the moment I am just trying to package a simple program and have it run from the jar.
I have tried following the jar instructions in the "Using the Jar Method" section here: Jython FAQ: Using the Jar Method
I have also looked at slides 25-28 here: Jython Update 2012 slides
And finally here:
stackoverflow Question: Distributing My Python Scripts as Jars with Jython
I have installed jython 2.5.3, jvm 1.6, and python 2.7.3 on my mac which is running OS X 10.8.3.
These are the steps I go through to create the jar and run it:
Create a copy of jython.jar from my jython installation directory.
zip -r jython_copy.jar Lib (where Lib is the folder in the jython installation directory)
cp myJythonProgram.py __run__.py (myJythonProgram.py does not include an 'if name == main' line)
zip jython_copy.jar __run__.py
export CLASSPATH=/path/to/my/app/jython_copy.jar:$CLASSPATH
I have tried running the jar using all three of these methods:
java org.python.util.jython -jar myapp.jar
java -cp myapp.jar org.python.util.jython -jar myapp.jar
java -jar myapp.jar -jar myapp.jar
This works if my program doesn't use any import statements.
However I am running into an issue where some python packages are not able to be found when I run the jar. For instance, I get the error "ImportError: No module named random" when I include the line from random import random in my program. No errors occur on lines in the program when I import from javax.swing, java.awt, time, or math.
Additionally, I tried to package a jar with my library and a jython program which imports my library using the previous steps as well as the following additional steps:
zip jython_copy.jar myLibrary.jar
jar ufm jython_copy.jar othermanifest.mf
othermanifest.mf only contains the line Class-Path: ./myLibrary.jar.
This too gives the error "ImportError: No module named myLibrary"
I would appreciate any insight into what I am doing incorrectly or other steps I should take.
Thanks!
I realized what the problem was and I wanted to document it in case anyone else has the same problems.
I was using the jython.jar file that came in the standard installation of Jython, and NOT the standalone jython.jar (the instructions at Using the Jar Method mentions this, but the instructions at Building Jars do not). I am still unsure why copying the Lib/ folder of the standard installation into the jython.jar that came with that installation didn't work on my system. However, once I used the standalone jar, things started to work more smoothly.
Additionally, I was able to get my library to work with the packaged file by doing three things in addition to the steps I laid out in my question:
Exploding the standalone jython.jar and copying the folder with all of my library files into Lib, then create a new jar. This seemed to be the easiest way to include my library and allows me to package everything into a single jar.
I discovered after reading Frank Wierzbicki's answer in Why does Jython refuse to find my Java package? that because I am now using the standalone jar, I could no longer use imports of the style from java.awt import *, instead I needed to fully specify each thing I was importing, for example from java.awt.Font import PLAIN, BOLD, ITALIC. So I went through the library's imports and fixed the few that were of the wrong style.
Now that I am adding my Library directly to the Jar's Lib folder, instead of writing Class-Path: ./myLibrary.jar in othermanifest.mf, I put Main-Class: org.python.util.JarRunner as per Frank Wierzbicki's answer in the post I mentioned in my question: Distributing my Python scripts as JAR files with Jython?
This allowed me to create a double-clickable executable jar containing my library and jython file that I wanted to run.
There are two solutions. They both work, but one better than the other.
I believe you can rename your python script as __run__.py, place that file inside the .jar file, and pass the .jar file through a python interpreter. See https://wiki.python.org/jython/UserGuide#invoking-the-jython-interpreter for more.
Multiple methods to run Jython from the java code while running through JVM are described here, at the Jython documentation.
EDIT:
You can execute a command line code that runs the python file you want.
Link to an example of running command line code from java here.

CMake/CTest & gcovr: filename extensions?

After compiling with CMake with flags --coverage, and running my boost unit test programs, files with extension .cpp.gcda and .cpp.gcno are created. If I then run gcovr it claims it cannot find the .gcno files (error message ".gcno:cannot open graph file"). I could possibly move all output files but that would be really awkward/silly.
Related problems of other people could be solved by using CTest but as I am using Jenkins I'd like to stick to gcovr and use the cobertura xml output.
Ps. Maybe I should simply ask: how should I combine CMake with gcovr?
This is the solution we are using for the same setup inside jenkins: http://www.semipol.de/archives/320. You can simply grab the CMake macro from the linked RSC library for your own purposes.
Apart from that read something about a slightly changed format of the coverage files in recent gcc versions and it seems gcovr didn't keep up with that. But I cannot remember where I read this.