In the process of migrating dozens of individual Maven projects to use Maven Tiles, I've hit a challenge in the Netbeans IDE 12.0 -- with all common definitions, like the maven-compiler-plugin including the desired JDK version (11), being centralised in reusable tiles.
The pom.xml looks like this:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.example</groupId>
<artifactId>failing-project</artifactId>
<version>1.0-SNAPSHOT</version>
<name>failing-project</name>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.23</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>my.example.maven-tile:jar-tile:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Running the mvn clean build command directly works fine, and starts out as expected with something like this:
--- tiles-maven-plugin: Injecting 3 tiles as intermediary parent artifacts for my.example:failing-project...
Mixed 'my.example:failing-project:1.0-SNAPSHOT' with tile 'my.example.maven-tile:jar-tile:1.0' as its new parent.
Mixed 'my.example.maven-tile:jar-tile:1.0' with tile 'my.example.maven-tile:build-tile:1.0' as its new parent.
Mixed 'my.example.maven-tile:build-tile:1.0' with tile 'my.example.maven-tile:nexus-tile:1.0' as its new parent.
Mixed 'my.example.maven-tile:nexus-tile:1.0' with original parent '(no parent)' as its new top level parent.
The rest of the build is then behaving as before, like all the common definitions are part of my project's pom.xml.
Unfortunately, Netbeans indicates "Project Problems". Selecting the "Resolve Project Problems" option, brings up a dialog with the following entry:
Custom build participant(s) found
The IDE will not execute any 3rd party extension code during Maven project loading. These can have significant influence on performance of the Maven model (re)loading or interfere with IDE's own codebase. On the other hand the model loaded can be incomplete without their participation. In this project we have discovered the following external build participants:
io.repaint.maven.tiles.TilesMavenLifecycleParticipant
In the absence of an explicit maven-compiler-plugin configuration, Netbeans has to pick some JDK version and choses poorly (JDK 5). That results in all "newer" constructs (e.g. every single lambda expression) to be highlighted as compilation error, making the IDE pretty much unusable.
lambda expressions are not supported in -source 5
(use -source 8 or higher to enable lambda expressions)
- Other IDEs do not appear to have such limitations, but I'd rather find a solution for Netbeans to not force all developers who are used to it, to change.
- This challenge was already identified in the Maven Tiles project, but no solution was presented until it got closed with the comment "closing as no one cares about netbeans anymore.", which I disagree with.
https://github.com/repaint-io/maven-tiles/issues/10
Question is: Is there a way to do one of the following things?
- Allow such an "external build participant" to be included in the Maven project loading.
- Globally enforce a default
maven-compiler-plugin<source>and<target>(and I don't mean the build environment via something like<netbeans.hint.jdkPlatform>JDK_11</netbeans.hint.jdkPlatform>). - Suppress the automatic Maven project loading and rather rely on the explicit "Build" action to be triggered, while still highlighting the actual errors in my code.
EDIT:
Via right-click on the project, one can go to "Properties" > "Sources" > "Source/Binary Format" and select "11" there, which solves the false negatives on the compilation errors but only by inserting the following properties into my pom.xml, which I wanted to avoid, since that may contradict my Tile definition and is unnecessary for other IDEs:
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>