Hello guys,
I have a quick question on how Sonarqube works, im not really sure here is the correct place to ask. Please help move this to the correct section if i made a mistake. Thanks
Currently I am using Sonarqube version 9.4 and my application is build using Java 8. According to documentation here , if my application is run on java 8, i need to change the jdk8 version for build and then change to java 11 to run the sonarqube. Below is the jenkins code snippet on how i run the scan
stage("build") {
tools {
jdk "jdk8"
}
steps {
sh '''
echo $JAVA_HOME
/var/jenkins_home/tools/hudson.plugins.gradle.GradleInstallation/gradle/bin/gradle clean build -p integration --refresh-dependencies --no-daemon --stacktrace -x test
'''
}}
stage("integration") {
tools {
jdk "jdk11"
}
steps {
echo '------- Start to do sonarqube -------'
withSonarQubeEnv('SonarqubeEnt') {
sh '''
echo "test-2:integration"
export JAVA_HOME=/usr/lib/jvm/jre-11-openjdk-11.0.17.0.8-2.el7_9.x86_64
/var/jenkins_home/tools/hudson.plugins.gradle.GradleInstallation/gradle/bin/gradle sonarqube -p integration -Dsonar.host.url=http://[URL]:9000 -
Dsonar.login=[username] -Dsonar.password=[password] -Dsonar.projectKey=test-2:integration -Dsonar.branch.name=gatedcheckin-20221208142521696110803001178214696-0-integration --no-daemon --info
'''
}
echo '------- End to do sonarqube -------'
}
}
If i understand correctly, i have build the java using java8 and i run the gradle sonarqube using java 11.
But I keep gettig an error about a dependency that already depreciated in Java 11
> Task :utils-ext:compileJava
file or directory '/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/rfid-server/src/main/resources', not found
file or directory '/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/main/java', not found
Task ':utils-ext:compileJava' is not up-to-date because:
No history is available.
All input files are considered out-of-date for incremental task ':utils-ext:compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
file or directory '/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/main/java', not found
Compiling with JDK Java compiler API.
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/excel/poi/NumericPoiColumn.java:10: warning: Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
@Data
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/excel/poi/BlankPoiColumn.java:8: warning: Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
@Data
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/excel/poi/FormulaPoiColumn.java:8: warning: Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
@Data
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/excel/poi/CurrencyPoiColumn.java:8: warning: Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
@Data
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/excel/poi/DatePoiColumn.java:10: warning: Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
@Data
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/excel/poi/StringPoiColumn.java:12: warning: Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
@Data
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/BaseReqRespLogUtil.java:10: error: package javax.xml.bind does not exist
import javax.xml.bind.JAXBElement;
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/JAXBElementAdapter.java:7: error: package javax.xml.bind does not exist
import javax.xml.bind.JAXBElement;
^
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/JAXBElementAdapter.java:10: error: cannot find symbol
public class JAXBElementAdapter extends TypeAdapter<JAXBElement> {
^
symbol: class JAXBElement
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/JAXBElementAdapter.java:12: error: cannot find symbol
public void write(JsonWriter out, JAXBElement value) throws IOException {
^
symbol: class JAXBElement
location: class JAXBElementAdapter
/var/jenkins_home/jobs/gatedcheckin-20221208155206534110803008455871066-0/workspace/utils-ext/src/com/abl/util/JAXBElementAdapter.java:22: error: cannot find symbol
public JAXBElement read(JsonReader in) throws IOException {
^
symbol: class JAXBElement
location: class JAXBElementAdapter
5 errors
6 warnings
> Task :utils-ext:compileJava FAILED
:utils-ext:compileJava (Thread[Task worker for ':',5,main]) completed. Took 2.872 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':utils-ext:compileJava'.
> Compilation failed; see the compiler error output for details.
Can anyone help me understand why I get this error if i already build the application using Java8, why the gradle sonarqube still build the application using Java 11. Am i missing anything?
Do let me know if you need any more information.
Thank you.