From ab0e0deb979d3dca47d801bb67a182547e6282f5 Mon Sep 17 00:00:00 2001 From: wdschei Date: Fri, 29 Jan 2016 14:29:22 -0600 Subject: [PATCH 01/16] Updated the JSE Docs link. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5569386..f4d93c7 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ test { groovydoc { docTitle = "Gradle XSD Plugin" link("http://groovy.codehaus.org/gapi/", "groovy.", "org.codehaus.groovy.") - link("http://doc.oracle.com/javase/7/docs/api/", "java.") + link("http://docs.oracle.com/javase/8/docs/api/", "java.") link("http://google-guice.googlecode.com/svn/trunk/javadoc/", "com.google.") link("http://www.gradle.org/docs/current/javadoc/", "org.gradle.", "org.gradle.api.") } From 1be24eea806242f742ae231df41ea94e81a0fb48 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 17:59:23 -0600 Subject: [PATCH 02/16] Updated the .gitignore to be a little more friendly with multiple IDE's. --- .gitignore | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f91f853..8879387 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,65 @@ -build -*.class -.gradle \ No newline at end of file +## java specific +!.gitignore +*.iml +*.iws +*.ipr +*.lic +target +*/target +*/*/target + +## vim objects +*.swo +*.swp + +## Build helper scripts +*.bhs + +## Netbeans +catalog.xml +nbactions.xml + +## IntelliJ IDEA +*.iml +*.ipr +*.iws +.idea/ +local/ + +# Gradle bits from: https://github.com/github/gitignore/blob/master/Gradle.gitignore +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +## generic files to ignore +*~ +*.lock +*.DS_Store +*.swp +*.out +jmeter.log + +## rcman +rcman.conf +rcman.log +rsInstances +nodeNames +hosts.csv +automation/rcman/files/* +log.txt +/test/JavaApplication1/nbproject/private/ +/test/artifact-behavior-test/responseBody +/test/artifact-behavior-test/responseHeaders + +## Python +*.py[cod] +.Python + +## Eclipse +# eclipse specific git ignore +.project +.metadata +.classpath +.settings From 5dd965d807c38864e198f2a55a969cc1ff7fd65d Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 18:49:41 -0600 Subject: [PATCH 03/16] Changed the behavior from **ALWAYS** relative to project.rootDir, to only if not absolute through using the recomended project.projectDir and project.rootDir references in the variable definitions. --- README.md | 22 +++--- .../hello-world-bindings-schema.gradle | 5 +- .../hello-world-import-schema.gradle | 5 +- .../hello-world-schema.gradle | 5 +- .../hello-world-spaces-dir-schema.gradle | 7 +- .../gradle/jacobo/plugins/JaxbPlugin.groovy | 73 ++++++++++--------- .../plugins/extension/XjcExtension.groovy | 4 +- .../jacobo/plugins/JaxbPluginSpec.groovy | 18 ++--- 8 files changed, 75 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 29f9fe1..cca0dfa 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ new group id `com.github.jacobono` matches gradle plugin id. :boom: :collision: -## Using Gradle 2.1 plugins script block +## Using Gradle 2.10 plugins script block ```groovy plugins { id 'com.github.jacobono.jaxb' version '1.3.6' @@ -137,17 +137,14 @@ There are 4 overrideable defaults for this JAXB Plugin. These defaults are changed via the `jaxb` closure. * `xsdDir` - * **ALWAYS** relative to `project.rootDir` * Defined **by each** project to tell the plugin where to find the `.xsd` files to parse * `episodesDir` - * **ALWAYS** relative to `project.rootDir` - * i.e. _"episodes"_, _"schema/episodes"_, _"xsd/episodes"_, + * i.e. _"build/generated-resources/episodes"_, _"episodes"_, _"schema/episodes"_, _"xsd/episodes"_, _"XMLSchema/episodes"_ * **All** generated episode files go directly under here, no subfolders. * `bindingsDir` - * **ALWAYS** relative to `project.rootDir` - * i.e. "bindings", "schema/bindings", "xsd/bindings", + * i.e. "src/main/resources/schema", "bindings", "schema/bindings", "xsd/bindings", "XMLSchema/bindings" * User defined binding files to pass in to the `xjc` task * **All** files are directly under this folder, _no subfolders_. @@ -166,10 +163,10 @@ Several sensible defaults are defined to be passed into the | parameter | Description | default | type | | :--- | :---: | :---: | ---: | -|`destinationDir` _(R)_ | generated code will be written to this directory | `src/main/java` | `String` | +|`destinationDir` _(R)_ | generated code will be written to this directory | `${project.projectDir}/build/generated-sources/xjc` | `String` | |`extension` _(O)_ | Run XJC compiler in extension mode | `true` | `boolean` | |`header` _(O)_ | generates a header in each generated file | `true` | `boolean` | -|`producesDir` _(O)(NI)_ | aids with XJC up-to-date check | `src/main/java` | `String` | +|`producesDir` _(O)(NI)_ | aids with XJC up-to-date check | `${project.projectDir}/build/generated-sources/xjc` | `String` | |`generatePackage` _(O)_ | specify a package to generate to | **none** | `String` | |`args` _(O)_ | List of strings for extra arguments to pass that aren't listed | **none** | `List` | |`removeOldOutput` _(O)_ | Only used with nested `` elements, when _'yes'_ all files are deleted before XJC is run | _'yes'_ | `String` | @@ -185,9 +182,8 @@ substitute the version you are using. ### destinationDir ### -`destinationDir` is relative to `project.projectDir`. It is -defaulted to `src/main/java`, but can be set to anywhere in -`project.projectDir`. +`destinationDir` is relative to `project.rootDir`. It is defaulted to +`${project.projectDir}/build/generated-sources/xjc`, but can be set to anywhere. ### producesDir ### @@ -213,7 +209,7 @@ _(per project)_ is the `xsdDir`, and jaxb dependencies as described above. ```groovy jaxb { - xsdDir = "schema/folder1" + xsdDir = "${project.projectDir}/schema/folder1" } ``` @@ -231,7 +227,7 @@ dependencies { } jaxb { - xsdDir = "some/folder" + xsdDir = "${project.projectDir}/some/folder" xjc { taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task" generatePackage = "com.company.example" diff --git a/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle b/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle index a9ed3fe..975643c 100644 --- a/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle +++ b/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle @@ -6,11 +6,12 @@ dependencies { } jaxb { - xsdDir = "schema/multiple" - bindingsDir = "schema/multiple/xjb" + xsdDir = "${project.rootDir}/schema/multiple" + bindingsDir = "${project.rootDir}/schema/multiple/xjb" bindings = ["xsd-bindings.xjb"] xjc { taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task" args = ["-Xannotate"] + destinationDir = "${project.projectDir}/build/generated-sources/xjc" } } \ No newline at end of file diff --git a/examples/hello-world-import-schema/hello-world-import-schema.gradle b/examples/hello-world-import-schema/hello-world-import-schema.gradle index 8d171b4..df010a4 100644 --- a/examples/hello-world-import-schema/hello-world-import-schema.gradle +++ b/examples/hello-world-import-schema/hello-world-import-schema.gradle @@ -1,5 +1,8 @@ version = "0.1" jaxb { - xsdDir = "schema/Import" + xsdDir = "${project.rootDir}/schema/Import" + xjc { + destinationDir = "${project.projectDir}/build/generated-sources/xjc" + } } \ No newline at end of file diff --git a/examples/hello-world-schema/hello-world-schema.gradle b/examples/hello-world-schema/hello-world-schema.gradle index 324bdda..fec9464 100644 --- a/examples/hello-world-schema/hello-world-schema.gradle +++ b/examples/hello-world-schema/hello-world-schema.gradle @@ -1,5 +1,8 @@ version = "0.1" jaxb { - xsdDir = "schema/HelloWorld" + xsdDir = "${project.rootDir}/schema/HelloWorld" + xjc { + destinationDir = "${project.projectDir}/build/generated-sources/xjc" + } } \ No newline at end of file diff --git a/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle b/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle index 6c31c19..37586df 100644 --- a/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle +++ b/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle @@ -1,6 +1,9 @@ version = "0.1" jaxb { - xsdDir = "schema/HelloWorld" - episodesDir = "schema/space episodes" + xsdDir = "${project.rootDir}/schema/HelloWorld" + episodesDir = "${project.projectDir}/build/generated-resources/schema/space episodes" + xjc { + destinationDir = "${project.projectDir}/build/generated-sources/xjc" + } } \ No newline at end of file diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index b8b4db6..c7fca75 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -2,31 +2,27 @@ package org.gradle.jacobo.plugins import com.google.inject.Guice import com.google.inject.Injector - -import org.gradle.api.Project import org.gradle.api.Plugin - -import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.artifacts.Configuration -import org.gradle.api.logging.Logging import org.gradle.api.logging.Logger - -import org.gradle.jacobo.plugins.task.JaxbDependencyTree -import org.gradle.jacobo.plugins.task.JaxbXjc +import org.gradle.api.logging.Logging +import org.gradle.api.plugins.JavaPlugin +import org.gradle.jacobo.plugins.ant.AntXjc +import org.gradle.jacobo.plugins.converter.NamespaceToEpisodeConverter import org.gradle.jacobo.plugins.extension.JaxbExtension import org.gradle.jacobo.plugins.extension.XjcExtension -import org.gradle.jacobo.plugins.guice.JaxbPluginModule -import org.gradle.jacobo.schema.guice.DocSlurperModule - import org.gradle.jacobo.plugins.factory.XsdDependencyTreeFactory +import org.gradle.jacobo.plugins.guice.JaxbPluginModule +import org.gradle.jacobo.plugins.resolver.EpisodeDependencyResolver import org.gradle.jacobo.plugins.resolver.ExternalDependencyResolver import org.gradle.jacobo.plugins.resolver.NamespaceResolver -import org.gradle.jacobo.schema.factory.DocumentFactory -import org.gradle.jacobo.plugins.ant.AntXjc -import org.gradle.jacobo.plugins.converter.NamespaceToEpisodeConverter import org.gradle.jacobo.plugins.resolver.XjcResolver -import org.gradle.jacobo.plugins.resolver.EpisodeDependencyResolver +import org.gradle.jacobo.plugins.task.JaxbDependencyTree +import org.gradle.jacobo.plugins.task.JaxbXjc +import org.gradle.jacobo.schema.factory.DocumentFactory +import org.gradle.jacobo.schema.guice.DocSlurperModule /** * Defines the Jaxb Plugin. @@ -62,19 +58,19 @@ class JaxbPlugin implements Plugin { * @see org.gradle.jacobo.plugins.extension.JaxbExtension * @see org.gradle.jacobo.plugins.extension.XjcExtension */ - private void configureJaxbExtension(final Project project) { - extension = project.extensions.create("jaxb", JaxbExtension, project) - extension.with { - xsdDir = "schema" - episodesDir = "schema/episodes" - bindingsDir = "schema/bindings" + private void configureJaxbExtension(final Project project) { + extension = project.extensions.create('jaxb', JaxbExtension, project) + extension.with { + xsdDir = "${project.projectDir}/src/main/resources/schema" + episodesDir = "${project.projectDir}/build/generated-resources/episodes" + bindingsDir = "${project.projectDir}/src/main/resources/schema" bindings = [] } - def xjcExtension = project.jaxb.extensions.create("xjc", XjcExtension) + def xjcExtension = project.jaxb.extensions.create('xjc', XjcExtension) xjcExtension.with { taskClassname = 'com.sun.tools.xjc.XJCTask' - destinationDir = "src/main/java" - producesDir = "src/main/java" + destinationDir = "${project.projectDir}/build/generated-sources/xjc" + producesDir = "${project.projectDir}/build/generated-sources/xjc" extension = true removeOldOutput = 'yes' header = true @@ -133,9 +129,11 @@ class JaxbPlugin implements Plugin { "and find all unique namespaces, create a namespace graph and parse in " + "the graph order with jaxb" jnt.group = JAXB_TASK_GROUP - jnt.conventionMapping.xsds = { project.fileTree( dir: - new File(project.rootDir, - project.jaxb.xsdDir), include: '**/*.xsd') + jnt.conventionMapping.xsds = { + project.fileTree( + dir: new File((String)project.jaxb.xsdDir), + include: '**/*.xsd' + ) } jnt.conventionMapping.docFactory = { injector.getInstance(DocumentFactory.class) @@ -176,26 +174,33 @@ class JaxbPlugin implements Plugin { xjc.dependsOn(jnt) xjc.conventionMapping.manager = { project.jaxb.dependencyGraph } xjc.conventionMapping.episodeDirectory = { - new File(project.rootDir, project.jaxb.episodesDir) } + new File((String)project.jaxb.episodesDir) + } xjc.conventionMapping.bindings = { // empty filecollection if no bindings listed, so that // files.files == empty set project.jaxb.bindings.isEmpty() ? project.files() : - project.fileTree(dir:new File(project.rootDir, project.jaxb.bindingsDir), - include: project.jaxb.bindings) + project.fileTree( + dir:new File((String)project.jaxb.bindingsDir), + include: project.jaxb.bindings + ) } // these two (generatedFilesDirectory and schemasDirectory) // are here so that gradle can check if anything // has changed in these folders and run this task again if so // they serve no other purpose than this xjc.conventionMapping.generatedFilesDirectory = { - new File(project.projectDir, project.jaxb.xjc.destinationDir) } + new File((String)project.jaxb.xjc.destinationDir) + } // this is here in case there are bindings present, in which case a dependency tree type // evaluation just won't work. xjc.conventionMapping.xsds = { - project.fileTree(dir: new File(project.rootDir, project.jaxb.xsdDir), include: '**/*.xsd') } - xjc.conventionMapping.schemasDirectory = { - new File(project.rootDir, project.jaxb.xsdDir) } + project.fileTree( + dir: new File((String)project.jaxb.xsdDir), + include: '**/*.xsd' + ) + } + xjc.conventionMapping.schemasDirectory = { new File((String)project.jaxb.xsdDir) } xjc.conventionMapping.xjc = { injector.getInstance(AntXjc.class) } xjc.conventionMapping.episodeConverter = { injector.getInstance(NamespaceToEpisodeConverter.class) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy b/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy index fe6c313..07d03f4 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy @@ -13,8 +13,8 @@ class XjcExtension { /** * Destination directory for the generated output from the {@code xjc} task. - * Path is relative to this individual projects directory NOT the root - * directory. + * If the Path is not absolute, then it is assumed to be relative to this + * projects root directory. * See jaxb ant task */ String destinationDir diff --git a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy index 83c075b..fa9e493 100644 --- a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy +++ b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy @@ -27,16 +27,16 @@ class JaxbPluginSpec extends ProjectTaskSpecification { project.plugins.getPlugin("java") instanceof JavaPlugin with(project.jaxb) { it instanceof JaxbExtension - xsdDir == "schema" - episodesDir == "schema/episodes" - bindingsDir == "schema/bindings" - bindings == [] + xsdDir == "${project.projectDir}/src/main/resources/schema" + episodesDir == "${project.projectDir}/build/generated-resources/episodes" + bindingsDir == "${project.projectDir}/src/main/resources/schema" + bindings == ['**/*.xjb'] with(xjc) { - destinationDir == "src/main/java" - producesDir == "src/main/java" - extension == 'true' - removeOldOutput == 'yes' - header == true + destinationDir == "${project.projectDir}/build/generated-sources/xjc" + producesDir == "${project.projectDir}/build/generated-sources/xjc" + extension == 'true' + removeOldOutput == 'yes' + header == true } } } From a5e5b863a4435d06c00a181cc76eeb9cf9f25d64 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 18:54:23 -0600 Subject: [PATCH 04/16] Added the ability to explicitly state the XML Schema Definitions to be compiled within a directory, with the default being all '**/*.xsd'. --- README.md | 4 ++++ .../groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy | 7 ++++--- .../gradle/jacobo/plugins/extension/JaxbExtension.groovy | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cca0dfa..42e5998 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ These defaults are changed via the `jaxb` closure. * `xsdDir` * Defined **by each** project to tell the plugin where to find the `.xsd` files to parse +* `xsdIncludes` + * the schemas to compile + * file name List of strings found in `xsdDir` + * The default glob pattern is `**/*.xsd` * `episodesDir` * i.e. _"build/generated-resources/episodes"_, _"episodes"_, _"schema/episodes"_, _"xsd/episodes"_, _"XMLSchema/episodes"_ diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index c7fca75..d21637a 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -62,9 +62,10 @@ class JaxbPlugin implements Plugin { extension = project.extensions.create('jaxb', JaxbExtension, project) extension.with { xsdDir = "${project.projectDir}/src/main/resources/schema" + xsdIncludes = ['**/*.xsd'] episodesDir = "${project.projectDir}/build/generated-resources/episodes" bindingsDir = "${project.projectDir}/src/main/resources/schema" - bindings = [] + bindings = ['**/*.xjb'] } def xjcExtension = project.jaxb.extensions.create('xjc', XjcExtension) xjcExtension.with { @@ -132,7 +133,7 @@ class JaxbPlugin implements Plugin { jnt.conventionMapping.xsds = { project.fileTree( dir: new File((String)project.jaxb.xsdDir), - include: '**/*.xsd' + include: project.jaxb.xsdIncludes ) } jnt.conventionMapping.docFactory = { @@ -197,7 +198,7 @@ class JaxbPlugin implements Plugin { xjc.conventionMapping.xsds = { project.fileTree( dir: new File((String)project.jaxb.xsdDir), - include: '**/*.xsd' + include: project.jaxb.xsdIncludes ) } xjc.conventionMapping.schemasDirectory = { new File((String)project.jaxb.xsdDir) } diff --git a/src/main/groovy/org/gradle/jacobo/plugins/extension/JaxbExtension.groovy b/src/main/groovy/org/gradle/jacobo/plugins/extension/JaxbExtension.groovy index 52f217b..ddb6223 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/extension/JaxbExtension.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/extension/JaxbExtension.groovy @@ -18,6 +18,11 @@ class JaxbExtension { */ String xsdDir + /** + * User defined list of RegEx strings to include from the {@code xsdDir}. + */ + List xsdIncludes + /** * Folder name (under {@link org.gradle.api.Project#getRootDir()}) containing * user defined binding files to bind during the {@code xjc} task. From 044808e83f4ea477ce3a4cef642a2767e8eeaa07 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 18:58:54 -0600 Subject: [PATCH 05/16] Added a default to the list of XML Schema Definition Bindings '**/*.xjb'. --- README.md | 4 +--- .../groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 42e5998..a45872b 100644 --- a/README.md +++ b/README.md @@ -155,9 +155,7 @@ These defaults are changed via the `jaxb` closure. * `bindings` * customization files to bind with * file name List of strings found in `bindingsDir` - * if there are bindings present, xjc will be called once with the - glob pattern `**/*.xsd` to snag everything under `xsdDir`. Fixes - #27. + * The default glob pattern is `**/*.xjb` ## XJC Convention ## diff --git a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy index fa9e493..8b37b94 100644 --- a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy +++ b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy @@ -28,6 +28,7 @@ class JaxbPluginSpec extends ProjectTaskSpecification { with(project.jaxb) { it instanceof JaxbExtension xsdDir == "${project.projectDir}/src/main/resources/schema" + xsdIncludes == ['**/*.xsd'] episodesDir == "${project.projectDir}/build/generated-resources/episodes" bindingsDir == "${project.projectDir}/src/main/resources/schema" bindings == ['**/*.xjb'] From ec17fd157475f7327296c9f5d5b379b0e0fa1100 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 19:02:53 -0600 Subject: [PATCH 06/16] Updated a variable name to precent confusion with an extension value. --- .../groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index d21637a..296b6f4 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -35,7 +35,7 @@ class JaxbPlugin implements Plugin { static final Logger log = Logging.getLogger(JaxbPlugin.class) - private JaxbExtension extension + private JaxbExtension jaxbExtension /** * Entry point for plugin. @@ -47,8 +47,8 @@ class JaxbPlugin implements Plugin { Injector injector = Guice.createInjector([new JaxbPluginModule(), new DocSlurperModule()]) configureJaxbExtension(project) configureJaxbConfiguration(project) - JaxbDependencyTree jnt = configureJaxbDependencyTree(project, extension, injector) - configureJaxbXjc(project, extension, jnt, injector) + JaxbDependencyTree jnt = configureJaxbDependencyTree(project, jaxbExtension, injector) + configureJaxbXjc(project, jaxbExtension, jnt, injector) } /** @@ -59,8 +59,8 @@ class JaxbPlugin implements Plugin { * @see org.gradle.jacobo.plugins.extension.XjcExtension */ private void configureJaxbExtension(final Project project) { - extension = project.extensions.create('jaxb', JaxbExtension, project) - extension.with { + jaxbExtension = project.extensions.create('jaxb', JaxbExtension, project) + jaxbExtension.with { xsdDir = "${project.projectDir}/src/main/resources/schema" xsdIncludes = ['**/*.xsd'] episodesDir = "${project.projectDir}/build/generated-resources/episodes" From 20565f76d3e226b7d6f8396caf82481d406048bf Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 19:04:39 -0600 Subject: [PATCH 07/16] Added support for setting the new javax.xml.accessExternalSchema system property that causes the plugin to not work as expected under JSE8. --- .../groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy | 1 + .../groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy | 7 ++++++- .../gradle/jacobo/plugins/extension/XjcExtension.groovy | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index 296b6f4..bbd27c7 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -75,6 +75,7 @@ class JaxbPlugin implements Plugin { extension = true removeOldOutput = 'yes' header = true + accessExternalSchema = 'file' } } diff --git a/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy index 9c7b765..7c0fe78 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy @@ -48,13 +48,18 @@ class AntXjc implements AntExecutor { classpath : classpath) def args = [destdir : extension.destinationDir, - extension : extension.extension, + extension : extension.extension, removeOldOutput : extension.removeOldOutput, header : extension.header] if (extension.generatePackage) { args << [package : extension.generatePackage] } log.info("xjc ant task is being passed these arguments: '{}'", args) + if(extension.accessExternalSchema == null) { + System.clearProperty('javax.xml.accessExternalSchema') + } else { + System.setProperty('javax.xml.accessExternalSchema', extension.accessExternalSchema) + } ant.xjc(args) { //TODO maybe should put the produces in there? //produces (dir : destinationDirectory) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy b/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy index 07d03f4..034901c 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/extension/XjcExtension.groovy @@ -56,4 +56,9 @@ class XjcExtension { */ List args = [] + /** + * The value to be used for the JVM System property {@code javax.xml.accessExternalSchema} + * See JAXP Properties + */ + String accessExternalSchema } From 0936027a24874b0673b50bd58b2b307c63817eaa Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 19:05:55 -0600 Subject: [PATCH 08/16] Added support for automatically creating the output directory prior to calling XJC in order to prevent a FileNotFoundException from being thrown. --- src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy index efdb7ff..d0413f5 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy @@ -127,6 +127,7 @@ class JaxbXjc extends DefaultTask { def xjc(xsds, episodes, episodeFile) { def jaxbConfig = project.configurations[JaxbPlugin.JAXB_CONFIGURATION_NAME] log.debug("episodes are '{}' is empty '{}'", episodes, episodes.isEmpty()) + new File((String)project.jaxb.xjc.destinationDir).mkdirs() getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, project.files(xsds), getBindings(), project.files(episodes), episodeFile) } From 5227c4e44d7126effc90818ad11b531dda3cb4f2 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 19:06:57 -0600 Subject: [PATCH 09/16] Added another way of determining the need to execute the XJC using the project properties. --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index a45872b..8ec2eb5 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,23 @@ subproject { project -> applying the plugin to all schema projects. +Another way to do this is by adding a boolean property to the +`gradle.properties` file in the sub-projects. You can then use it this way: + +```groovy +subproject { project -> + if(Boolean.valueOf(project.getProperties().getOrDefault('doJAXB', 'false'))) { + apply plugin: 'com.github.jacobono.jaxb' + + dependencies { + jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41' + jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41' + jaxb 'javax.xml.bind:jaxb-api:2.2.7' + } + } +} +``` + Other Features ============== From 3e99c483736fa1d0d490ab175e984105aa7afeb4 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 19:09:15 -0600 Subject: [PATCH 10/16] Updated a bunch of double tick strings to single tick strings, some typos, and other misc. that hadn't been previously commited. --- examples/build.gradle | 51 ++++++++++--------- .../gradle/jacobo/plugins/JaxbPlugin.groovy | 2 +- .../gradle/jacobo/plugins/task/JaxbXjc.groovy | 2 +- .../jacobo/plugins/JaxbPluginSpec.groovy | 21 ++++---- .../EpisodeDependencyResolverSpec.groovy | 2 +- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/examples/build.gradle b/examples/build.gradle index 03cef62..04d8682 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -1,21 +1,24 @@ buildscript { - // uncomment for local testing - //********************************************************** - // repositories { - // flatDir { dirs '../build/libs' } - // mavenCentral() - // jcenter() - // } - - // dependencies { - // classpath ':gradle-jaxb-plugin-1.3.6' - // classpath 'com.google.inject:guice:3.0' - // classpath 'com.github.jacobono:gradle-xsd-wsdl-slurping:1.1.2' - // } - //********************************************************** - + //******************************************************************************** + // uncomment for local testing + //-------------------------------------------------------------------------------- + //repositories { + // flatDir { dirs '../build/libs' } // gradle unversionedJar + // //flatDir { dirs "/${gradle.gradleHomeDir}/lib/plugins" } // gradle installPlugin + // jcenter() + // mavenCentral() + //} + // + //dependencies { + // classpath ':gradle-jaxb-plugin' + // classpath 'com.google.inject:guice:3.0' + // classpath 'com.github.jacobono:gradle-xsd-wsdl-slurping:1.1.2' + //} + //******************************************************************************** + + //******************************************************************************** // use artifacts from bintray - //****************************************************** + //-------------------------------------------------------------------------------- repositories { jcenter() mavenCentral() @@ -24,25 +27,23 @@ buildscript { dependencies { classpath 'com.github.jacobono.plugins:gradle-jaxb-plugin:1.3.6' } + //******************************************************************************** } allprojects { - - repositories { + repositories { mavenCentral() } - } subprojects { project -> - - if(project.name.endsWith("-schema")) { + if(project.name.endsWith("-schema")) { apply plugin: 'com.github.jacobono.jaxb' - - dependencies { - jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41' //jaxws 2.2.6 uses jaxb 2.2.5, but can't dL 2.2.5 from maven the pom is off TODO + dependencies { + // TODO: jaxws 2.2.6 uses jaxb 2.2.5, but can't dL 2.2.5 from maven the pom is off + jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41' jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41' jaxb 'javax.xml.bind:jaxb-api:2.2.7' } } -} \ No newline at end of file +} diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index bbd27c7..aa9dd62 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -161,7 +161,7 @@ class JaxbPlugin implements Plugin { * * @param project This plugins gradle project * @param jaxb This plugins extension - * @param jnt This plugins {@code xsd-dependency-tree} task (dependended upon) + * @param jnt This plugins {@code xsd-dependency-tree} task (depended upon) * @param injector This pluings Guice injector * @return this plugins xjc tree task, configured * @see org.gradle.jacobo.plugins.task.JaxbXjc diff --git a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy index d0413f5..fb5c2a0 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy @@ -37,7 +37,7 @@ class JaxbXjc extends DefaultTask { /** * Directory where the generated java files from xjc would go - * Usually {@code /src/main/java} + * Usually {@code /build/generated-sources/xjc} */ @OutputDirectory File generatedFilesDirectory diff --git a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy index 8b37b94..a5d9089 100644 --- a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy +++ b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy @@ -10,21 +10,21 @@ import org.gradle.jacobo.plugins.task.JaxbXjc class JaxbPluginSpec extends ProjectTaskSpecification { - def rootFolder = getFileFromResourcePath("/test-project") + def rootFolder = getFileFromResourcePath('/test-project') def setupSpec() { - def resourcesRoot = getFileFromResourcePath("/") - def rootFolder = new File(resourcesRoot, "test-project") + def resourcesRoot = getFileFromResourcePath('/') + def rootFolder = new File(resourcesRoot, 'test-project') rootFolder.mkdir() } def cleanupSpec() { - def rootFolder = getFileFromResourcePath("/test-project") + def rootFolder = getFileFromResourcePath('/test-project') rootFolder.delete() } def "applies Java plugin and adds extension object"() { expect: - project.plugins.getPlugin("java") instanceof JavaPlugin + project.plugins.getPlugin('java') instanceof JavaPlugin with(project.jaxb) { it instanceof JaxbExtension xsdDir == "${project.projectDir}/src/main/resources/schema" @@ -38,11 +38,12 @@ class JaxbPluginSpec extends ProjectTaskSpecification { extension == 'true' removeOldOutput == 'yes' header == true + accessExternalSchema == 'file' } } } - def "adds confiugration to this project"() { + def "adds configuration to this project"() { when: def jaxb = project.configurations.getByName( JaxbPlugin.JAXB_CONFIGURATION_NAME) @@ -50,7 +51,7 @@ class JaxbPluginSpec extends ProjectTaskSpecification { then: jaxb.visible == true jaxb.transitive == true - jaxb.description == "The JAXB XJC libraries to be used for this project." + jaxb.description == 'The JAXB XJC libraries to be used for this project.' } def "contains 2 tasks, xjc task depends on tree graph task"() { @@ -59,7 +60,7 @@ class JaxbPluginSpec extends ProjectTaskSpecification { def dependencyTask = project.tasks['xsd-dependency-tree'] then: - [xjcTask, dependencyTask]*.group == ["parse", "parse"] + [xjcTask, dependencyTask]*.group == ['parse', 'parse'] dependencyTask instanceof JaxbDependencyTree xjcTask instanceof JaxbXjc xjcTask.taskDependencies.getDependencies(xjcTask)*.path as Set == @@ -74,8 +75,8 @@ class JaxbPluginSpec extends ProjectTaskSpecification { rootProject).build() def lastProject = ProjectBuilder.builder().withName('last').withParent( rootProject).build() - commonProject.apply(plugin: "com.github.jacobono.jaxb") - lastProject.apply(plugin: "com.github.jacobono.jaxb") + commonProject.apply(plugin: 'com.github.jacobono.jaxb') + lastProject.apply(plugin: 'com.github.jacobono.jaxb') lastProject.dependencies { compile commonProject diff --git a/src/test/groovy/org/gradle/jacobo/plugins/resolver/EpisodeDependencyResolverSpec.groovy b/src/test/groovy/org/gradle/jacobo/plugins/resolver/EpisodeDependencyResolverSpec.groovy index fce3426..00cf088 100644 --- a/src/test/groovy/org/gradle/jacobo/plugins/resolver/EpisodeDependencyResolverSpec.groovy +++ b/src/test/groovy/org/gradle/jacobo/plugins/resolver/EpisodeDependencyResolverSpec.groovy @@ -12,7 +12,7 @@ class EpisodeDependencyResolverSpec extends TreeFixture { def resolver = new EpisodeDependencyResolver() - def episodesDir = new File("/schemas/episodes") + def episodesDir = new File('/build/generated-resources/episodes') def externalNamespaces = ["E1", "E2", "E3", "E4"] def converter = Mock(NamespaceToEpisodeConverter) From 6289afbbe868d444679987ae4942f50a8ab9d4a6 Mon Sep 17 00:00:00 2001 From: wdschei Date: Mon, 1 Feb 2016 19:25:19 -0600 Subject: [PATCH 11/16] Updated the build for 'local testing' to accomadate all the updates. --- examples/build.gradle | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/build.gradle b/examples/build.gradle index 04d8682..fe6b2cc 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -2,32 +2,32 @@ buildscript { //******************************************************************************** // uncomment for local testing //-------------------------------------------------------------------------------- - //repositories { - // flatDir { dirs '../build/libs' } // gradle unversionedJar - // //flatDir { dirs "/${gradle.gradleHomeDir}/lib/plugins" } // gradle installPlugin - // jcenter() - // mavenCentral() - //} - // - //dependencies { - // classpath ':gradle-jaxb-plugin' - // classpath 'com.google.inject:guice:3.0' - // classpath 'com.github.jacobono:gradle-xsd-wsdl-slurping:1.1.2' - //} - //******************************************************************************** - - //******************************************************************************** - // use artifacts from bintray - //-------------------------------------------------------------------------------- repositories { + flatDir { dirs '../build/libs' } // gradle unversionedJar + //flatDir { dirs "/${gradle.gradleHomeDir}/lib/plugins" } // gradle installPlugin jcenter() mavenCentral() } dependencies { - classpath 'com.github.jacobono.plugins:gradle-jaxb-plugin:1.3.6' + classpath ':gradle-jaxb-plugin' + classpath 'com.google.inject:guice:3.0' + classpath 'com.github.jacobono:gradle-xsd-wsdl-slurping:1.1.2' } //******************************************************************************** + + //******************************************************************************** + // use artifacts from bintray + //-------------------------------------------------------------------------------- + //repositories { + // jcenter() + // mavenCentral() + //} + // + //dependencies { + // classpath 'com.github.jacobono:gradle-jaxb-plugin:1.3.6' + //} + //******************************************************************************** } allprojects { From d9068b35264e64a639ccc670d5da9c8806233170 Mon Sep 17 00:00:00 2001 From: wdschei Date: Thu, 4 Feb 2016 10:24:58 -0600 Subject: [PATCH 12/16] Updated all references from ${project.projectDir}/build to ${project.buildDir} to allow more flexibility. --- README.md | 6 +++--- .../hello-world-bindings-schema.gradle | 2 +- .../hello-world-import-schema.gradle | 2 +- examples/hello-world-schema/hello-world-schema.gradle | 2 +- .../hello-world-spaces-dir-schema.gradle | 4 ++-- src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy | 6 +++--- .../groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8ec2eb5..7c818a0 100644 --- a/README.md +++ b/README.md @@ -165,10 +165,10 @@ Several sensible defaults are defined to be passed into the | parameter | Description | default | type | | :--- | :---: | :---: | ---: | -|`destinationDir` _(R)_ | generated code will be written to this directory | `${project.projectDir}/build/generated-sources/xjc` | `String` | +|`destinationDir` _(R)_ | generated code will be written to this directory | `${project.buildDir}/generated-sources/xjc` | `String` | |`extension` _(O)_ | Run XJC compiler in extension mode | `true` | `boolean` | |`header` _(O)_ | generates a header in each generated file | `true` | `boolean` | -|`producesDir` _(O)(NI)_ | aids with XJC up-to-date check | `${project.projectDir}/build/generated-sources/xjc` | `String` | +|`producesDir` _(O)(NI)_ | aids with XJC up-to-date check | `${project.buildDir}/generated-sources/xjc` | `String` | |`generatePackage` _(O)_ | specify a package to generate to | **none** | `String` | |`args` _(O)_ | List of strings for extra arguments to pass that aren't listed | **none** | `List` | |`removeOldOutput` _(O)_ | Only used with nested `` elements, when _'yes'_ all files are deleted before XJC is run | _'yes'_ | `String` | @@ -185,7 +185,7 @@ substitute the version you are using. ### destinationDir ### `destinationDir` is relative to `project.rootDir`. It is defaulted to -`${project.projectDir}/build/generated-sources/xjc`, but can be set to anywhere. +`${project.buildDir}/generated-sources/xjc`, but can be set to anywhere. ### producesDir ### diff --git a/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle b/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle index 975643c..b460148 100644 --- a/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle +++ b/examples/hello-world-bindings-schema/hello-world-bindings-schema.gradle @@ -12,6 +12,6 @@ jaxb { xjc { taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task" args = ["-Xannotate"] - destinationDir = "${project.projectDir}/build/generated-sources/xjc" + destinationDir = "${project.buildDir}/generated-sources/xjc" } } \ No newline at end of file diff --git a/examples/hello-world-import-schema/hello-world-import-schema.gradle b/examples/hello-world-import-schema/hello-world-import-schema.gradle index df010a4..264a2f8 100644 --- a/examples/hello-world-import-schema/hello-world-import-schema.gradle +++ b/examples/hello-world-import-schema/hello-world-import-schema.gradle @@ -3,6 +3,6 @@ version = "0.1" jaxb { xsdDir = "${project.rootDir}/schema/Import" xjc { - destinationDir = "${project.projectDir}/build/generated-sources/xjc" + destinationDir = "${project.buildDir}/generated-sources/xjc" } } \ No newline at end of file diff --git a/examples/hello-world-schema/hello-world-schema.gradle b/examples/hello-world-schema/hello-world-schema.gradle index fec9464..a5a3d5f 100644 --- a/examples/hello-world-schema/hello-world-schema.gradle +++ b/examples/hello-world-schema/hello-world-schema.gradle @@ -3,6 +3,6 @@ version = "0.1" jaxb { xsdDir = "${project.rootDir}/schema/HelloWorld" xjc { - destinationDir = "${project.projectDir}/build/generated-sources/xjc" + destinationDir = "${project.buildDir}/generated-sources/xjc" } } \ No newline at end of file diff --git a/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle b/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle index 37586df..d66637c 100644 --- a/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle +++ b/examples/hello-world-spaces-dir-schema/hello-world-spaces-dir-schema.gradle @@ -2,8 +2,8 @@ version = "0.1" jaxb { xsdDir = "${project.rootDir}/schema/HelloWorld" - episodesDir = "${project.projectDir}/build/generated-resources/schema/space episodes" + episodesDir = "${project.buildDir}/generated-resources/schema/space episodes" xjc { - destinationDir = "${project.projectDir}/build/generated-sources/xjc" + destinationDir = "${project.buildDir}/generated-sources/xjc" } } \ No newline at end of file diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index aa9dd62..b0f77ed 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -63,15 +63,15 @@ class JaxbPlugin implements Plugin { jaxbExtension.with { xsdDir = "${project.projectDir}/src/main/resources/schema" xsdIncludes = ['**/*.xsd'] - episodesDir = "${project.projectDir}/build/generated-resources/episodes" + episodesDir = "${project.buildDir}/generated-resources/episodes" bindingsDir = "${project.projectDir}/src/main/resources/schema" bindings = ['**/*.xjb'] } def xjcExtension = project.jaxb.extensions.create('xjc', XjcExtension) xjcExtension.with { taskClassname = 'com.sun.tools.xjc.XJCTask' - destinationDir = "${project.projectDir}/build/generated-sources/xjc" - producesDir = "${project.projectDir}/build/generated-sources/xjc" + destinationDir = "${project.buildDir}/generated-sources/xjc" + producesDir = "${project.buildDir}/generated-sources/xjc" extension = true removeOldOutput = 'yes' header = true diff --git a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy index a5d9089..e761d62 100644 --- a/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy +++ b/src/test/groovy/org/gradle/jacobo/plugins/JaxbPluginSpec.groovy @@ -29,12 +29,12 @@ class JaxbPluginSpec extends ProjectTaskSpecification { it instanceof JaxbExtension xsdDir == "${project.projectDir}/src/main/resources/schema" xsdIncludes == ['**/*.xsd'] - episodesDir == "${project.projectDir}/build/generated-resources/episodes" + episodesDir == "${project.buildDir}/generated-resources/episodes" bindingsDir == "${project.projectDir}/src/main/resources/schema" bindings == ['**/*.xjb'] with(xjc) { - destinationDir == "${project.projectDir}/build/generated-sources/xjc" - producesDir == "${project.projectDir}/build/generated-sources/xjc" + destinationDir == "${project.buildDir}/generated-sources/xjc" + producesDir == "${project.buildDir}/generated-sources/xjc" extension == 'true' removeOldOutput == 'yes' header == true From 227e2d5a21110790eadcac507d8c8a82d90f4e79 Mon Sep 17 00:00:00 2001 From: wdschei Date: Thu, 4 Feb 2016 15:04:29 -0600 Subject: [PATCH 13/16] Updated a variable name that was causing a test to fail in Gradle 2.10 since it was being confused with the method of the same name. --- .../plugins/factory/XsdDependencyTreeFactorySpec.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/gradle/jacobo/plugins/factory/XsdDependencyTreeFactorySpec.groovy b/src/test/groovy/org/gradle/jacobo/plugins/factory/XsdDependencyTreeFactorySpec.groovy index 2dbaef3..7e5e113 100644 --- a/src/test/groovy/org/gradle/jacobo/plugins/factory/XsdDependencyTreeFactorySpec.groovy +++ b/src/test/groovy/org/gradle/jacobo/plugins/factory/XsdDependencyTreeFactorySpec.groovy @@ -80,7 +80,7 @@ class XsdDependencyTreeFactorySpec extends NamespaceFixture { and: "get expecations for tree root and addChildren" def noDeps = getBaseNamespaces(baseNamespaces) - def expectations = addChildrenExpectations(addChildrenExpectations) + def expectations = addChildrenExpectations(addChildrenExpectationValues) and: "stub out manager getter calls" stubManagerGetCurrentRow(currentRows) @@ -110,7 +110,7 @@ class XsdDependencyTreeFactorySpec extends NamespaceFixture { "RelatedAncestorDependencyScheme", "UnRelatedAncestorDependencyScheme"] baseNamespaces = ["xsd1", "xsd2"] - addChildrenExpectations << [ + addChildrenExpectationValues << [ [["xsd3":["xsd1"],"xsd4":["xsd2"]], ["xsd5":["xsd3"],"xsd6":["xsd4"]]], [["xsd3":["xsd1"], "xsd4":["xsd1", "xsd2"], "xsd5":["xsd2"]], ["xsd6":["xsd3"], "xsd7":["xsd3"], "xsd8":["xsd4", "xsd5"], From 910c5dea3cfd09c58a17a8793539d8014a66b7d9 Mon Sep 17 00:00:00 2001 From: wdschei Date: Thu, 18 Feb 2016 15:27:38 -0600 Subject: [PATCH 14/16] Exposed the XJC Ant Tasks's classpath argument out to the plugin so that XJC Plugins can be used. --- .../org/gradle/jacobo/plugins/JaxbPlugin.groovy | 15 +++++++++++++++ .../org/gradle/jacobo/plugins/ant/AntXjc.groovy | 15 +++++++++------ .../org/gradle/jacobo/plugins/task/JaxbXjc.groovy | 3 ++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index b0f77ed..378f0dc 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -32,6 +32,7 @@ class JaxbPlugin implements Plugin { static final String JAXB_XSD_DEPENDENCY_TREE_TASK = 'xsd-dependency-tree' static final String JAXB_XJC_TASK = 'xjc' static final String JAXB_CONFIGURATION_NAME = 'jaxb' + static final String XJC_CONFIGURATION_NAME = 'xjc' static final Logger log = Logging.getLogger(JaxbPlugin.class) @@ -48,6 +49,7 @@ class JaxbPlugin implements Plugin { configureJaxbExtension(project) configureJaxbConfiguration(project) JaxbDependencyTree jnt = configureJaxbDependencyTree(project, jaxbExtension, injector) + configureXjcConfiguration(project) configureJaxbXjc(project, jaxbExtension, jnt, injector) } @@ -92,6 +94,19 @@ class JaxbPlugin implements Plugin { } } + /** + * Configures this plugins {@code xjc} configuration. + * + * @param project This plugins gradle project + */ + private void configureXjcConfiguration(final Project project) { + project.configurations.create(XJC_CONFIGURATION_NAME) { + visible = true + transitive = true + description = "The JAXB XJC plugin libraries to be used for this project." + } + } + /** * Adds a dependency on tasks with the specified name in other projects. The other projects are determined from * project lib dependencies using the specified configuration name. These may be projects this project depends on or diff --git a/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy index 7c0fe78..b566b16 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/ant/AntXjc.groovy @@ -35,13 +35,14 @@ class AntXjc implements AntExecutor { public void execute(AntBuilder ant, Object... arguments) { XjcExtension extension = arguments[0] def classpath = arguments[1] - def xsds = arguments[2] - def bindings = arguments[3] - def episodes = arguments[4] - def episodeFile = arguments[5] + def pluginsPath = arguments[2] + def xsds = arguments[3] + def bindings = arguments[4] + def episodes = arguments[5] + def episodeFile = arguments[6] - log.info("xjc task is being passed these arguments: Plugin Extension '{}', classpath '{}', xsds '{}', bindings '{}', episodes '{}', episodeFile '{}'", - arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]) + log.info("xjc task is being passed these arguments: Plugin Extension '{}', classpath '{}', pluginsPath '{}', xsds '{}', bindings '{}', episodes '{}', episodeFile '{}'", + extension, classpath, pluginsPath, xsds, bindings, episodes, episodeFile) ant.taskdef (name : 'xjc', classname : extension.taskClassname, @@ -67,6 +68,8 @@ class AntXjc implements AntExecutor { bindings.addToAntBuilder(ant, 'binding', FileCollection.AntType.FileSet) episodes.addToAntBuilder(ant, 'binding', FileCollection.AntType.FileSet) // ant's arg line is space delimited, won't work with spaces + arg(value : "-classpath") + arg(value : "$pluginsPath") arg(value : "-episode") arg(value : "$episodeFile") for (String val : extension.args) { diff --git a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy index fb5c2a0..4dc4762 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy @@ -126,9 +126,10 @@ class JaxbXjc extends DefaultTask { def xjc(xsds, episodes, episodeFile) { def jaxbConfig = project.configurations[JaxbPlugin.JAXB_CONFIGURATION_NAME] + def xjcConfig = project.configurations[JaxbPlugin.XJC_CONFIGURATION_NAME] log.debug("episodes are '{}' is empty '{}'", episodes, episodes.isEmpty()) new File((String)project.jaxb.xjc.destinationDir).mkdirs() - getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, project.files(xsds), + getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, xjcConfig.asPath, project.files(xsds), getBindings(), project.files(episodes), episodeFile) } From 5b0924eca850ba07f6b09f4f04d8334293883a3f Mon Sep 17 00:00:00 2001 From: wdschei Date: Wed, 2 Mar 2016 22:38:09 -0600 Subject: [PATCH 15/16] Synchronized the XJC Ant Task call to allow for Gradle's new parallel project execution. --- .../groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy index 4dc4762..5c8385c 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy @@ -129,8 +129,13 @@ class JaxbXjc extends DefaultTask { def xjcConfig = project.configurations[JaxbPlugin.XJC_CONFIGURATION_NAME] log.debug("episodes are '{}' is empty '{}'", episodes, episodes.isEmpty()) new File((String)project.jaxb.xjc.destinationDir).mkdirs() - getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, xjcConfig.asPath, project.files(xsds), + log.info(" Locking XJC...") + synchronized (JaxbXjc.class) { + log.info(" Locked XJC...") + getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, xjcConfig.asPath, project.files(xsds), getBindings(), project.files(episodes), episodeFile) + log.info("UN-Locked XJC.") + } } def getEpisodeFile(xsdNamespace) { From cf2b7808923e480565b5332f5d41566e870905e4 Mon Sep 17 00:00:00 2001 From: wdschei Date: Thu, 3 Mar 2016 16:26:52 -0600 Subject: [PATCH 16/16] Removed the synchronization from the XJC Ant Task call in favor of changing the default to the multi-process safe XJC2Task. --- .../groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy | 2 +- .../groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy index 378f0dc..2889176 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/JaxbPlugin.groovy @@ -71,7 +71,7 @@ class JaxbPlugin implements Plugin { } def xjcExtension = project.jaxb.extensions.create('xjc', XjcExtension) xjcExtension.with { - taskClassname = 'com.sun.tools.xjc.XJCTask' + taskClassname = 'com.sun.tools.xjc.XJC2Task' destinationDir = "${project.buildDir}/generated-sources/xjc" producesDir = "${project.buildDir}/generated-sources/xjc" extension = true diff --git a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy index 5c8385c..467e6fa 100644 --- a/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy +++ b/src/main/groovy/org/gradle/jacobo/plugins/task/JaxbXjc.groovy @@ -129,13 +129,8 @@ class JaxbXjc extends DefaultTask { def xjcConfig = project.configurations[JaxbPlugin.XJC_CONFIGURATION_NAME] log.debug("episodes are '{}' is empty '{}'", episodes, episodes.isEmpty()) new File((String)project.jaxb.xjc.destinationDir).mkdirs() - log.info(" Locking XJC...") - synchronized (JaxbXjc.class) { - log.info(" Locked XJC...") - getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, xjcConfig.asPath, project.files(xsds), - getBindings(), project.files(episodes), episodeFile) - log.info("UN-Locked XJC.") - } + getXjc().execute(ant, project.jaxb.xjc, jaxbConfig.asPath, xjcConfig.asPath, project.files(xsds), + getBindings(), project.files(episodes), episodeFile) } def getEpisodeFile(xsdNamespace) {