mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
105 stars 76 forks source link

Xjc with generateEpisode=false throws Exception #169

Open isotes opened 3 years ago

isotes commented 3 years ago

The error can be reproduced with the integration test: In src/it/xjc-main/pom.xml, add <generateEpisode>false</generateEpisode> to the configuration (after <packageName>com.example.myschema</packageName>). With this, the integration test fails. If additionally @project.version@ is replaced by 2.5.0, it is possible to just build the project in src/it/xjc-main which shows the exceptions in the log below.

Despite the info message 'Created EpisodePath', the mentioned path src/it/xjc-main/target/generated-sources/jaxb/META-INF/JAXB does not exist and my guess is that then the creation of a file fails. However, I would expect that with generateEpisode=false neither the file nor the directory should be created.

$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< org.codehaus.mojo.jaxb2.its:xjc-main >----------------
[INFO] Building xjc-main 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from stores-releases: https://repo.aldidevops.com/repository/stores-public/org/apache/maven/plugins/maven-compiler-plugin/2.5.1/maven-compiler-plugin-2.5.1.pom
Downloaded from stores-releases: https://repo.aldidevops.com/repository/stores-public/org/apache/maven/plugins/maven-compiler-plugin/2.5.1/maven-compiler-plugin-2.5.1.pom (0 B at 0 B/s)
Downloading from stores-releases: https://repo.aldidevops.com/repository/stores-public/org/apache/maven/plugins/maven-compiler-plugin/2.5.1/maven-compiler-plugin-2.5.1.jar
Downloaded from stores-releases: https://repo.aldidevops.com/repository/stores-public/org/apache/maven/plugins/maven-compiler-plugin/2.5.1/maven-compiler-plugin-2.5.1.jar (0 B at 0 B/s)
[INFO]
[INFO] --- jaxb2-maven-plugin:2.5.0:xjc (xjc) @ xjc-main ---
[INFO] Created EpisodePath [/Volumes/ramdisk/jaxb2-maven-plugin/src/it/xjc-main/target/generated-sources/jaxb/META-INF/JAXB]: true
[INFO] Ignored given or default xjbSources [/Volumes/ramdisk/jaxb2-maven-plugin/src/it/xjc-main/src/main/xjb], since it is not an existent file or directory.
[ERROR] null [-1,-1]
org.xml.sax.SAXParseException: Failed to write to /Volumes/ramdisk/jaxb2-maven-plugin/src/it/xjc-main/target/generated-sources/jaxb/META-INF/JAXB/episode_xjc.xjb
    at com.sun.tools.xjc.addon.episode.PluginImpl.run (PluginImpl.java:177)
    at com.sun.tools.xjc.model.Model.generateCode (Model.java:262)
    at com.sun.tools.xjc.Driver.run (Driver.java:354)
    at org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo.performExecution (AbstractJavaGeneratorMojo.java:475)
    at org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute (AbstractJaxbMojo.java:337)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.io.FileNotFoundException: /Volumes/ramdisk/jaxb2-maven-plugin/src/it/xjc-main/target/generated-sources/jaxb/META-INF/JAXB/episode_xjc.xjb (No such file or directory)
    at java.io.FileOutputStream.open0 (Native Method)
    at java.io.FileOutputStream.open (FileOutputStream.java:298)
    at java.io.FileOutputStream.<init> (FileOutputStream.java:237)
    at java.io.FileOutputStream.<init> (FileOutputStream.java:187)
    at com.sun.tools.xjc.addon.episode.PluginImpl.run (PluginImpl.java:139)
    at com.sun.tools.xjc.model.Model.generateCode (Model.java:262)
    at com.sun.tools.xjc.Driver.run (Driver.java:354)
    at org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo.performExecution (AbstractJavaGeneratorMojo.java:475)
    at org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute (AbstractJaxbMojo.java:337)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.716 s
[INFO] Finished at: 2020-09-24T15:33:13+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.5.0:xjc (xjc) on project xjc-main:
[ERROR] +=================== [XJC Error]
[ERROR] |
[ERROR] | 0: file:/Volumes/ramdisk/jaxb2-maven-plugin/src/it/xjc-main/src/main/xsd/address.xsd
[ERROR] |
[ERROR] +=================== [End XJC Error]
[ERROR]
[ERROR] -> [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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException