Hello,
I am currently trying to build a custom plugin from example plugin git repo. Basic use of this plugin is onces the analysis starts our plugin also trigger an analysis.
Problem:
I put all our resources including main_jar and rules inside resources direactory. However, I am not able to access the jar file path.
What could be the problem here ? I already tried to extract the resources in temp directory and it’s working but I think there should be more concreate solution to this problem.
For what it’s worth, this code let me access a .jar file in the src/main/resources directory of my sample Java project.
package com.example;
import java.io.File;
import java.net.URL;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) {
URL resourceUrl = App.class.getClassLoader().getResource("SSLPoke.jar");
if (resourceUrl != null) {
try {
File jarFile = new File(resourceUrl.toURI());
ProcessBuilder pb = new ProcessBuilder("java", "-jar", jarFile.getAbsolutePath());
pb.inheritIO();
Process p = pb.start();
int exitCode = p.waitFor();
System.out.println("Process exited with code: " + exitCode);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
I think without a complete sample project from you, it will be hard to debug further. This is probably also a general Java coding question better suited for a forum like StackOverflow (since it’s not involving any specific SonarQube APIs)