- Saved searches
- Use saved searches to filter your results more quickly
- Instant execution fails on Java Compile Task (no source) when there are only kotlin files in src/main/java #11841
- Instant execution fails on Java Compile Task (no source) when there are only kotlin files in src/main/java #11841
- Comments
- Failed to compile java source files
- [Solved] Java Error Invalid Source Release 18 IntelliJ and Eclipse
- IntelliJ IDEA — Java: Error: Invalid Source Release: 18
- Fixing Invalid Source Release Error in Eclipse
- Conclusion
- [Fixed] Fatal Error Compiling: Invalid Target Release: 11
- Understanding the Error
- Fixing Fatal Error Compiling: Invalid Target Release: 11
- Using Maven
- Using IDE
- Using JAVA_HOME Environment Variable
- Conclusion
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instant execution fails on Java Compile Task (no source) when there are only kotlin files in src/main/java #11841
Instant execution fails on Java Compile Task (no source) when there are only kotlin files in src/main/java #11841
Comments
I am working closely with people from Gradle and JetBrains. While testing instant execution for Android projects I found the following bug.
- Gradle latest nightly: gradle-6.2-20200106230036+0000
- Kotlin versions tested: 1.4.0-dev-74 + latest nightly 1.4.0-dev-589
- AGP versions used (it should not matter here, the build fails in modules not using AGP): 3.5.3, 3.6-rc01, 4.0 alpha 6&7.
The build fails on the second run (both of them are launched using : -Dorg.gradle.unsafe.instant-execution=true , so only the second one actually uses instant execution.
The second build fails for all modules that uses both the java-library and the kotlin plugin when there is no java source files in such modules, but only kotlin source files.
> Task :moduleA:compileJava FAILED > Task :moduleB:compileJava FAILED 1: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':moduleA:compileJava'. > no source files
The problem should be quite easy to reproduce. I use the command line ./gradlew :module:assembleDebug on an android app module that uses modules A and B as dependencies. Module A and B are both using the java-library plugin + the kotlin plugin and both have only kotlin source files (stored in src/main/java). They don’t use any other plugins, especially not the android plugin.
The problem also fully reproduces when calling «./gradlew :module:compileJava`. A simple mono-module sample should be enough to reproduce the problem.
The text was updated successfully, but these errors were encountered:
Failed to compile java source files
- The basics of TOGAF certification and some ways to prepare TOGAF offers architects a chance to learn the principles behind implementing an enterprise-grade software architecture, including.
- Haskell vs. PureScript: The difference is complexity Haskell and PureScript each provide their own unique development advantages, so how should developers choose between these two .
- A quick intro to the MACH architecture strategy While not particularly prescriptive, alignment with a MACH architecture strategy can help software teams ensure application .
- Postman API platform will use Akita to tame rogue endpoints Akita’s discovery and observability will feed undocumented APIs into Postman’s design and testing framework to bring them into .
- How to make use of specification-based test techniques Specification-based techniques can play a role in efficient test coverage. Choosing the right techniques can ensure thorough .
- GitHub Copilot Chat aims to replace Googling for devs GitHub’s public beta of Copilot Chat rolls out GPT-4 integration that embeds a chat assistant into Visual Studio, but concerns .
- Explore the key features of Microsoft Defender for Cloud Apps Monitoring and visibility are crucial when it comes to cloud security. Explore Microsoft Defender for Cloud Apps, and see how .
- 4 popular machine learning certificates to get in 2023 AWS, Google, IBM and Microsoft offer machine learning certifications that can further your career. Learn what to expect from each.
- Navigate multi-cloud billing challenges Keeping track of cloud bills from multiple clouds or accounts can be complex. Learn how to identify multi-cloud billing .
- Security hygiene and posture management: A work in progress Security hygiene and posture management may be the bedrock of cybersecurity, but new research shows it is still decentralized and.
- How to avoid LinkedIn phishing attacks in the enterprise Organizations and users need to be vigilant about spotting LinkedIn phishing attacks by bad actors on the large business social .
- Thoma Bravo sells Imperva to Thales Group for $3.6B With the acquisition, Thales looks to expand its Digital Security and Identity business with an increased focus on protecting web.
- AWS Control Tower aims to simplify multi-account management Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates .
- Break down the Amazon EKS pricing model There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service .
- Compare EKS vs. self-managed Kubernetes on AWS AWS users face a choice when deploying Kubernetes: run it themselves on EC2 or let Amazon do the heavy lifting with EKS. See .
[Solved] Java Error Invalid Source Release 18 IntelliJ and Eclipse
In this short article, we will showcase how to solve java: error: invalid source release: 18.
First, we will take a close look at the main causes behind the error. Then, we will explore different ways of fixing it.
IntelliJ IDEA — Java: Error: Invalid Source Release: 18
In short, The Invalid source release error occurs when there is a JDK version mismatch between the project (specified in Maven) and the IntelliJ structure.
In this case, “source release 18” refers to Java 18.
To reproduce the error, let’s choose Java 8 (1.8) as the main JDK of our project in IntelliJ:
Next, we are going to edit the pom.xml file to specify Java 18 as the value of maven.compiler.source:
Now, if we compile the project using Maven, we will get Invalid source release: 18:
In a nutshell, the root cause of the error is trying to compile a project using a version of Java that is not supported by the JDK configured in IntelliJ.
So to fix the error, we need to upgrade the project version to JDK 18.
To do so, we can select our project, then navigate to:
File -> Project Structure -> Project Settings -> Project -> Project Language Level
Sometimes, we need to make sure to align the version for the Java Compiler as well:
IntelliJ IDEA -> Preferences -> Build, Execution and Deployment -> Compiler -> Java Compiler -> Project bytecode version
Another solution would be removing the maven.compiler.source property and set maven.compiler.target to the same version (1.8 in our case).
Fixing Invalid Source Release Error in Eclipse
Now, let’s see how to reproduce and solve the error in Eclipse IDE.
First, we will set the maven compiler source to Java 18:
maven.compiler.source>18/maven.compiler.source>
Next, we are going to select jdk1.8 as the default JRE in Eclipse:
Now, let’s run the mvn clean install command and view the logs:
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins. . Fatal error compiling: invalid source release: 18 -> [Help 1]
As we can see, the build fails with the excat same error.
So, to fix the issue, we need to make sure that the JRE version of the project is greater than or equal to the one specified in maven.compiler.source.
Conclusion
In this short article, we covered in-depth the java: error: invalid source release: 18.
We see how to reproduce and fix the error both in IntelliJ and Eclipse.
Liked the Article? Share it on Social media!
If you enjoy reading my articles, buy me a coffee ☕. I would be very grateful if you could consider my request ✌️
[Fixed] Fatal Error Compiling: Invalid Target Release: 11
In this short tutorial, we will explore different ways of solving fatal error compiling: invalid target release: 11.
First, we will explain the root cause behind the error. Then, we will demonstrate how to fix it in practice.
Understanding the Error
Typically, the error occurs when we compile a project with a Java/JDK version that is not compatible with the target version.
For example, trying to compile a project that uses Java 8 whereas Maven uses Java 11 will result in fatal error compiling: invalid target release: 11.
Fixing Fatal Error Compiling: Invalid Target Release: 11
Before diving deep into the details, let’s see how to reproduce the error.
First, we will assume that our project is configured with JDK 1.8.
Next, let’s specify another version in Maven. For instance, Java 11:
properties> java.version>11/java.version> /properties>
Now, let’s compile the project using the Maven command mvn compile:
C:\Users\Asus\GIT\employeeapi>mvn compile [INFO] Scanning for projects. . [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE . [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project employeeapi: Fatal error compiling: invalid target release: 11 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:
As we can see in the logs, the compilation fails because the target version Java 11 doesn’t match the project version.
Using Maven
To fix the error, we must set a Java version that is less than or equal to the version of the project.
So, let’s update Maven to use Java 8 instead. To do so, we need to edit the pom.xml file:
properties> java.version>1.8/java.version> /properties>
Alternatively, we can use maven.compiler.target to achieve the same objective:
maven.compiler.source>1.8/maven.compiler.source> maven.compiler.target>1.8/maven.compiler.target>
That way, we tell the compiler to use 1.8 which denotes Java 8.
Please note that using maven.compiler.source is also recommended to avoid the error: java: error: invalid source release.
Now, let’s run mvn compile and see what will happen:
C:\Users\Asus\GIT\employeeapi>mvn compile [INFO] Scanning for projects. . [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ employeeapi --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 14 source files to C:\Users\Asus\GIT\employeeapi\target\classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
As shown above, our project is now compiled with success.
Using IDE
Another solution would be configuring the project with a JDK version compatible with the one specified in Maven.
So, in our case, all we need to do is change the project settings to use Java 11 instead of Java 8:
Using JAVA_HOME Environment Variable
In some cases, the problem could be in the JAVA_HOME. It may denote an older or unused version.
So, to solve the issue, we need to make sure that we installed the proper JDK version:
C:\Users\Asus>java --version java 18.0.1.1 2022-04-22 Java(TM) SE Runtime Environment (build 18.0.1.1+2-6) Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
Then, we need to update the JAVA_HOME environment variable to point to the correct JDK installation:
C:\Users\Asus>echo %JAVA_HOME% C:\Program Files\Java\jdk-18.0.1.1
Conclusion
To sum it up, we explained in detail how to solve the error: fatal error compiling: invalid target release: 11.
Along the way, we highlighted the main cause of the error. Then, we illustrated how to solve it using practical examples.
Liked the Article? Share it on Social media!
If you enjoy reading my articles, buy me a coffee ☕. I would be very grateful if you could consider my request ✌️