You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Leszek Jadacki (Jira)" <ji...@apache.org> on 2022/10/07 19:38:00 UTC
[jira] [Comment Edited] (MPLUGIN-421) descriptor goal fails when there is .java file present with content that's just a comment
[ https://issues.apache.org/jira/browse/MPLUGIN-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17614225#comment-17614225 ]
Leszek Jadacki edited comment on MPLUGIN-421 at 10/7/22 7:37 PM:
-----------------------------------------------------------------
here you go with full project of plugin:
[https://github.com/Lesjad/descriptor-fail-poc]
A story behind:
At first I was playing with concept of Mojo without changing the maven-plugin-plugin version. My problems started when I wanted to use Stream.forEach( {*}some lambda expression{*}) <- as it is in the code on github.
build of my plugin failed (on maven-plugin-plugin v. 3.2 also on descriptor goal) without any meaningful message (just a number as an error output). To see it you may simply comment/delete maven-plugin-plugin version change in the provided pom.xml and try to mvn install the project
During my investigation I left some .java file that I wanted to use later but didn't want to compile it until I fix unknown (at that time) issue which outputs just a number.. After finding out that the Stream causes the problem I thought about upgrading the maven-plugin-plugin version to the latest. Then my build failed due to .java file without meaningfull code.
v 3.6.4
reads the sources If im not mistaken in following flow:
org.apache.maven.tools.plugin.extractor.javadoc.JavaJavadocMojoDescriptorExtractor (haven't check other DescriptorExtractors)
uses
com.thoughtworks.qdox.JavaProjectBuilder
which is fed with all files with name ending up with .java
then it goes to:
com.thoughtworks.qdox.library.SourceLibrary
where
com.thoughtworks.qdox.parser.impl.Parser
fails when comes to end of file without meaningfull content
was (Author: JIRAUSER296637):
here you go with full project of plugin:
[https://github.com/Lesjad/descriptor-fail-poc]
A story behind:
At first I was playing with concept of Mojo without changing the maven-plugin-plugin version. My problems started when I wanted to use Stream.forEach( *some lambda expression*) <- as it is in the code on github.
build of my plugin failed (on maven-plugin-plugin v. 3.2 also on descriptor goal) without any meaningful message (just a number as an error output). To see it you may simply comment/delete maven-plugin-plugin version change in the provided pom.xml and try to mvn install the project
During my investigation I left some .java file that I wanted to use later but didn't want to compile it until I fix unknown (at that time) issue which outputs just a number.. After finding out that the Stream causes the problem I thought about upgrading the maven-plugin-plugin version to the latest. Then my build failed due to .java file without meaningfull code.
As I went deeper I found out that:
v 3.2 :
uses on it's way
_org.apache.maven.tools.plugin.annotations.JavaAnnotationsMojoDescriptorExtractor_
which is calling method _scan_ on:
_org.apache.maven.tools.plugin.annotations.scanner.DefaultMojoAnnotationsScanner_
which apparently reads code through some library (org.objectweb.asm.ClassReader) from the compiled classes. I'm not sure but I guess that library might not be able to read some up to date constructs.. thut's just my guess
So once I get rid of Stream.forEach construction by for instance replacing it with simple
_List<?> pluginList = {color:#9876aa}project{color}.getBuildPlugins(){color:#cc7832};
{color}{color:#cc7832}
{color}{color:#cc7832}for {color}(Object o :_ _pluginList) {_
_getLog().info(o.toString()){color:#cc7832};
{color}}_
The problem was solved, but I was not satisfied that I cannot use java 1.8 in my plugin..
while:
v 3.6.4
reads the sources differently:
_org.apache.maven.tools.plugin.extractor.javadoc.JavaJavadocMojoDescriptorExtractor (haven't check other DescriptorExtractors)_
uses
_com.thoughtworks.qdox.JavaProjectBuilder_
which is fed with all files with name ending up with .java
then it goes to:
_com.thoughtworks.qdox.library.SourceLibrary_
_where_
com.thoughtworks.qdox.parser.impl.Parser
fails when comes to end of file without meaningfull content :)
> descriptor goal fails when there is .java file present with content that's just a comment
> -----------------------------------------------------------------------------------------
>
> Key: MPLUGIN-421
> URL: https://issues.apache.org/jira/browse/MPLUGIN-421
> Project: Maven Plugin Tools
> Issue Type: Bug
> Components: Plugin Plugin
> Affects Versions: 3.6.4
> Reporter: Leszek Jadacki
> Priority: Minor
>
> Hello,
> As I was learning to create own custom plugin, during development process I decided not to compile one of my Mojo's. For ease I simply commented all its content.
> When trying to build my "custom" plugin _Install_ fails when it executes _descriptor_ goal.
> It seems like when there is a file in the source folder with .java extension but contains only commented lines the compiler omits the file, but the descriptor is taking it into account and fails during parsing the file with error "syntax error @[X,Y]" pointing to it's last line and column.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)