Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of little updates and a few features. #47

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 65 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
build
*.class
.gradle
## 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
47 changes: 31 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -137,26 +137,25 @@ 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
* `xsdIncludes`
* the schemas to compile
* file name List of strings found in `xsdDir`
* The default glob pattern is `**/*.xsd`
* `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_.
* `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 ##

Expand All @@ -166,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 | `src/main/java` | `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 | `src/main/java` | `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<String>` |
|`removeOldOutput` _(O)_ | Only used with nested `<produces>` elements, when _'yes'_ all files are deleted before XJC is run | _'yes'_ | `String` |
Expand All @@ -185,9 +184,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.buildDir}/generated-sources/xjc`, but can be set to anywhere.

### producesDir ###

Expand All @@ -213,7 +211,7 @@ _(per project)_ is the `xsdDir`, and jaxb dependencies as described above.

```groovy
jaxb {
xsdDir = "schema/folder1"
xsdDir = "${project.projectDir}/schema/folder1"
}
```

Expand All @@ -231,7 +229,7 @@ dependencies {
}

jaxb {
xsdDir = "some/folder"
xsdDir = "${project.projectDir}/some/folder"
xjc {
taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task"
generatePackage = "com.company.example"
Expand Down Expand Up @@ -262,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
==============

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down
55 changes: 28 additions & 27 deletions examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
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'
// }
//**********************************************************

// use artifacts from bintray
//******************************************************
//********************************************************************************
// uncomment for local testing
//--------------------------------------------------------------------------------
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 {

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'
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.buildDir}/generated-sources/xjc"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version = "0.1"

jaxb {
xsdDir = "schema/Import"
xsdDir = "${project.rootDir}/schema/Import"
xjc {
destinationDir = "${project.buildDir}/generated-sources/xjc"
}
}
5 changes: 4 additions & 1 deletion examples/hello-world-schema/hello-world-schema.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version = "0.1"

jaxb {
xsdDir = "schema/HelloWorld"
xsdDir = "${project.rootDir}/schema/HelloWorld"
xjc {
destinationDir = "${project.buildDir}/generated-sources/xjc"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version = "0.1"

jaxb {
xsdDir = "schema/HelloWorld"
episodesDir = "schema/space episodes"
xsdDir = "${project.rootDir}/schema/HelloWorld"
episodesDir = "${project.buildDir}/generated-resources/schema/space episodes"
xjc {
destinationDir = "${project.buildDir}/generated-sources/xjc"
}
}
Loading