Re: Maven plugin fails when a class compiled for Java 9 is present in a jar running in Java 8.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maven plugin fails when a class compiled for Java 9 is present in a jar running in Java 8.

Ralph Goers
FWIW, building the jar as a multi-release jar did fix this problem, but building a multi-release jar with Maven is a bear to do. I have to invoke the compiler plugin first to compile the pre-java9 classes using the java 7 or 8 compiler, call the maven-bundle-plugin, call the maven-helper-plugin to add the java9 source directory, call the compiler plugin again with the java9 toolchain, call the antrun plugin to move the java9 classes to the proper META-INF location (because there is no way to tell the compiler plugin to put them in the correct place and the antrun plugin doesn’t support toolchains so it can’t be used to compile) and then call the jar plugin. The maven-bundle-plugin doesn’t support multi-release jars so it has to be called before the java9 classes are created.

Ralph

> On Jun 15, 2017, at 4:42 PM, Ralph Goers <[hidden email]> wrote:
>
> I have a plugin that uses a jar that doesn’t have any Maven plugin annotations in it but does have classes compiled for Java 9 in it that are only used when executing on Java 9. Loading of the plugin is failing because the annotation scanner can’t read the class. What do I need to do to prevent annotation scanning on that dependency? Would this work if the dependency was in multi-release format?
>
> Here is the relevant stack trace.
>
> Caused by: java.lang.IllegalArgumentException
> at org.objectweb.asm.ClassReader.<init>(Unknown Source)
> at org.objectweb.asm.ClassReader.<init>(Unknown Source)
> at org.objectweb.asm.ClassReader.<init>(Unknown Source)
> at org.apache.maven.tools.plugin.extractor.annotations.scanner.DefaultMojoAnnotationsScanner.analyzeClassStream(DefaultMojoAnnotationsScanner.java:214)
> at org.apache.maven.tools.plugin.extractor.annotations.scanner.DefaultMojoAnnotationsScanner.scanArchive(DefaultMojoAnnotationsScanner.java:145)
> at org.apache.maven.tools.plugin.extractor.annotations.scanner.DefaultMojoAnnotationsScanner.scan(DefaultMojoAnnotationsScanner.java:112)
> at org.apache.maven.tools.plugin.extractor.annotations.scanner.DefaultMojoAnnotationsScanner.scan(DefaultMojoAnnotationsScanner.java:79)
> at org.apache.maven.tools.plugin.extractor.annotations.JavaAnnotationsMojoDescriptorExtractor.scanAnnotations(JavaAnnotationsMojoDescriptorExtractor.java:124)
> at org.apache.maven.tools.plugin.extractor.annotations.JavaAnnotationsMojoDescriptorExtractor.execute(JavaAnnotationsMojoDescriptorExtractor.java:103)
> at org.apache.maven.tools.plugin.scanner.DefaultMojoScanner.populatePluginDescriptor(DefaultMojoScanner.java:96)
> at org.apache.maven.plugin.plugin.AbstractGeneratorMojo.execute(AbstractGeneratorMojo.java:283)
> at org.apache.maven.plugin.plugin.HelpGeneratorMojo.execute(HelpGeneratorMojo.java:92)
> at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>
> Ralph
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...