Skip to content

Commit

Permalink
Merge pull request #23 from IntershopCommunicationsAG/configchanged
Browse files Browse the repository at this point in the history
Configchanged
  • Loading branch information
m-raab authored Nov 17, 2019
2 parents 5bca28d + ae9795e commit 2cfadbb
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java
sudo: false
jdk:
- oraclejdk8
- openjdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
Expand Down
25 changes: 13 additions & 12 deletions README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= JAXB Gradle Plugin
:latestRevision: 3.0.3
:latestRevision: 4.0.0
:toc:
:icons: font

Expand Down Expand Up @@ -42,7 +42,15 @@ jaxb {

If the JavaBasePlugin is applied to the project, generated java sources will be added to the specified source set. Per default the main source set is used.

IMPORTANT: This plugin uses the version 2.2.11. It is possible to change this to 2.2.7 or 2.2.10. It will not work with older versions of JAXB. It is possible to overwrite the project dependency configuration 'jaxb', if you want use an other version of JAXB. The classpath of the xjc can be extended with a project configuration 'jaxb' and dependencies.
IMPORTANT: This plugin uses the following dependencies: +
**    org.glassfish.jaxb:jaxb-runtime:2.3.2** +
**    com.sun.xml.bind:jaxb-jxc:2.2.11** +
**    com.sun.xml.bind:jaxb-xjc:2.2.11** +
**    com.sun.xml.bind:jaxb-core:2.2.11** +
It is possible to overwrite the project dependency configuration 'jaxb', if you want use an other version of JAXB.
The classpath of the xjc can be extended with a project configuration 'jaxb' and dependencies.

This configuration is used, because 'org.glassfish.jaxb:jaxb-runtime:2.3.2' does not contain a classpath configuration in the manifest.

== Tasks
The JAXB Gradle plugin adds one task `jaxb` to the project. This task depends on all other plugin task. It is a task added for each configuration in schemaGen and javaGen.
Expand All @@ -58,13 +66,6 @@ The JAXB Gradle plugin adds one task `jaxb` to the project. This task depends on
== Project Extension 'jaxb'
This plugin adds an extension *`jaxb`* to the project.

=== Properties
[cols="17%,17%,17%,49%", width="90%, options="header"]
|===
|Property | Type | Default value | Description
|*xjcVersion* |`String` | '2.2.11' | The version of JAXB.
|===

=== Methods
[cols="20%,15%,65%", width="95%", options="header"]
|===
Expand All @@ -85,10 +86,10 @@ This plugin adds an extension *`jaxb`* to the project.
|*args* | `List<String>` | `[]` | Additional command line arguments passed to the XJC (-use-runtime, -schema, -dtd, -relaxng, -Xlocator, -Xsync-methods)
|*sourceSetName* | `String` | `'main'` | Generated source code will be added to the source set.
|*encoding* | `String` | `'UTF-8'` | specify character encoding for generated source files
|*strictValidation* | `boolean` | `true` | perform strict validation of the input schema
|*strictValidation* | `boolean` | `false` | perform strict validation of the input schema
|*extension* | `boolean` | `false` | allow vendor extensions - do not strictly follow the +
compatibility rules and app E.2 from the JAXB Spec
|*header* | `boolean` | `true` | Generate a header in each generated file indicating that this file is generated by such and such version of JAXB RI when. +
|*header* | `boolean` | `false` | Generate a header in each generated file indicating that this file is generated by such and such version of JAXB RI when. +
If this value is false '-nv' will be added to the command line parameter list.
|*packageName* | `String` | `'generated'` | If specified, generated code will be placed under this Java package.
|*schema* | `File` | `null` | A schema file to be compiled.
Expand Down Expand Up @@ -244,7 +245,7 @@ jaxb {

== License

Copyright 2014-2018 Intershop Communications.
Copyright 2014-2019 Intershop Communications.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Expand Down
27 changes: 18 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ plugins {
`maven-publish`

// intershop version plugin
id("com.intershop.gradle.scmversion") version "4.1.1"
id("com.intershop.gradle.scmversion") version "6.0.0"

// plugin for documentation
id("org.asciidoctor.jvm.convert") version "2.0.0"
id("org.asciidoctor.jvm.convert") version "2.3.0"

// plugin for publishing to Gradle Portal
id("com.gradle.plugin-publish") version "0.10.1"
Expand Down Expand Up @@ -78,7 +78,7 @@ java {
}

sourceSets.main {
java.setSrcDirs(emptyList())
java.setSrcDirs(listOf<String>())
withConvention(GroovySourceSet::class) {
groovy.setSrcDirs(mutableListOf("src/main/groovy", "src/main/java"))
}
Expand All @@ -91,9 +91,11 @@ if (project.version.toString().endsWith("-SNAPSHOT")) {

tasks {
withType<Test>().configureEach {
systemProperty("intershop.gradle.versions", "5.4.1")
systemProperty("intershop.gradle.versions", "5.6.4, 6.0")

if(project.hasProperty("repoURL") && project.hasProperty("repoUser") && project.hasProperty("repoPasswd")) {
if(project.hasProperty("repoURL")
&& project.hasProperty("repoUser")
&& project.hasProperty("repoPasswd")) {
systemProperty("repo_url_config", project.property("repoURL").toString())
systemProperty("repo_user_config", project.property("repoUser").toString())
systemProperty("repo_passwd_config", project.property("repoPasswd").toString())
Expand All @@ -106,9 +108,10 @@ tasks {
includeEmptyDirs = false

val outputDir = file("$buildDir/tmp/asciidoctorSrc")
val inputFiles = fileTree(mapOf("dir" to rootDir,
"include" to listOf("**/*.asciidoc"),
"exclude" to listOf("build/**")))
val inputFiles = fileTree(rootDir) {
include("**/*.asciidoc")
exclude("build/**")
}

inputs.files.plus( inputFiles )
outputs.dir( outputDir )
Expand Down Expand Up @@ -252,8 +255,14 @@ dependencies {
compileOnly("org.jetbrains:annotations:17.0.0")

testImplementation("commons-io:commons-io:2.2")
testImplementation("com.intershop.gradle.test:test-gradle-plugin:3.1.0-dev.2")
testImplementation("com.intershop.gradle.test:test-gradle-plugin:3.4.0")
testImplementation(gradleTestKit())

//testImplementation("org.glassfish.jaxb:jaxb-runtime:2.3.3-b01")
//testImplementation("com.sun.xml.bind:jaxb-jxc:2.2.11")
//testImplementation("com.sun.xml.bind:jaxb-xjc:2.2.11")
//testImplementation("com.sun.xml.bind:jaxb-core:2.2.11")

}

repositories {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 15 additions & 20 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down Expand Up @@ -154,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import org.gradle.api.Project
@CompileStatic
class JaxbExtension {

/**
* Default version of JAXB
*/
public final static String XJC_DEFAULT_VERSION = '2.2.11'

/**
* Extension name
*/
Expand Down Expand Up @@ -85,19 +80,10 @@ class JaxbExtension {

this.project = project

if(! xjcVersion) {
xjcVersion = XJC_DEFAULT_VERSION
}

schemaGen = project.container(JavaToSchema, new JavaToSchemaFactory(project))
javaGen = project.container(SchemaToJava, new SchemaToJavaFactory(project))
}

/**
* Version of xjc, default is 2.2.11
*/
String xjcVersion

/**
* Closure with the configuration of schema generation configurations
* @param closure with schema generation configurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class SchemaToJavaTask extends DefaultTask {

final Property<Boolean> strictValidation = project.objects.property(Boolean)

@Optional
@Input
boolean getStrictValidation() {
return strictValidation.get()
Expand Down Expand Up @@ -211,7 +210,6 @@ class SchemaToJavaTask extends DefaultTask {

final Property<Boolean> header = project.objects.property(Boolean)

@Optional
@Input
boolean getHeader() {
return header.get()
Expand All @@ -227,7 +225,6 @@ class SchemaToJavaTask extends DefaultTask {

final Property<Boolean> extension = project.objects.property(Boolean)

@Optional
@Input
boolean getExtension() {
return extension.get()
Expand Down Expand Up @@ -288,6 +285,13 @@ class SchemaToJavaTask extends DefaultTask {
this.antTaskClassName.set(antTaskClassName)
}

SchemaToJavaTask() {
super()
extension.convention(false)
header.convention(false)
strictValidation.convention(false)
}

@CompileStatic(TypeCheckingMode.SKIP)
@TaskAction
void generate() {
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/intershop/gradle/jaxb/JaxbPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,10 @@ private Configuration getConfiguration(final Project project) {
// this will be executed if configuration is empty
DependencyHandler dependencyHandler = project.getDependencies();

dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-xjc:" + extension.getXjcVersion()));
dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-impl:" + extension.getXjcVersion()));

dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-jxc:" + extension.getXjcVersion()));
dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-core:" + extension.getXjcVersion()));
dependencies.add(dependencyHandler.create("org.glassfish.jaxb:jaxb-runtime:2.3.2"));
dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-jxc:2.2.11"));
dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-xjc:2.2.11"));
dependencies.add(dependencyHandler.create("com.sun.xml.bind:jaxb-core:2.2.11"));
});
return configuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class JaxbPluginSpec extends AbstractProjectSpec {
plugin.apply(project)

then:
project.extensions.getByName(JaxbExtension.JAXB_EXTENSION_NAME).getXjcVersion() == JaxbExtension.XJC_DEFAULT_VERSION
project.extensions.getByName(JaxbExtension.JAXB_EXTENSION_NAME) != null

when:
project.extensions.getByName(JaxbExtension.JAXB_EXTENSION_NAME).schemaGen {
Expand Down
4 changes: 2 additions & 2 deletions src/test/groovy/com/intershop/gradle/jaxb/SamplesSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class SamplesSpec extends AbstractIntegrationGroovySpec {
}
dependencies {
compile 'com.sun.xml.bind:jaxb-core:${JaxbExtension.XJC_DEFAULT_VERSION}'
compile 'com.sun.xml.bind:jaxb-core:2.2.11'
}
repositories {
Expand Down Expand Up @@ -538,7 +538,7 @@ class SamplesSpec extends AbstractIntegrationGroovySpec {
}
dependencies {
compile 'com.sun.xml.bind:jaxb-core:${JaxbExtension.XJC_DEFAULT_VERSION}'
compile 'com.sun.xml.bind:jaxb-core:2.2.11'
}
repositories {
Expand Down

0 comments on commit 2cfadbb

Please sign in to comment.