Ant sonar command not works - ant

I am trying to insert sonarqube setup on build.xml, getting unsupported error.
My build Java version support 1.6
Ant.sonar.qube support 2.5
If I use have version 1.8 my ant sonar command is working.ant command is not working.if I use java 1.6 ant is working and ant sonar is not working.

You already know exactly what your problem is:
If I use have version 1.8 my ant sonar command is working
...
if I use java 1.6 ant is working and ant sonar is not working.
You're facing incompatibility with the version of Java you're trying to use. Since analysis will not work with 1.6, you're best off upgrading to Java 8 and working to make whatever your other Ant target is work with that.

Related

Java code is 1.8 supported, SonarQube version supports Java 11, the build fails in Jenkins

folks!
I have 2 separate servers on Linux for Jenkins and Sonarqube. The code is written in Java 1.8 and can be compiled using Jenkins. Everything works fine.
It fails at the SonarQube step because our SonarQube uses Java 11, and it fails with this error.
ERROR: Error during SonarScanner execution java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
How can I fix this?
You have to run the sonar scanner with at least Java 11, no matter what version of Java your application supports.
Two years ago I had a similar issue. I don't know if your app and sonarqube should run on the same machine (as it was in my case).
If yes, just install both versions of java and set the path of Java 11 to SonarQube settings.
According to sonarqube community, you should do the following:
Edit conf\wrapper.conf, specifically the wrapper.java.command to following:
wrapper.java.command=C:\Program Files\Java\open jdk-11.0.2\bin\java
#wrapper.java.command=java

Jenkins: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

I am facing issue in jenkins job(jenkins running docker) Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
I have checked java version in docker it is openjdk version "11.0.12" 2021-07-20
we can solve this in Android Studio but how can we solve while running gradle build in jenkins.
Below is the error I am getting
Build file '/var/jenkins_home/workspace/CICDDemo_master/app/build.gradle' line: 2
What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
In your Jenkins project choose the "configure" tab on the left side, then scroll down to "Properties Content" and write there:
JAVA_HOME=C:\Program Files\Java\jdk-11.0.12
GRADLE_USER_HOME=C:\

ant Unsupported major.minor version 52.0

This is driving me nuts.
When running any ant command (even ant -version), I always get the following error on Mac OSX:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0
I removed and re-installed ant entirely, and still get the same error.
For our company we have to run Java7 to run the command, so I created an alias.
This used to work, I'm not sure what changed.
I see you have java 1.7 installed and post that you have installed Ant 1.10.
Ant 1.10 requires jdk 8
Refer : http://ant.apache.org/
The Apache Ant team currently maintains two lines of development. The
1.9.x releases require Java5 at runtime and 1.10.x requires Java8 at runtime. Both lines are based off of Ant 1.9.7 and the 1.9.x releases
are mostly bug fix releases while additional new features are
developed for 1.10.x. We recommend using 1.10.x unless you are
required to use versions of Java prior to Java8 during the build
process.
Try using Ant 1.9.x if you can't use java 8
Here is a list of minimum java version for given ant version

Java 8 version with an Ant/Jenkins build

I have a project that build with ant 1.9.4 and java 1.8.0_121 on machine A using Jenkins. But if I move the same project to a machine with the same versions of Ant and Jenkins but with java 1.8.0_131, my build fails.
Is there a way to make an ant build succeed with any Java 8 version without installing a different version of Java 8?
Thank you!
Since I am on a Linux RHEL, I had to increase the memory size configuration for JiBx in the /etc/security/limits.conf file.

build Grails 3 war with specific java compiler version

I am using IDEA 15. I have a grails 3 project setup. The app server I need to deploy to has Java Version 7. My local JDK is Java 8. I have set some properties in my build.gradle to use the target version 1.7.
apply plugin: 'java'
compileJava {
targetCompatibility = '1.7'
}
When I rebuild my project, it generates class files for 1.7, but when I run a maven war build from the IDEA menu, the classes are rebuilt and end up being Java 8 versions. I have set Java version in my project to 1.7 as well, but this did not help. How can I get to where I am producing a war file from my grails app that contains 1.7 versioned class files?
Thanks!
What are you using to build war file? "grails war" or "gradle war". Try to use gradle.

Resources