Skip to content

Mixed up binding-files when using groups #32

Open
@MZimmermann

Description

@MZimmermann

Hey,

I'm having trouble with release 1.8.1, because of inconsistent bindings when there is more than one xjc-task involved (which will be the case, when multiple groups are configured). I attached a minimal example-project:

XjcTest.zip

Each group is supposed to generate a single class (A and B).

A has an xsd:dateTime-attribute, which is supposed to be handled via a custom-converter, which is specified in the bindings-file xsd-templates/a/bindings_a.xjb.

B has an xsd:duration-attribute, which is supposed to be handled via another converter, which is specified in the bindings-file xsd-templates/b/bindings_b.xjb.

This example compiles, because it's using the plugin at version 1.8.0. But if you change it to 1.8.1, and replace the lines

bindingFiles = project.files(xsdDir.file("bindings_a.xjb"))

with

bindingFiles.setFrom(project.files(xsdDir.file("bindings_a.xjb"))),

(the same for the B-task respectively)

it will fail.

If we're attempting to run ./gradlew xjcA xjcB --rerun-tasks --info, we see the problem in the output:

> Task :xjcA
Caching disabled for task ':xjcA' because:
  Build cache is disabled
Task ':xjcA' is not up-to-date because:
  Executed with '--rerun-tasks'.
Watching 22 directories to track changes
Watching 21 directories to track changes
Loading XSD files [/home/mz/git/private/XjcTest/xsd-templates/a/A.xsd]
file or directory '/home/mz/git/private/XjcTest/build/xjc/extracted-bind-files', not found
Loading binding files: [/home/mz/git/private/XjcTest/xsd-templates/b/bindings_b.xjb]

> Task :xjcB
Caching disabled for task ':xjcB' because:
  Build cache is disabled
Task ':xjcB' is not up-to-date because:
  Executed with '--rerun-tasks'.
Watching 16 directories to track changes
Watching 15 directories to track changes
Loading XSD files [/home/mz/git/private/XjcTest/xsd-templates/b/B.xsd]
file or directory '/home/mz/git/private/XjcTest/build/xjc/extracted-bind-files', not found
Loading binding files: [/home/mz/git/private/XjcTest/xsd-templates/b/bindings_b.xjb]

Note, that the task xjcA now loads the binding-file /home/mz/git/private/XjcTest/xsd-templates/b/bindings_b.xjb, which means that the code from Main.java will lead to compile errors. Either a.setMyDateTime(OffsetDateTime.MAX); or b.setMyDuration(Duration.ofSeconds(4)); will produce an error, because one of the task will have worked with mismatched binding-file.

I'm guessing, that replacing the FileCollection with ConfigurableFileCollection and making them final has something to do with the problem, but I'm not well versed in the intricacies of gradle. I would appreciate it, if you could have a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions