mojohaus / jaxb2-maven-plugin

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

Problem with <source> tag #127

Closed FimChe closed 5 years ago

FimChe commented 5 years ago

I encountered a problem while executing schemagen goal on Jenkins, '/' is omitted from the start of the path to file specified under <source> tag in <configuration>. Issue exists on 2.4 version, worked fine when I downgraded to 2.3.1.

Relevant configuration part from pom.xml:

<sources> <source>src/main/java/path/to/file/SomeFile.java</source> </sources>

Stack trace from Jenkins is as follows:

[WARNING] [SchemaGen]: Apr 04, 2019 3:26:16 PM com.sun.tools.jxc.SchemaGenerator$Runner compile WARNING: Unrecognized options found: [home/jenkins/path/to/project/src/main/java/path/to/file/SomeFile.java]

[ERROR] Execution failed. [ERROR]

[Message]: no source files com.sun.tools.javac.main.Main.error(Main.java:186) com.sun.tools.javac.main.Main.compile(Main.java:428) com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129) com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138) com.sun.tools.jxc.SchemaGenerator$Runner.compile(SchemaGenerator.java:266) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) com.sun.tools.jxc.SchemaGenerator.run(SchemaGenerator.java:166) org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo.performExecution(AbstractXsdGeneratorMojo.java:405) org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute(AbstractJaxbMojo.java:315) org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) org.apache.maven.cli.MavenCli.execute(MavenCli.java:956) org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) org.apache.maven.cli.MavenCli.main(MavenCli.java:192) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

lennartj commented 5 years ago

A workaround is to provide a path relative to the project.basedir

vehovsky commented 3 years ago

Why was this issue closed? I'm encountering the exact same problem.

@lennartj as you can see in the original issue description, relative path to project.basedir is already used:

<source>src/main/java/path/to/file/SomeFile.java</source>

I didn't look at the code but it seems the relative path for the source file is not resolved properly. As for me the issue only happens when my multi-module aggregator/parent is not in the root directory:

|-- project_dir
    |-- paret_aggregator_dir
    |   `-- pom.xml
    |-- module_a_dir
    |   `-- pom.xml
    |-- module_b_dir
        `-- pom.xml

When I move the aggregator/parent to root directory. I no longer have this issue.

|-- project_dir
    |-- pom.xml (paret/aggregator)
    |-- module_a_dir
    |   `-- pom.xml
    |-- module_b_dir
        `-- pom.xml