Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Make it possible to configure schemaDir #5

Closed
mraccola opened this issue Dec 13, 2011 · 5 comments
Closed

Make it possible to configure schemaDir #5

mraccola opened this issue Dec 13, 2011 · 5 comments
Assignees

Comments

@mraccola
Copy link
Contributor

Currently the schemaDir is hard coded to "src/${sourceSet.name}/jaxb". Request to allow the default to be changed via a plugin convention object.

I took a look at the source code and it seems the plugin does define a convention object but the name of the object, JaxbSourceDirectory, does not lend itself to extension. I would be happy to create a patch if you felt like it was OK to rename the convention object perhaps to JaxbPluginConvention?

Also, please consider changing the default from "src/${sourceSet.name}/jaxb" to "src/${sourceSet.name}/xsd". This might be more appropriate because there could be other uses for these schemas other than just JAXB code generation.

@stigkj
Copy link
Collaborator

stigkj commented Dec 13, 2011

I've been meaning to add a convention object, but time has not allowed it. Think it would be easy to add just to be able to change the schemaDir. Not sure how it would work with the dynamic nature of the source sets.

JaxbSourceDirectory is not a normal plugin convention as one is created for each source set. So it is more a convention object for each JAXB source drectory set. So a plugin convention would be a new object :-)

Good point about changing the default from jaxb to xsd. A little narrowminded of me. That, at least, is a very easy fix.

@ghost ghost assigned stigkj Dec 13, 2011
@mraccola
Copy link
Contributor Author

I have been able to work around the issue by adding this code to my build:

project.convention.plugins.java.sourceSets.all { SourceSet sourceSet -> sourceSet.jaxb { srcDir 'src/main/xsd' } }

Maybe something like this be nice to have?

sourceSets { main { xsd { srcDir 'src/main/xsd' } } }

@stigkj
Copy link
Collaborator

stigkj commented Dec 14, 2011

I'm afraid your sourceSets.all thing only works when you only have schemas in the main source directory set. An example:

sourceSets {
    main {
        ...
    }
    customer1 {
        ...
    }
    customer2 {
        ...
    }
}

Here you have 3 source sets which normally has 3 schema source directory sets:

src/main/jaxb
src/customer1/jaxb
src/customer2/jaxb

If you had applied your sourceSets.all thing on such a project, you would only get 1 source directory (src/main/xsd)
for all source sets, which was not your intention, I would guess.

But you can actually change the directory properly for multiple source sets with the current version of the plugin, just like what
you have done in the second block, but with jaxb as the source directory set name instead of xsd:

sourceSets {
    main {
        jaxb { srcDir 'src/main/xsd' }
    }
    customer1 {
        jaxb { srcDir 'src/customer1/xsd' }
    }
    customer2 {
        jaxb { srcDir 'src/customer2/xsd' }
    }
}

So when this issue is closed, the previous code block will be the standard setup, that is, the directory for the schemas will be
src/<source set name>/xsd

@stigkj
Copy link
Collaborator

stigkj commented Dec 14, 2011

Regarding your wish for this:

sourceSets {
    main {
        xsd { <some overrides> }
    }
}

I think this is better:

sourceSets {
    main {
        jaxb { <some overrides> }
    }
}

As it is a source directory set for the JAXB plugin, it is better to name it jaxb than xsd.

@stigkj
Copy link
Collaborator

stigkj commented Dec 15, 2011

Changing the default source directory to .../xsd is moved into its own issue.

Then the rest of this issue is solved by using the options available in source sets as shown in previous comments.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants