Maven Kotlin plugin with JDK 17 not working - kotlin

Upgraded Kotlin from 1.5 to 1.8 today: build fails in JDK 17 due to:
java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.io.OutputStream java.io.FilterOutputStream.out accessible: module java.base does not "opens java.io" to unnamed module #2ba9f986
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at com.intellij.util.io.IOUtil.syncStream(IOUtil.java:217)
tried to add the following to my Maven configuration:
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>${java.version}</jvmTarget>
<args>
<arg>"--add-opens java.base/java.io=ALL-UNNAMED"</arg>
</args>
</configuration>
</plugin>
but the problem is still there.
Official documentation does not seem to provide any info on this. Online search did not find much, apart from something about Gradle
Is there any Maven-plugin configuration to fix it? (ie build Kotlin 1.8 on JDK 17) or is that not supported?

For our Kotlin project build with Maven, We have the following file .mvn/jvm.config in the project folder. The content should be as follows:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED

Related

java: You aren't using a compiler supported by lombok, so lombok will not work and has been disabled

After upgrade, Unable to run the application from intellij IDE.
Intellij version : IntelliJ IDEA 2020.3 (Community Edition)
Build #IC-203.5981.155, built on December 1, 2020
lombok version : 0.32-EAP
Error :
java: You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: com.sun.proxy.$Proxy24
Lombok supports: sun/apple javac 1.6, ECJ
Using lombok 1.18.16 did not work for me. I added the argument below in the build process VM options in
-Djps.track.ap.dependencies=false
Setting:-
Build, Execution, Deployment -> Compiler -> Shared build process VM
options
and it worked
https://github.com/rzwitserloot/lombok/issues/2592
This issue is introduced in IntelliJ IDEA 2020.3 (Community Edition) Build #IC-203.5981.155.
You can fix it by adding this dependency into your project -
Maven -
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
Gradle -
providedCompile group: 'org.projectlombok', name: 'lombok', version: '1.18.16'
For the impatient one (like myself) add
-Djps.track.ap.dependencies=false
to 'Shared build process VM options:'
I had the same issue here after updating my Intellij Community to 20.3.
The issue could be solved by updating the lombok plugin to 1.18.16
Perform this steps to resolve this issue -->
Click on IntelliJ Idea near File Menu from header
Open Preferences
Click on Build, Execution, Deployment
Go to Compile
Inside the User-local build process VM options -> Add this command
-Djps.track.ap.dependencies=false
Apply the changes
Intellij CE Version: 2020.3 Lombok issue fixed by simply updating POM dependency. Example,
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</dependency>
With this version:
Version: 2020.3
Build: 203.5981.155
1 December 2020
I've got this message:
⚠ You aren't using a compiler supported by lombok, so lombok will not work and has been disabled
So,
I added lombok plugin in IntelliJ:
I enabled it:
I downloaded the last lombok Jar: https://projectlombok.org/downloads/lombok.jar
And installed it manually:
Add it in Platform settings
And, now, it works fine!
PS: The version of my project Lombok dependency is 1.18.8 while the one of the downloaded plugin installed jar in platform settings is 1.18.16.
Go to IntelliJ | Preferences | Build, Execution, Deployment |
Compiler Find Build process VM options or Shared build process VM
options Add string -Djps.track.ap.dependencies=false into the text
box Hit save
java: You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: com.sun.proxy.$Proxy27
Lombok supports: sun/apple javac 1.6, ECJ
Upgrade your lombok version by adding below dependencies for gradle, as this is the version supported by updated Intellij 2020.3:
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
In my case, I had a dependency module running in the project that used another version of lombok. Another spring-boot version to be more precise. With it's BOM comes another lombok version.
My project has lombok in version 1.18.16 yet intellij 2020.3 refused to compile my code and above answers did not help:(.
Eventually tweeking in settings->"build,execution,deployment"->compiler->"annotation processors" worked :). Make sure to enable "annotation processing" and "obtain processors from classpath" checkboxes .
screenshot
Solved it by using the maven-compiler-plugin configuration and specify the annotationProcessorPaths as follows:
Note I also have mapstruct, so hence the extra paths.
inside build/plugins:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${mapstruct-processor.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
My dependencies:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
My properties:
<java.version>11</java.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<mapstruct.version>1.4.2.Final</mapstruct.version>
<mapstruct-processor.version>0.2.0</mapstruct-processor.version>
<!-- Bumped version of lombok temporarily to avoid issues with IntelliJ 2020.3+ until we have upgraded to a more recent version of spring boot. -->
<lombok.version>1.18.20</lombok.version>
Note:
I override the lombok version to 1.18.20 since I'm still on an older version of spring boot which uses 1.18.12 under the hood...
I had the same error and I solved updating IntelliJ to 2021.1.1 version:
IntelliJ IDEA 2021.1.1 (Community Edition)
Build #IC-211.7142.45, built on April 30, 2021
Another cause could be that you updated the lombok version and forgot to update the version of the lombok plugin:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<!-- needs to match -->
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.20.0</version>
<!-- [...] plugin config -->
</plugin>
For me, I disabled the bundled Lombok plugin. Then enabled it again and reloaded the maven project. Boomshakalaka.
Lombok 1.18.22
IDEA 2021.3 #IU-213.5744.223
Somehow I couldn't make it work no matter what options I tried in the settings. I finally managed to make it work by following the bare instructions on lombok with ecj page. I downloaded lombok.jar and added this in the Shared build process VM options :
-Djps.track.ap.dependencies=false -javaagent:/path/to/lombok/jar/lombok.jar=ECJ
This was using this system :
IntelliJ IDEA 2022.1.4 (Ultimate Edition)
Build #IU-221.6008.13, built on July 19, 2022
Macbook pro with a M1 pro
add scope as provided <scope>provided</scope>.
This will not give any issues on compile time
You need to enable the bundled plugin.
Since version 2020.3 the Lombok plugin is build-in, you don't need to download a separate plugin (which won't work anymore). Find it in installed plugins (not in marketplace) and simply enable it.
That plugin doesn't have homepage link anymore and has a different description.

