jaxb schemagen issue in linux when calling from build.xml. Cant find source files?

StackOverflow https://stackoverflow.com/questions/15129666

  •  16-03-2022
  •  | 
  •  

Вопрос

Here's the details: This works fine on Windows, but won't work on Linux and I need it to work on a Linux machine.

schemagen -version gives the same results on both Windows and Linux..

schemagen version "JAXB 2.1.10 in JDK 6" JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build JAXB 2.1.10 in JDK 6)

Here's the ant code in question:
<target name="genSchema" description="Generate Schema from Java source files">
<exec executable="schemagen">
<arg line="-d ../target/schema ../path/to/source/*.java" />
</exec>
</target>

First of all this all works fine in windows. In Linux, if I run the following from the command line, no problems generating the schema:

schemagen -d ../target/schema ../path/to/source/*.java

Note: Writing ../target/schema/schema1.xsd

However, If I run the ant target from the build.xml above in Linux, I get the following error:

[exec] error: cannot read: ../path/to/source/*.java [exec] 1 error [exec] Result: 1

In Windows the exact same ant target works fine. Please help! Pulling my hair out on this one. Let me know if you need any more details.

For what it's worth, I've also tried using an absolute path instead of backing up a directory to get to the source files in my ant task... I still get the same error when trying to do it with ant.

Ex. <arg line="-d ../target/schema /home/path/to/source/*.java" />
[exec] error: cannot read: /home/path/to/source/*.java

Это было полезно?

Решение

Try this:

<exec executable="bash">
    <arg line='-c "schemagen -d ../target/schema ../path/to/source/*.java"' />
</exec>

As we discussed above, the problem seems to be that on some Unix systems, the exec task does not expand wildcards. Thus this is an attempt to pass the command to a shell which will do the expansion for you.

And yes, I realize this solution makes the build.xml file unix-specific. If this works, there are ways to address that.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top