Open Reqeique opened 2 years ago
One thing, use this as the example of code. I believe once your present code creates and runs through the fat, it will not change the LED. https://github.com/Pi4J/pi4j-example-minimal
I created a clone of this example successfully ran it.
FAT used info from https://pi4j.com/documentation/building/fat-jar/ and example https://github.com/Pi4J/pi4j-example-fatjar to copy the needed edits to the pom file.
I edited the pom file to add the FAT specific details . Was able to: mvn clean package, cd into target/distribution and sudo java -jar pi4j-example-fatjar.jar
Give me a minute and I will attach my pom
hope this help. Tom
I could see you prefer gradle to build. I used the example testcase from above and added gradle to it. I see an error. I normally use maven so all this is a matter of digging and I have not found an answer. I do see that running under gradle build there are fewer providers loaded.
Maven these output providers.
├─DIGITAL_OUTPUT: [3]
Using gradle only
└─PROVIDER: "RaspberryPi Digital Output (GPIO) Provider" {raspberrypi-digital-output}
My error is Exception in thread "main" com.pi4j.provider.exception.ProviderNotFoundException: Pi4J provider [pigpio-digital-output] c
Was this your initial error when you said a 'lib' was not found ?
@taartspi that was absolutely the error that I faced while fatJaring for the first time but was resolved easily(not considering the last exception)
Hi did you solve this problem?
I got the same exception. If I run my code on my computer in Intellij IDEA with the Embedded Linux JVM plugin, then the code works well (GPIO Out turns HIGH and Input is detected, ecc..).
If I create a fatjar with gradle, copy the file to my RPI4 and execute it with java -jar, then I got the same exception (Provider not found).
On the webside is described how to create a fat jar with Maven: https://pi4j.com/documentation/building/fat-jar/.
So I try now to use this plugin: https://github.com/dkorotych/gradle-maven-exec-plugin
with the goal to execute the described maven commands/plugins through gradle, but I'm still struggling
@RLEO94 for Provider not found
you could easily tweak it by modifying the fatjar to include the the library that wasn't found manually by using tools like win-rar or creating custom jaRing method as above(that was taken from here
) to include all dependencies
overall can't guarantee wouldn't throw Method [create([class java.lang.Integer])] could not be resolved in provider
Hi Thanks for your help. I will give it a try :)
Hey @Reqeique, I'm not sure if you were able to solve this issue, but I managed to solve it by checking out pi4j-kotlin & using shadow plugin & configuring the below gradle task
tasks.named("shadowJar", ShadowJar::class.java) {
mergeServiceFiles()
manifest.attributes["Main-Class"] = "MinimalExampleKt"
}
This is worth including in the docs alongside the maven Uber Jar document. More information can be found in shadow: merging-service-descriptor-files.
I was currently experimenting with pi4j but when I start to fat Jar it, it kept throwing exception my first attempt was to utilize shadowJar, which wasn't able to jar all the necessary libraries resulting
lib wasn't found exception
so I put all the necessaryjar
files manually but gaveMethod [create([class java.lang.Integer])] could not be resolved in provider [pigpio-digital-output(com.pi4j.plugin.pigpio.provider.gpio.digital.PiGpioDigitalOutputProviderImpl)]; Overridden instances of 'create()' are not supported unless defined as default methods in the provider interface
following that I tried my third attempts which was to utilize built in jaring method using the following codebut throws the same execption no luck! Note: the code i used was from https://pi4j.com/documentation/io-examples/digital-output/ which was then converted to kotlin