Which JDK's release should I use when coding a sonar plugin? - java

I'm currently coding a plugin for sonar ( custom rules ) . Which JDK and API should I use in order to be compatible for teh majority of sonar instances ? JDK6 ?
Thanks for your response

From the Sonar website
Prerequisite
The only prerequisite for running Sonar is to have Java (Oracle JRE 6
onwards) installed on your machine.
Check more details here

You can use Java 6 onwards It is also mentioned in the SONAR web site.

As said above you can use Java6. Indeed you must use Java6.
When a sonar analysis is launched, the launcher of the analysis (sonar runner or maven) will use your sonar instance as a plugin repository. This means that each jar plugins will be downloaded on the machine performing the analysis. Then each plugin will be asked if it should be executed or not.
Hence, if a plugin is built using Java7, you need to run sonar using Java7 and you also need to run any analysis with Java7, even if this plugin is disabled.

Related

Whether Sonar supports the below languages?

I would like to know whether sonar analyze the below javascript,jquery,knockout.js,languages? if yes is it licensed or free. Can you please share me the link to download this plugin so that we can integrate to analyze this project. We are using sonarqube 5.0.1 version. We are fine for latest sonarqube 6.2 version, But need to know whether it supports?
You can check the link below for a list of Plugins available for Sonar
https://docs.sonarqube.org/display/PLUG/Plugin+Library

Sonarqube difference between sonar way profile and sonarqube java rules repository

What is the difference between the Sonarqube java plugin repository under rules>repository> Sonarqube Java rules and the default profile Sonar way under quality profiles. The first one has 322 rules, while the second one has 229. What is missing from the Sonar way profile? I am using Sonarqube 5.2 server.
First, the version of your Java Plugin is more relevant than the version of your SonarQube server. The server ships with a copy of the Java plugin, but the two are versioned independently, and it can never be assumed that you're running the version of the plugin that ships with the server.
To answer your question, the Sonar Way profiles are designed to be absolutely non-controversial out of the box. So rules about what line '{' should be on, for instance, aren't included. There are also rules that are desirable only in certain coding situations. For instance, not everyone is going to be interested in the proper use of Struts, so those get left off too.

Publishing Sonar analysis on SonarQube Dashboard

We have Eclipse Java EE IDE for Web Developers.
Version: Luna Release (4.4.0)
Build id: 20140612-0600
I have installed SonarQube Plugin in my eclipse and have configured the SonarQube Server. Tested the Server connection in Eclipse.
Windows>Preferences>Sonar>Servers. Connection is successful.
I am able to associate my project to Sonar in eclipse and get the report locally.
After fixing the violated issues , Is there a way we can publish the new report from our Local to the SonarQbe server dashboard.?
First, you appear to be using an old version of the plugin; the most recent version of SonarLint for Eclipse has not yet re-established the connected experience (although that's coming soon). You may be interested in upgrading because SonarLint checks your code as you work; there's no longer a need to trigger the analysis. This way, issues are brought to your attention immediately instead of your having to remember to look for them.
Now to your question: there is not a way to push your updated results from Eclipse directly into the SonarQube platform; you'll need to perform a full analysis. Keep in mind that in-IDE analysis runs most but not all rules. I.e. you're not going to get issues in Eclipse from the rule about too-low coverage thresholds, for instance. Ditto duplicatons. Those are only run as part of the full analysis.

Maven: compile Java 7 with JDK8

I need to ensure one thing before doing it, so I have not yet tested the solution I'll propose.
I have a Jenkins on which one project compiles with a JDK 7 with target Java 7. I have a new project written in Java 8, and I'd like to add it to my Jenkinsfor it to build it too.
As a consequence, I need to install a JDK 8 on the machine. I know we can specify the java compiler version in the pom of each project, but I'm fearing this: once I have installed JDK 8, will my Java 7 project still be able to compile with that JDK 8? Should I have the two JDK installed on the machine, and have a configuration for each project to be able to locate its own JDK? Or will my Java 7 project be able to compile in Java 7 using the JDK 8 ?
Thanks for any help.
As stated in comments, it is possible to install multiple JDKs on Jenkins machine (see this answer as an example) and to configure each job to use a specific one.
Besides, you could perfectly compile your Java7 project using Java8 JDK. However, I advise you not to do that. indeed, if backwards compatibility is enforced at language level, you may find some APIs in which bugs you were unaware of, but the libs you use already knew, have been fixed, creating some weird behaviours. As a consequence, your Java7 application would compile using Java8 JDK, but expose bugs at runtime. And it would be the hell of a nightmare to solve those bugs (believe me, my friend, I've met that kind of horrors in a previous common company).
You can use multiple jdk on your machine, but remember to use specific jdk for specific project. Configure POM file of your project carefully if you have installed multiple jdk. Compiling Source Using Maven
Or you can change JAVA_HOME in the Build Environment section of the job configuration you can set environment variables for the job. Although, you can use multiple JDKs but its not a good practice to in CI/CD. Use specific machines with specific configurations.

How to fix bad version in eclipse plugin?

I am getting this bad version error as shown below. How to fix this. Do I need to have a separate jar file for each version of java?
(source: sourceforge.net)
How to fix this.
Is this a plugin that you created, or did you download it from somewhere?
I've never seen this myself, but I suspect that you are running Eclipse using an older version of Java (e.g. 1.5) and trying to use a plugin that was compiled for Java 1.6. Assuming that is the case you can:
upgrade the JDK used to run Eclipse to 1.6,
try to find a version of the plugin that was compiled for the Java 1.5 platform, or
download the plugin sources and build it for Java 1.5 yourself.
Do I need to have a separate jar file for each version of java?
No. A JAR file built for a Java 1.5 target platform should also work on a Java 1.6 platform. (Just not the other way around ...)
I got similar kind of error once and I was not able to fix it. And I ended up removing the plugin (EMF Plugin) and installing it on a new setup of Eclipse.
Now, I use Yoxos On-demand where you can create/add/remove Eclipse plugins with no effort. This is the best Eclipse customizer I have seen.
You are running on an older version of Java than the code was compiled for.

Categories

Resources