{"id":27359574,"url":"https://github.com/rackerlabs/gradle-jaxb-plugin","last_synced_at":"2026-03-07T13:02:49.191Z","repository":{"id":3847247,"uuid":"50666148","full_name":"rackerlabs/gradle-jaxb-plugin","owner":"rackerlabs","description":"Gradle plugin to ease projects that use xsds and the ant jaxb task","archived":false,"fork":false,"pushed_at":"2023-03-16T01:21:12.000Z","size":1009,"stargazers_count":34,"open_issues_count":19,"forks_count":23,"subscribers_count":29,"default_branch":"master","last_synced_at":"2026-02-11T02:28:48.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rackerlabs.png","metadata":{"files":{"readme":"README.adoc","changelog":"CHANGELOG.adoc","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-01-29T14:08:19.000Z","updated_at":"2022-03-21T11:11:56.000Z","dependencies_parsed_at":"2023-07-05T18:48:17.387Z","dependency_job_id":null,"html_url":"https://github.com/rackerlabs/gradle-jaxb-plugin","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/rackerlabs/gradle-jaxb-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fgradle-jaxb-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fgradle-jaxb-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fgradle-jaxb-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fgradle-jaxb-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rackerlabs","download_url":"https://codeload.github.com/rackerlabs/gradle-jaxb-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Fgradle-jaxb-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30214618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T12:15:00.571Z","status":"ssl_error","status_checked_at":"2026-03-07T12:15:00.217Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-13T00:30:19.734Z","updated_at":"2026-03-07T13:02:49.154Z","avatar_url":"https://github.com/rackerlabs.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"= gradle-jaxb-plugin\n\n:exclamation:IMPORTANT PLUGIN ID CHANGES:exclamation:\n\nThis plugin is an update to the original project this was forked from.\nWe acknowledge and are grateful to these developers for their contributions to open source.\nYou can find the source code of their original using the `forked from` link of this project.\nIn compliance with the license chosen by the original author, we are publishing this modified version since they have not kept up with the maintenance needs of the community.\n\nTo prevent possible collisions and/or confusion if the original author decides to accept our PR's or to simply begin anew, we have changed the id and package names.\n\nIn compliance with the gradle plugin submission guidelines, the plugin's id was changed from `com.github.jacobono.jaxb` to `org.openrepose.gradle.plugins.jaxb`.\nThis affects how you apply the plugin (`apply plugin: 'org.openrepose.gradle.plugins.jaxb'`).\n\nThis Gradle plugin defines some conventions for XSD projects and provides some processing to ease some of the maintenance of these projects by:\n\n* Hooking in ant tasks to parse the XSD's with the `xjc` task.\n* Generates code from XSD's per unique namespace.\n* Generates an xsd dependency tree, to parse namespaces in their order of dependencies, from the base namespaces up.\n* Generating an episode file for every unique namespace in a set of xsd files.\n* Defining a convention to optionally generate episode files.\n* Ability to define xsd projects to depend on one another, so that when parsing, what a project depends on is also parsed.\n\n== Using The Plugin\n\nSee this plugin's page in the\nhttps://plugins.gradle.org/plugin/org.openrepose.gradle.plugins.jaxb[gradle plugins repo].\n\n== Setting Up The JAXB Configurations\n\nYou *need* the jaxb configuration to run the `xjc` task, but that is the only task that requires an external dependency.\nIf an XJC plugin is used, then simply add it to the dependencies to have it included.\n\nAny version of jaxb that you care to use will work.\n\n[source, groovy]\n----\ndependencies {\n  jaxb 'org.glassfish.jaxb:jaxb-xjc:2.2.11'\n  jaxb 'org.glassfish.jaxb:jaxb-runtime:2.2.11'\n  xjc  'com.example:xjc-plugin:0.0.0'\n}\n----\n\n== Plugin Tasks\n\nThere are only two tasks.\n\n* `xjc`\n    - runs `xjc` ant task on each `.xsd` in the dependency tree.\n    - needs to be run **manually**.\n* `xsd-dependency-tree`\n    - Builds a dependency tree from all `.xsd` files configured to be parsed.\n    - Finds each unique namespace and groups files containing that namespace.\n    - Analyzes xsd dependencies and places them in the correct place in the dependency tree.\n      This ensures the namespaces can be parsed in order using the optionally generated episode files to bind.\n      If the episode files generated, then other projects can bind to them from the namespace in the tree.\n      - This keeps all namespaces decoupled and prevents a big episode blob containing everything that was parsed.\n\n`xjc` depends on `xsd-dependency-tree` so you don't need to run the tree task at all.\n\n== Plugin Conventions\n\nThere are two conventions that can be overridden and one is nested in the other.\n\nThe `jaxb` convention defines the conventions for the whole plugin, and the `xjc` convention defines the conventions for the `xjc` ant task.\n\nYou can change these defaults with a closure in your build script.\n\n[source, groovy]\n----\njaxb {\n  ...\n  xjc {\n    ...\n  }\n}\n----\n\n=== JAXB Plugin Convention\n\nThese are the configurable parameters for the JAXB Plugin.\n\n.JAXB Plugin Parameters\n[cols=\"2,6,3,2\"]\n|===\n| Parameter\n| Description\n| Default\n| Type\n\n| `xsdDir`\n| Defined **by each** project to tell the plugin where to find the `.xsd` files to parse.\n| `${project.projectDir}/src/main/resources/schema`\n| `String`\n\n| `xsdIncludes`\n| RegEx used to produce a List of files found in `xsdDir` to compile.\n| `**/*.xsd`\n| `String`\n\n| `episodesDir`\n| **All** generated episode files go directly under here, no subfolders.\n  (i.e. _\"build/generated-resources/episodes\"_, _\"episodes\"_, _\"schema/episodes\"_, _\"xsd/episodes\"_, _\"XMLSchema/episodes\"_)\n| `${project.buildDir}/generated-resources/episodes`\n| `String`\n\n| `bindingsDir`\n| User defined binding files to pass into the `xjc` task.\n  **All** files are directly under this folder, _no subfolders_.\n  (i.e. _\"src/main/resources/schema\"_, _\"bindings\"_, _\"schema/bindings\"_, _\"xsd/bindings\"_, _\"XMLSchema/bindings\"_)\n| `${project.projectDir}/src/main/resources/schema`\n| `String`\n\n| `bindings`\n| RegEx used to produce a List of customization files found in `bindingsDir` to bind with.\n| `**/*.xjb`\n| `String`\n|===\n\n=== XJC Convention\n\nThese are the configurable parameters for the JAXB Plugin's XJC interactions.\n\n.XJC Plugin Parameters\n[cols=\"2,6,3,2\"]\n|===\n| Parameter\n| Description\n| Default\n| Type\n\n|`taskClassname`\n| Enables a custom task classname to run the XJC task if something other than JAXB is desired.\n  Useful if **JAXB2** is required to be used.\n| `com.sun.tools.xjc.XJCTask`\n| `String`\n\n|`destinationDir`\n| The directory relative to `project.rootDir` where generated code will be written to.\n\n  In order to automatically remove previously generated sources, this directory is deleted whenever the **Up To Date** check fails.\n  This should never point to a location under the main source directory.\n| `${project.buildDir}/generated-sources/xjc`\n| `String`\n\n|`producesDir`\n| This parameter has never been used by this plugin.\n  It remains only for the purposes of backwards compatibility.\n  Consider it deprecated and that it will be removed in a future release.\n| `${project.buildDir}/generated-sources/xjc`\n| `String`\n\n|`generateEpisodeFiles`\n| Enables the creation of the Episode files\n| `true`\n| `boolean`\n\n|`extension`\n| Run XJC compiler in extension mode\n| `true`\n| `boolean`\n\n|`removeOldOutput`\n| Only used with nested `\u003cproduces\u003e` elements, when `yes` all files are deleted before XJC is run\n| `yes`\n| `String`\n\n|`header`\n| generates a header in each generated file\n| `true`\n| `boolean`\n\n|`generatePackage`\n| specify a package to generate to\n| **Not Defined**\n| `String`\n\n|`args`\n| List of extra String arguments to pass the `xjc` ant task.\n  This is useful when activating JAXB2 plugins.\n| **Empty String**\n| `List\u003cString\u003e`\n\n|`accessExternalSchema`\n| Enables setting the new `javax.xml.accessExternalSchema` system property that causes the plugin to not work as expected under JSE8.\n| **Implementation Specific**\n| `String`\n|===\n\n\nFor more in depth description please see the\nhttps://jaxb.java.net/2.2.7/docs/ch04.html#tools-xjc-ant-task[XJC Ant Task documentation].\n\n== Examples\n\n=== Default Example using JAXB\n\nIf the default conventions are used, then there is nothing to configure.\n\n=== Default Example using JAXB2\n\nCustomized to use `xjc` plugins.\n\n[source, groovy]\n----\ndependencies {\n    jaxb \"org.jvnet.jaxb2_commons:jaxb2-basics:1.11.1\"\n    jaxb 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:1.11.1'\n    jaxb 'org.jvnet.jaxb2_commons:jaxb2-basics-annotate:1.0.4'\n    jaxb 'org.slf4j:slf4j-log4j12:1.7.25'\n}\n\njaxb {\n  xsdDir = \"${project.projectDir}/some/folder\"\n  xjc {\n    generateEpisodeFiles = false\n    taskClassname        = \"org.jvnet.jaxb2_commons.xjc.XJC2Task\"\n    generatePackage      = \"com.company.example\"\n    args                 = [\"-Xinheritance\", \"-Xannotate\"]\n  }\n}\n----\n\n== Defining The Plugin For All Projects\n\nCreate a convention for xsd projects to have a suffix of `-schema`, then it is easy to write:\n\n[source, groovy]\n----\nsubprojects { project -\u003e\n  if(project.name.endsWith(\"-schema\")) { \n    apply plugin: 'org.openrepose.gradle.plugins.jaxb'\n\n    dependencies { \n      jaxb 'org.glassfish.jaxb:jaxb-xjc:2.2.11'\n      jaxb 'org.glassfish.jaxb:jaxb-runtime:2.2.11'\n    }\n  }\n}\n----\n\napplying the plugin to all schema projects.\n\nAnother way to do this is by adding a boolean property to the `gradle.properties` file in the sub-projects.\nYou can then use it this way:\n  \n[source, groovy]\n----\nsubprojects { project -\u003e\n  if(Boolean.valueOf(project.getProperties().getOrDefault('doJAXB', 'false'))) { \n    apply plugin: 'org.openrepose.gradle.plugins.jaxb'\n\n    dependencies { \n      jaxb 'org.glassfish.jaxb:jaxb-xjc:2.2.11'\n      jaxb 'org.glassfish.jaxb:jaxb-runtime:2.2.11'\n    }\n  }\n}\n----\n\n== Other Features\n\n=== Depend On Another Project\n\nThis lets gradle know that the xjc task of a project is dependent on the xjc task of another project.\nThis can be achieved with:\n\n[source, groovy]\n----\ndependencies {\n  jaxb project(path: ':common', configuration: 'jaxb')\n}\n----\n\nThis expresses that xsd's definitely depend on other xsd's outside of their parent folder `xsdDir`.\n\nThis will run the xjc task on `common` before running the xjc task of of the project this is defined in.\n\n== Examples\n\nYou can find some small example projects using this plugin in the link:./examples[examples folder].\nSimply issue `../gradlew clean build` from within it to run them all.\n\nFor a basic example of using this plugin with multiple sub-projects that have interactions, please see this https://github.com/wdschei/gradle-jaxb-plugin-test[test project].\n\nFor a real world example of this plugin, please visit the main https://github.com/rackerlabs/repose[Repose project].\n\n== Improvements\n\nIf you have an idea that would make something a little easier, we'd love to hear about it.\nIf you think you can make this plugin better, then simply fork it like we did and submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frackerlabs%2Fgradle-jaxb-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frackerlabs%2Fgradle-jaxb-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frackerlabs%2Fgradle-jaxb-plugin/lists"}