Tell IntelliJIdea to use specific JDK version, not just JDK8, but jdk-8u201

After a switch to JDK8 the MANIFEST.MF Attributes started returning null
https://bugs.openjdk.java.net/browse/JDK-8201636 suggests that this is a bug introduced by Oracle in JDK 8u151-8u172.
I use pom.xml and IntelliJ IDEA. pom.xml specifies (tags < and > removed)
<maven.compiler.target> 1.8 </maven.compiler.target>
<maven.compiler.source> 1.8 </maven.compiler.source>
IDEA settings show target bytecode version 1.8
JAVA_HOME set to JDK10
I have C:\Program Files\Java\jdk1.8.0_201 installed.
How to specify this version for the builds. Also does pom.xml trump IDEA project settings or vice versa?
Edit:
I've specified
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<!--executable>{JAVA_1_8_HOME}/bin/javac</executable-->
<executable>C:/Program Files/Java/jdk1.8.0_201/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
Intellij still defaults to JDK 1.5 and chokes on List<String> a = new ArrayList<>(); with "I don't understand <> with JDK1.5".
maven.compiler.target and source are nothing to do with it. Those are just arguments passed to javac.
If you want to specify the version of javac explicitly, you can use the Maven Compiler Plugin.
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
Otherwise the javac from the Project SDK will be used (Project Structure > Project).

Intellij ignoring Project java source level

Note: this is not a duplicate. This version of spark requires either jdk 1.7 or 1.8. The parent pom.xml entry is shown here:
<java.version>1.7</java.version>
As shown in the screenshot we have java 1.8 for the SDK and the language level:
And here are the modules settings:
But Intellij is just confused about that:
Error:(73, 51) java: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
This is a spark project being built from maven on OS/X. Intellij Ultimate 14.1.4
Update Here is the pom.xml entry for the jdk
If you are using Maven, please watch your pom.xml file. Even if your IntelliJ Project is set to Java 8 your project will compile with the version of Java set in your pom.xml.
Add this to your pom.xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Or directly in the maven plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.8</source> <!-- java version here -->
<target>1.8</target> <!-- java version here -->
</configuration>
</plugin>

org.jibx: maven-jibx-plugin:1.2.1 - Error reading path

I am trying to execute a goal using maven-jibx-plugin version 1.2.1, but I am getting the following error:
[ERROR] Failed to execute goal org.jibx:maven-jibx-plugin:1.2.1:bind (default) on project XoXcertExIm: Error loading class java.lang.CharSequence: Error reading
path java/lang/CharSequence.class for class java.lang.CharSequence -> [Help 1]
I am using Maven 3.2.5, Java versions 1.8.0_11, and windows 7 as the OS.
There is an issue on Jibx to support Java 8 see Issue here
There is a Workaround in this comment that you can try.
I had the same problem...
Workaround was as easy as include newer "bcel" dependency to the plugin "maven-jibx-plugin":
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.6</version>
<dependencies>
<!-- Workaround to avoid error compiling with JDK 1.8 -->
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
You should include a new Maven repository definition in your "settings.xml" to get the new dependency:
<repository>
<id>apache-snapshots-repo</id>
<url>https://repository.apache.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
Regards

building maven flex project with flex mojo depending on apache sdk fail

I have a mavenized flex project wich builds fine with adobe sdke 4.6.
Now , i'm trying to compile it with apache recent sdk .
I mavenized the sdk and copied the dependencies in local repo .
the apache version that i mavenized is : 4.13.0.20140701 .
my pom is as below :
<properties>
<flexmojos.version>7.0.1</flexmojos.version>
<flex.version>4.13.0.20140701</flex.version>
<flash.version>11.1</flash.version>
</properties>
<build>
<sourceDirectory>src/main/flex</sourceDirectory>
<plugins>
<plugin>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>${flexmojos.version}</version>
<extensions>true</extensions>
<configuration>
<debug>true</debug>
<sourceFile>ComptaFlex.mxml</sourceFile>
<services>${basedir}/src/main/flex/services/services-config.xml</services>
<compilerWarnings>
<warn-no-constructor>false</warn-no-constructor>
</compilerWarnings>
</configuration>
<dependencies>
<!-- This handles a bug in maven which causes problems with flex resources -->
<dependency>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-threadlocaltoolkit-wrapper</artifactId>
<version>${flexmojos.version}</version>
</dependency>
<!-- Without this FM will use the compiler configured in its master
pom, which will result in version conflicts -->
<dependency>
<groupId>org.apache.flex</groupId>
<artifactId>compiler</artifactId>
<version>4.13.0.20140701</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
<plugin>
I got maven compile error as :
xmojos.oss:flexmojos-flex-compiler:jar:7.0.1 -> net.flexmojos.oss:flexmojos-generator-internal-compiler-iface:jar:7.0.1 -> org.apache.flex:compiler:pom:4.12.1.20140427: Failed to read artifact descriptor for org.apache.flex:compiler:pom:4.12.1.20140427: Could not transfer artifact org.apache.
it seems that flex mojo always use a default apache version and ignores mine provided . how could i force flexmojo build with my given version .
Flexmojos-maven-plugin version 7.0.x is built using FDK 4.12.1.20140427. This FDK declared as dependency to this maven plugin.
You need firstly mavenize FDK 4.12.1.20140427 and put it to you maven repository. Only after that you can mavenize other versions of FDK.
A dirty work around is to change flexmojo-parent pom file : and edit by hand :
<flex.version>4.13.0.20140701</flex.version>
until flexmojo developpers comes with a better response .
I have written quite a bit of documentation lately, please check-out at: https://cwiki.apache.org/confluence/display/FLEX/Preparing+FDKs+for+Maven+builds
The short version:
We have created a maven extension that should automatically download and install Flex SDKs as they are referenced in the maven build. Also Flexmojos 7.1.0-SNAPSHOT has been updated to no longer contain a reference to any FDK artifact. Also we now use 3-segment versions such as: 4.14.1