├── .github ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── maven.yml │ └── release-drafter.yml ├── .gitignore ├── .java-version ├── LICENSE.txt ├── README.md ├── pom.xml └── src ├── it ├── mjaxb-14 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── dtd │ │ │ └── library.dtd │ └── verify.groovy ├── mjaxb-16 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── mjaxb-17-warning │ └── pom.xml ├── mjaxb-17 │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ └── main │ │ └── xsd │ │ └── noSchemasHere.txt ├── mjaxb-37 │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── foo │ │ │ │ └── bar │ │ │ │ └── Main.java │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── mjaxb-55-partialdefaults │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── se │ │ │ │ └── west │ │ │ │ └── schema │ │ │ │ ├── FooBar.java │ │ │ │ ├── FooBaz.java │ │ │ │ └── Namespaces.java │ │ │ └── resources │ │ │ └── expected │ │ │ ├── schema3.xsd │ │ │ ├── some_schema.xsd │ │ │ └── yet_another_schema.xsd │ └── verify.groovy ├── mjaxb-55 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── se │ │ │ │ └── west │ │ │ │ └── schema │ │ │ │ ├── FooBar.java │ │ │ │ ├── FooBaz.java │ │ │ │ └── Namespaces.java │ │ │ └── resources │ │ │ └── expected │ │ │ ├── another_schema.xsd │ │ │ ├── some_schema.xsd │ │ │ └── yet_another_schema.xsd │ └── verify.groovy ├── mjaxb-59 │ ├── module1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── Foo.java │ ├── pom.xml │ └── verify.groovy ├── mjaxb-64 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── shauqra │ │ │ ├── FooWithEmptyXmlTypeName.java │ │ │ └── FooWithSuppliedXmlTypeName.java │ └── verify.groovy ├── mjaxb-71 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── fooBarSource │ │ │ └── se │ │ │ └── west │ │ │ └── shauqra │ │ │ ├── FooWithEmptyXmlTypeName.java │ │ │ └── FooWithSuppliedXmlTypeName.java │ └── verify.groovy ├── mjaxb-80 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── domain │ │ │ ├── ImportItemDTO.java │ │ │ ├── ImportItemsDTO.java │ │ │ ├── SomeImportItemDTO.java │ │ │ ├── SomeOtherImportItemDTO.java │ │ │ ├── jaxb.index │ │ │ └── package-info.java │ └── verify.groovy ├── mjaxb-81 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── acme │ │ │ ├── FooBar.java │ │ │ ├── FooBaz.java │ │ │ └── package-info.java │ └── verify.groovy ├── schemagen-custom-converter │ ├── converters │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── converter │ │ │ └── FileNameConverter.java │ ├── invoker.properties │ ├── pom.xml │ ├── some_project │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ ├── Bar.java │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-encoding-utf8 │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── shauqra │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-handles-enums │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ ├── AmericanCoin.java │ │ │ ├── FoodPreference.java │ │ │ └── FoodPreferences.java │ └── verify.groovy ├── schemagen-handles-package-info │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── testing │ │ │ └── xml │ │ │ ├── MyType.java │ │ │ └── package-info.java │ └── verify.groovy ├── schemagen-handles-spaces in paths │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── se │ │ └── west │ │ └── SomeType.java ├── schemagen-handles-xmlwrappers │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── codehaus │ │ │ └── mojo │ │ │ └── jaxb2 │ │ │ └── schemageneration │ │ │ └── postprocessing │ │ │ └── javadoc │ │ │ └── wrappers │ │ │ ├── ExampleXmlWrapperUsingFieldAccess.java │ │ │ └── ExampleXmlWrapperUsingMethodAccess.java │ └── verify.groovy ├── schemagen-include-sources │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ ├── ANonAnnotatedClass.java │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-include-test-sources │ ├── pom.xml │ ├── src │ │ └── test │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ ├── ANonAnnotatedClass.java │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-jaxb-errors │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── IncorrectJaxbAnnotationClass.java │ └── verify.groovy ├── schemagen-main │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-multimodule-project │ ├── first │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── first │ │ │ ├── NonAnnotatedFirst.java │ │ │ └── gnat │ │ │ └── FirstFoo.java │ ├── pom.xml │ ├── second │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── second │ │ │ └── gnat │ │ │ └── SecondFoo.java │ ├── third │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ ├── ShouldNotBeIncluded.java │ │ │ └── third │ │ │ └── gnat │ │ │ ├── ExplicitlyExcluded.java │ │ │ └── ThirdFoo.java │ └── verify.groovy ├── schemagen-platform-encoding │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── se │ │ └── west │ │ └── gnat │ │ └── Foo.java ├── schemagen-rename-type │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-skipping-nonexistent-sources │ ├── pom.xml │ └── verify.groovy ├── schemagen-test │ ├── pom.xml │ ├── src │ │ └── test │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── blah │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-with-explicit-locale │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-without-episode │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── schemagen-work-directory │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── se │ │ │ └── west │ │ │ └── gnat │ │ │ └── Foo.java │ └── verify.groovy ├── settings.xml ├── xjc-exclude-file-patterns │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── foo │ │ │ └── gnat.txt │ │ │ └── someOtherXsds │ │ │ ├── another_schema.foo │ │ │ ├── fooSchema.txt │ │ │ ├── some_schema.bar │ │ │ └── thisShouldBeIgnored.xsd │ └── verify.groovy ├── xjc-handles-spaces-in-filenames │ ├── pom.xml │ ├── src │ │ └── main │ │ │ ├── xjb │ │ │ └── spaced filename.xjb │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── xjc-include-xsds-in-artifact │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── xjc-main │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── xjc-mark-generated │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── xjc-multiple-executions │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ ├── a.xsd │ │ │ └── b.xsd │ └── verify.groovy ├── xjc-multiple-xsd-specified │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ ├── a.xsd │ │ │ ├── b.xsd │ │ │ ├── c.xsd │ │ │ └── d.xsd │ └── verify.bsh ├── xjc-platform-encoding │ ├── pom.xml │ └── src │ │ └── main │ │ └── xsd │ │ └── address.xsd ├── xjc-plugins │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy ├── xjc-test │ ├── pom.xml │ ├── src │ │ └── test │ │ │ └── xsd │ │ │ └── address.xsd │ └── verify.groovy └── xjc-with-explicit-locale │ ├── pom.xml │ ├── src │ └── main │ │ └── xsd │ │ └── address.xsd │ └── verify.groovy ├── main ├── java │ └── org │ │ └── codehaus │ │ └── mojo │ │ └── jaxb2 │ │ ├── AbstractJaxbMojo.java │ │ ├── NoSchemasException.java │ │ ├── javageneration │ │ ├── AbstractJavaGeneratorMojo.java │ │ ├── SourceContentType.java │ │ ├── TestXjcMojo.java │ │ ├── XjcLogAdapter.java │ │ ├── XjcMojo.java │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── schemageneration │ │ ├── AbstractXsdGeneratorMojo.java │ │ ├── SchemaGenerationMojo.java │ │ ├── TestSchemaGenerationMojo.java │ │ ├── XsdGeneratorHelper.java │ │ ├── package-info.java │ │ └── postprocessing │ │ │ ├── NodeProcessor.java │ │ │ ├── javadoc │ │ │ ├── DefaultJavaDocRenderer.java │ │ │ ├── DomHelper.java │ │ │ ├── JavaDocData.java │ │ │ ├── JavaDocExtractor.java │ │ │ ├── JavaDocRenderer.java │ │ │ ├── NoAuthorJavaDocRenderer.java │ │ │ ├── SearchableDocumentation.java │ │ │ ├── SortableLocation.java │ │ │ ├── XsdAnnotationProcessor.java │ │ │ ├── XsdEnumerationAnnotationProcessor.java │ │ │ └── location │ │ │ │ ├── ClassLocation.java │ │ │ │ ├── FieldLocation.java │ │ │ │ ├── MethodLocation.java │ │ │ │ └── PackageLocation.java │ │ │ └── schemaenhancement │ │ │ ├── ChangeFilenameProcessor.java │ │ │ ├── ChangeNamespacePrefixProcessor.java │ │ │ ├── SimpleNamespaceResolver.java │ │ │ └── TransformSchema.java │ │ └── shared │ │ ├── FileSystemUtilities.java │ │ ├── JavaVersion.java │ │ ├── Validate.java │ │ ├── arguments │ │ └── ArgumentBuilder.java │ │ ├── environment │ │ ├── AbstractLogAwareFacet.java │ │ ├── EnvironmentFacet.java │ │ ├── ToolExecutionEnvironment.java │ │ ├── classloading │ │ │ ├── ContextClassLoaderEnvironmentFacet.java │ │ │ ├── ThreadContextClassLoaderBuilder.java │ │ │ └── ThreadContextClassLoaderHolder.java │ │ ├── locale │ │ │ └── LocaleFacet.java │ │ ├── logging │ │ │ ├── LoggingHandlerEnvironmentFacet.java │ │ │ └── MavenLogHandler.java │ │ └── sysprops │ │ │ ├── SystemPropertyChangeEnvironmentFacet.java │ │ │ └── SystemPropertySaveEnvironmentFacet.java │ │ ├── filters │ │ ├── AbstractFilter.java │ │ ├── Filter.java │ │ ├── Filters.java │ │ └── pattern │ │ │ ├── AbstractPatternFilter.java │ │ │ ├── FileFilterAdapter.java │ │ │ ├── PatternFileFilter.java │ │ │ ├── PatternURLFilter.java │ │ │ ├── StringConverter.java │ │ │ └── ToStringConverter.java │ │ ├── package-info.java │ │ └── version │ │ ├── DependencyInfo.java │ │ └── DependsFileParser.java └── resources │ └── META-INF │ ├── m2e │ └── lifecycle-mapping-metadata.xml │ └── plexus │ └── components.xml ├── site ├── fml │ └── faq.fml ├── markdown │ ├── example_schemagen_basic.md │ ├── example_schemagen_postprocessing.md │ ├── example_xjc_basic.md │ ├── filters.md │ └── index.md ├── puml │ ├── detailedFilterHierarchy.puml │ ├── postProcessing.puml │ └── sourceAndExcludeFilter.puml ├── resources │ └── images │ │ ├── FilterHierarchy.png │ │ ├── documentation_hub.png │ │ └── documentation_structure.png └── site.xml └── test ├── java └── org │ └── codehaus │ └── mojo │ └── jaxb2 │ ├── BufferingLog.java │ ├── PropertyResources.java │ ├── schemageneration │ └── postprocessing │ │ ├── AbstractJavadocExtractorTest.java │ │ ├── DebugNodeProcessor.java │ │ ├── XsdGeneratorHelperTest.java │ │ ├── javadoc │ │ ├── AbstractSourceCodeAwareNodeProcessingTest.java │ │ ├── DomHelperTest.java │ │ ├── FieldLocationTest.java │ │ ├── JavaDocExtractorTest.java │ │ ├── SemiDocumentedClass.java │ │ ├── SomewhatNamedPerson.java │ │ ├── XsdAnnotationProcessorSemiDocumentedTest.java │ │ ├── XsdAnnotationProcessorTest.java │ │ ├── XsdEnumerationAnnotationProcessorTest.java │ │ ├── enums │ │ │ ├── AmericanCoin.java │ │ │ ├── County.java │ │ │ ├── ExampleEnumHolder.java │ │ │ ├── FoodPreference.java │ │ │ ├── Municipality.java │ │ │ ├── Regions.java │ │ │ └── XsdAnnotationProcessorAndEnumsTest.java │ │ └── wrappers │ │ │ ├── ExampleXmlWapperUsingJavaBeanAccessors.java │ │ │ └── ExampleXmlWrapper.java │ │ └── schemaenhancement │ │ ├── ChangeFilenameProcessorTest.java │ │ ├── ChangeNamespacePrefixProcessorTest.java │ │ ├── SimpleNamespaceResolverTest.java │ │ ├── TransformSchemaTest.java │ │ └── XmlNameAnnotatedClassWithFieldAccess.java │ └── shared │ ├── FileSystemUtilitiesTest.java │ ├── ValidateTest.java │ ├── arguments │ └── ArgumentBuilderTest.java │ ├── classloader │ └── ThreadContextClassLoaderBuilderTest.java │ ├── environment │ ├── locale │ │ └── LocaleFacetTest.java │ └── sysprops │ │ └── SystemPropertySaveEnvironmentFacetTest.java │ ├── filters │ ├── DebugFilter.java │ ├── FiltersTest.java │ ├── PackageFilterInclusionTest.java │ ├── T_AbstractFilterTest.java │ └── pattern │ │ ├── AbstractPatternFilterTest.java │ │ ├── DebugPatternFilter.java │ │ ├── PatternFileFilterTest.java │ │ ├── PatternURLFilterTest.java │ │ └── T_AbstractPatternFilterTest.java │ └── version │ └── DependencyFileParserTest.java └── resources ├── generated └── schema │ ├── schema1.xsd │ ├── schema2.xsd │ └── schema3.xsd ├── logback-test.xml ├── org └── codehaus │ └── mojo │ └── jaxb2 │ └── helpers │ ├── anotherSchema.xsd │ ├── someSchema.xsd │ └── yetAnotherSchema.xsd ├── testdata ├── schemageneration │ └── javadoc │ │ ├── annotated │ │ ├── XmlNameAnnotatedClassWithFieldAccess.java │ │ └── XmlNameAnnotatedClassWithMethodAccess.java │ │ ├── basic │ │ └── NodeProcessor.java │ │ ├── enums │ │ ├── AmericanCoin.java │ │ ├── ExampleEnumHolder.java │ │ ├── FoodPreference.java │ │ ├── expectedTransformedExampleEnumHolder.xsd │ │ ├── processedEnumSchema.xsd │ │ └── rawEnumSchema.xsd │ │ ├── expectedRawExampleEnumHolder.xml │ │ ├── expectedSemiDocumentedClass.xml │ │ ├── expectedTransformedSomewhatNamedPerson.xml │ │ ├── methodbased │ │ └── ExampleXmlWrapperUsingMethodAccess.java │ │ └── xmlwrappers │ │ ├── ExampleXmlWrapperUsingFieldAccess.java │ │ ├── ExampleXmlWrapperUsingMethodAccess.java │ │ ├── expectedJavaDocXmlWrappersSchema.xsd │ │ └── expectedRawXmlWrappers.xsd └── shared │ ├── classloader │ ├── ImmediateTestResource.txt │ ├── jarSubDirectory │ │ └── aJarWithResources.jar │ └── subdirectory │ │ └── SubdirectoryTestResource.txt │ ├── deps1.properties │ ├── dirwith space │ └── somefile.txt │ ├── filefilter │ └── exclusion │ │ ├── AnXmlFile.xml │ │ └── TextFile.txt │ ├── filesystemutilities │ ├── TestFile2.txt │ └── canonicals │ │ └── TestFile1.txt │ ├── nazgul-tools-validation-aspect-4.0.1.jar │ ├── not_a_dependency.properties │ ├── standard │ └── exclusions │ │ ├── .hg │ │ └── someHgFile.txt │ │ ├── .svn │ │ └── someSvnFile.txt │ │ ├── CVS │ │ └── someCvsFile.txt │ │ └── someFile.log │ └── urlhandling │ └── file with spaces.txt └── testschemas ├── address.xsd ├── address2.xsd ├── address3.xsd └── address4.xsd /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | ignore: 8 | # Checkstyle >=10 requires Java 11+ 9 | - dependency-name: "com.puppycrawl.tools:checkstyle" 10 | versions: [">= 10.0"] 11 | - dependency-name: "se.jguru.shared.algorithms.api:jguru-shared-algorithms-api" 12 | versions: [">= 0.13.0"] 13 | - package-ecosystem: "github-actions" 14 | directory: "/" 15 | schedule: 16 | interval: "daily" 17 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | _extends: .github 2 | # mojo-parent uses a single version number, no semantic versioning 3 | version-template: '$MAJOR' 4 | name-template: '$NEXT_MAJOR_VERSION' 5 | tag-template: 'mojo-parent-$NEXT_MAJOR_VERSION' 6 | template: | 7 | ## Changes 8 | 9 | $CHANGES -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: GitHub CI 19 | 20 | on: [push, pull_request] 21 | 22 | jobs: 23 | build: 24 | name: Verify 25 | uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 26 | with: 27 | ff-goal: '-P run-its install' # site use project version for reporting 28 | verify-goal: '-P run-its install' # should be the same as for first build 29 | 30 | # deploy: 31 | # name: Deploy 32 | # needs: build 33 | # uses: mojohaus/.github/.github/workflows/maven-deploy.yml@master 34 | # secrets: inherit 35 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | on: 3 | push: 4 | branches: 5 | - master 6 | workflow_dispatch: 7 | jobs: 8 | update_release_draft: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: release-drafter/release-drafter@v6 12 | env: 13 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 14 | -------------------------------------------------------------------------------- /.java-version: -------------------------------------------------------------------------------- 1 | 1.8 2 | -------------------------------------------------------------------------------- /src/it/mjaxb-14/src/main/dtd/library.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/it/mjaxb-14/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | // Verify the existence of some of the generated classes 21 | File objectFactory = new File( basedir,'target/generated-sources/jaxb/com/example/myschema/ObjectFactory.java' ) 22 | assert objectFactory.exists() 23 | File book = new File( basedir,'target/generated-sources/jaxb/com/example/myschema/Book.java' ) 24 | assert book.exists() 25 | File library = new File( basedir,'target/generated-sources/jaxb/com/example/myschema/Library.java' ) 26 | assert library.exists() 27 | 28 | File testSources = new File( basedir,'target/generated-test-sources/jaxb/' ) 29 | assert !testSources.exists() 30 | 31 | File objectFactoryCompiled = new File( basedir,'target/classes/com/example/myschema/ObjectFactory.class' ) 32 | assert objectFactoryCompiled.exists() 33 | File bookCompiled = new File( basedir,'target/classes/com/example/myschema/Book.class' ) 34 | assert bookCompiled.exists() 35 | File libraryCompiled = new File( basedir,'target/classes/com/example/myschema/Library.class' ) 36 | assert libraryCompiled.exists() 37 | -------------------------------------------------------------------------------- /src/it/mjaxb-16/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/mjaxb-17/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/mjaxb-17/src/main/xsd/noSchemasHere.txt: -------------------------------------------------------------------------------- 1 | This directory should contain no XSDs. -------------------------------------------------------------------------------- /src/it/mjaxb-37/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = clean compile -------------------------------------------------------------------------------- /src/it/mjaxb-37/src/main/java/foo/bar/Main.java: -------------------------------------------------------------------------------- 1 | package foo.bar; 2 | 3 | import com.example.myschema.*; 4 | 5 | public class Main 6 | { 7 | 8 | public static void main( String args ) 9 | { 10 | ObjectFactory objectFactory = new ObjectFactory(); 11 | AddressType address = objectFactory.createAddressType(); 12 | boolean primary = address.isPrimary(); 13 | Boolean expensive = address.getExpensive(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/it/mjaxb-37/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/mjaxb-37/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | target/it/mjaxb-37/target/classes/com/example/myschema/AddressType.class 3 | target/it/mjaxb-37/target/classes/com/example/myschema/ObjectFactory.class 4 | target/it/mjaxb-37/target/classes/foo/bar/Main.class 5 | target/it/mjaxb-37/target/classes/xsd/address.xsd 6 | 7 | target/it/mjaxb-37/target/generated-sources/jaxb/META-INF/sun-jaxb.episode 8 | target/it/mjaxb-37/target/generated-sources/jaxb/com/example/myschema/AddressType.java 9 | target/it/mjaxb-37/target/generated-sources/jaxb/com/example/myschema/ObjectFactory.java 10 | target/it/mjaxb-37/target/jaxb2/.xjc-xjcStaleFlag 11 | */ 12 | 13 | // Assemble 14 | File generatedSourcesDir = new File(basedir, "target/generated-sources") 15 | File classesDir = new File(basedir, "target/classes") 16 | File episodeFile = new File(classesDir, 'META-INF/JAXB/episode_xjc.xjb') 17 | 18 | File addressTypeSourceFile = new File(generatedSourcesDir, 'jaxb/com/example/myschema/AddressType.java') 19 | List addressTypeSource = addressTypeSourceFile.readLines(); 20 | 21 | String expectedPrimitiveBooleanLine = "protected boolean primary;"; 22 | String expectedBooleanClassLine = "protected Boolean expensive;"; 23 | String expectedBooleanClassAnnotationLine = "@XmlElement(required = true, type = Boolean.class, nillable = true)"; 24 | 25 | boolean primitiveBooleanPrimaryFound = false; 26 | boolean classBooleanExpensiveFound = false; 27 | boolean expensiveAnnotationLineFound = false; 28 | 29 | // Act 30 | for(line in addressTypeSource) { 31 | 32 | String trimmedLine = line.trim() 33 | if (trimmedLine.isEmpty()) { 34 | continue 35 | }; 36 | 37 | if(trimmedLine.equals(expectedPrimitiveBooleanLine)) { 38 | primitiveBooleanPrimaryFound = true; 39 | } 40 | 41 | if(trimmedLine.equals(expectedBooleanClassLine)) { 42 | classBooleanExpensiveFound = true; 43 | } 44 | 45 | if(trimmedLine.equals(expectedBooleanClassAnnotationLine)) { 46 | expensiveAnnotationLineFound = true; 47 | } 48 | } 49 | 50 | // Assert 51 | def missingRequired(String trimmedLine) { 52 | return "Missing required line: [" + trimmedLine + "]" ; 53 | } 54 | 55 | assert primitiveBooleanPrimaryFound, missingRequired(expectedPrimitiveBooleanLine); 56 | assert classBooleanExpensiveFound, missingRequired(expectedBooleanClassLine); 57 | assert expensiveAnnotationLineFound, missingRequired(expectedBooleanClassAnnotationLine); 58 | assert episodeFile.exists() && episodeFile.isFile(), "Episode file [" + episodeFile.getPath() + "] not found" -------------------------------------------------------------------------------- /src/it/mjaxb-55-partialdefaults/src/main/java/se/west/schema/FooBar.java: -------------------------------------------------------------------------------- 1 | package se.west.schema; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * @author Lennart Jörelid 11 | */ 12 | @XmlType(namespace = Namespaces.SOME_NAMESPACE, 13 | propOrder = {"requiredElement", "aRequiredElementInAnotherNamespace", 14 | "optionalElement", "requiredAttribute", "optionalAttribute"}) 15 | @XmlAccessorType(XmlAccessType.FIELD) 16 | public class FooBar { 17 | 18 | @XmlElement(required = true, defaultValue = "requiredElementValue") 19 | private String requiredElement; 20 | 21 | @XmlElement(namespace = Namespaces.ANOTHER_NAMESPACE, required = true, defaultValue = "requiredElementValue") 22 | private String aRequiredElementInAnotherNamespace; 23 | 24 | @XmlElement(required = false) 25 | private String optionalElement; 26 | 27 | @XmlAttribute(required = true) 28 | private String requiredAttribute; 29 | 30 | @XmlAttribute(required = false) 31 | private String optionalAttribute; 32 | } 33 | -------------------------------------------------------------------------------- /src/it/mjaxb-55-partialdefaults/src/main/java/se/west/schema/FooBaz.java: -------------------------------------------------------------------------------- 1 | package se.west.schema; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * @author Lennart Jörelid 11 | */ 12 | @XmlType(namespace = Namespaces.ANOTHER_NAMESPACE, 13 | propOrder = {"requiredElement", "anOptionalElementInSomeNamespace", 14 | "aRequiredElementInYetAnotherNamespace", "requiredAttribute", "optionalAttribute"}) 15 | @XmlAccessorType(XmlAccessType.FIELD) 16 | public class FooBaz { 17 | 18 | @XmlElement(required = true, defaultValue = "requiredElementValue") 19 | private String requiredElement; 20 | 21 | @XmlElement(namespace = Namespaces.YET_ANOTHER_NAMESPACE, required = true, defaultValue = "requiredElementValue") 22 | private String aRequiredElementInYetAnotherNamespace; 23 | 24 | @XmlElement(namespace = Namespaces.SOME_NAMESPACE, required = false) 25 | private String anOptionalElementInSomeNamespace; 26 | 27 | @XmlAttribute(required = true) 28 | private String requiredAttribute; 29 | 30 | @XmlAttribute(required = false) 31 | private String optionalAttribute; 32 | } 33 | -------------------------------------------------------------------------------- /src/it/mjaxb-55-partialdefaults/src/main/java/se/west/schema/Namespaces.java: -------------------------------------------------------------------------------- 1 | package se.west.schema; 2 | 3 | /** 4 | * @author Lennart Jörelid 5 | */ 6 | public interface Namespaces { 7 | 8 | public static final String SOME_NAMESPACE = "http://some/namespace"; 9 | public static final String ANOTHER_NAMESPACE = "http://another/namespace"; 10 | public static final String YET_ANOTHER_NAMESPACE = "http://yet/another/namespace"; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/mjaxb-55-partialdefaults/src/main/resources/expected/schema3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/it/mjaxb-55-partialdefaults/src/main/resources/expected/some_schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/mjaxb-55-partialdefaults/src/main/resources/expected/yet_another_schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/it/mjaxb-55/src/main/java/se/west/schema/FooBar.java: -------------------------------------------------------------------------------- 1 | package se.west.schema; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * @author Lennart Jörelid 11 | */ 12 | @XmlType(namespace = Namespaces.SOME_NAMESPACE, 13 | propOrder = {"requiredElement", "aRequiredElementInAnotherNamespace", 14 | "optionalElement", "requiredAttribute", "optionalAttribute"}) 15 | @XmlAccessorType(XmlAccessType.FIELD) 16 | public class FooBar { 17 | 18 | @XmlElement(required = true, defaultValue = "requiredElementValue") 19 | private String requiredElement; 20 | 21 | @XmlElement(namespace = Namespaces.ANOTHER_NAMESPACE, required = true, defaultValue = "requiredElementValue") 22 | private String aRequiredElementInAnotherNamespace; 23 | 24 | @XmlElement(required = false) 25 | private String optionalElement; 26 | 27 | @XmlAttribute(required = true) 28 | private String requiredAttribute; 29 | 30 | @XmlAttribute(required = false) 31 | private String optionalAttribute; 32 | } 33 | -------------------------------------------------------------------------------- /src/it/mjaxb-55/src/main/java/se/west/schema/FooBaz.java: -------------------------------------------------------------------------------- 1 | package se.west.schema; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * @author Lennart Jörelid 11 | */ 12 | @XmlType(namespace = Namespaces.ANOTHER_NAMESPACE, 13 | propOrder = {"requiredElement", "anOptionalElementInSomeNamespace", 14 | "aRequiredElementInYetAnotherNamespace", "requiredAttribute", "optionalAttribute"}) 15 | @XmlAccessorType(XmlAccessType.FIELD) 16 | public class FooBaz { 17 | 18 | @XmlElement(required = true, defaultValue = "requiredElementValue") 19 | private String requiredElement; 20 | 21 | @XmlElement(namespace = Namespaces.YET_ANOTHER_NAMESPACE, required = true, defaultValue = "requiredElementValue") 22 | private String aRequiredElementInYetAnotherNamespace; 23 | 24 | @XmlElement(namespace = Namespaces.SOME_NAMESPACE, required = false) 25 | private String anOptionalElementInSomeNamespace; 26 | 27 | @XmlAttribute(required = true) 28 | private String requiredAttribute; 29 | 30 | @XmlAttribute(required = false) 31 | private String optionalAttribute; 32 | } 33 | -------------------------------------------------------------------------------- /src/it/mjaxb-55/src/main/java/se/west/schema/Namespaces.java: -------------------------------------------------------------------------------- 1 | package se.west.schema; 2 | 3 | /** 4 | * @author Lennart Jörelid 5 | */ 6 | public interface Namespaces { 7 | 8 | public static final String SOME_NAMESPACE = "http://some/namespace"; 9 | public static final String ANOTHER_NAMESPACE = "http://another/namespace"; 10 | public static final String YET_ANOTHER_NAMESPACE = "http://yet/another/namespace"; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/mjaxb-55/src/main/resources/expected/another_schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/it/mjaxb-55/src/main/resources/expected/some_schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/mjaxb-55/src/main/resources/expected/yet_another_schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/it/mjaxb-59/module1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 23 | 4.0.0 24 | 25 | 26 | org.codehaus.mojo.jaxb2.its 27 | mjaxb-59 28 | 1.0-SNAPSHOT 29 | 30 | mjaxb-59-module1 31 | 32 | 33 | 34 | jakarta.xml.bind 35 | jakarta.xml.bind-api 36 | 3.0.0 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/it/mjaxb-59/module1/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/mjaxb-64/src/main/java/se/west/shauqra/FooWithEmptyXmlTypeName.java: -------------------------------------------------------------------------------- 1 | package se.west.shauqra; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlRootElement(name = "customerForNamelessFoo", namespace = "http://acme.com/customer-api") 10 | @XmlType(name = "", namespace = "http://acme.com/customer-api") 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | public class FooWithEmptyXmlTypeName { 13 | @XmlElement(required = true, defaultValue = "defaultName") 14 | private String name; 15 | 16 | @XmlElement(required = true, namespace = "http://acme.com/customer-api") 17 | private String anotherName; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getAnotherName() { 28 | return anotherName; 29 | } 30 | 31 | public void setAnotherName(String name) { 32 | this.anotherName = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/it/mjaxb-64/src/main/java/se/west/shauqra/FooWithSuppliedXmlTypeName.java: -------------------------------------------------------------------------------- 1 | package se.west.shauqra; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlRootElement(name = "customerForSomeFoo", namespace = "http://acme.com/customer-api") 10 | @XmlType(name = "someFoo", namespace = "http://acme.com/customer-api") 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | public class FooWithSuppliedXmlTypeName { 13 | @XmlElement(required = true, defaultValue = "defaultName") 14 | private String name; 15 | 16 | @XmlElement(required = true, namespace = "http://acme.com/customer-api") 17 | private String anotherName; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getAnotherName() { 28 | return anotherName; 29 | } 30 | 31 | public void setAnotherName(String name) { 32 | this.anotherName = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/it/mjaxb-71/src/main/fooBarSource/se/west/shauqra/FooWithEmptyXmlTypeName.java: -------------------------------------------------------------------------------- 1 | package se.west.shauqra; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlRootElement(name = "customerForNamelessFoo", namespace = "http://acme.com/customer-api") 10 | @XmlType(name = "", namespace = "http://acme.com/customer-api") 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | public class FooWithEmptyXmlTypeName { 13 | @XmlElement(required = true, defaultValue = "defaultName") 14 | private String name; 15 | 16 | /** 17 | * JavaDoc for anotherName. 18 | */ 19 | @XmlElement(required = true, namespace = "http://acme.com/customer-api") 20 | private String anotherName; 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getAnotherName() { 31 | return anotherName; 32 | } 33 | 34 | public void setAnotherName(String name) { 35 | this.anotherName = name; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/it/mjaxb-71/src/main/fooBarSource/se/west/shauqra/FooWithSuppliedXmlTypeName.java: -------------------------------------------------------------------------------- 1 | package se.west.shauqra; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlRootElement(name = "customerForSomeFoo", namespace = "http://acme.com/customer-api") 10 | @XmlType(name = "someFoo", namespace = "http://acme.com/customer-api") 11 | @XmlAccessorType(XmlAccessType.FIELD) 12 | public class FooWithSuppliedXmlTypeName { 13 | @XmlElement(required = true, defaultValue = "defaultName") 14 | private String name; 15 | 16 | @XmlElement(required = true, namespace = "http://acme.com/customer-api") 17 | private String anotherName; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getAnotherName() { 28 | return anotherName; 29 | } 30 | 31 | public void setAnotherName(String name) { 32 | this.anotherName = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/it/mjaxb-80/src/main/java/org/domain/ImportItemDTO.java: -------------------------------------------------------------------------------- 1 | package org.domain; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlSeeAlso; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlAccessorType(XmlAccessType.FIELD) 10 | @XmlType(namespace = "http://schema.domain.org/integration/1.0", 11 | name = "importItem") 12 | @XmlSeeAlso({ SomeImportItemDTO.class, SomeOtherImportItemDTO.class }) 13 | public abstract class ImportItemDTO { 14 | 15 | @XmlAttribute 16 | private String id; 17 | 18 | public String getId() { 19 | return id; 20 | } 21 | 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/it/mjaxb-80/src/main/java/org/domain/ImportItemsDTO.java: -------------------------------------------------------------------------------- 1 | package org.domain; 2 | 3 | import jakarta.xml.bind.annotation.XmlElementRef; 4 | import jakarta.xml.bind.annotation.XmlRootElement; 5 | import jakarta.xml.bind.annotation.XmlType; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @XmlType(namespace = "http://schema.domain.org/integration/1.0", 10 | name = "importItems", 11 | propOrder = {"someImportItems", "someOtherImportItems"}) 12 | @XmlRootElement(namespace = "http://schema.domain.org/integration/1.0", 13 | name = "importItems") 14 | public class ImportItemsDTO { 15 | 16 | @XmlElementRef 17 | private List someImportItems = 18 | new ArrayList(); 19 | 20 | public List getSomeImportItems() { 21 | return someImportItems; 22 | } 23 | 24 | @XmlElementRef 25 | private List someOtherImportItems = 26 | new ArrayList(); 27 | 28 | public List getSomeOtherImportItems() { 29 | return someOtherImportItems; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/it/mjaxb-80/src/main/java/org/domain/SomeImportItemDTO.java: -------------------------------------------------------------------------------- 1 | package org.domain; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlAccessorType(XmlAccessType.FIELD) 10 | @XmlType(namespace = "http://schema.domain.org/integration/1.0", 11 | name = "someImportItem", 12 | propOrder = {"someIdentifier"}) 13 | @XmlRootElement(namespace = "http://schema.domain.org/integration/1.0", 14 | name = "someImportItem") 15 | public class SomeImportItemDTO extends ImportItemDTO { 16 | 17 | @XmlElement(name = "someIdentifier", required = true) 18 | private String someIdentifier; 19 | 20 | public String getSomeIdentifier() { 21 | return someIdentifier; 22 | } 23 | 24 | public void setSomeIdentifier(String id) { 25 | this.someIdentifier = id; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/it/mjaxb-80/src/main/java/org/domain/SomeOtherImportItemDTO.java: -------------------------------------------------------------------------------- 1 | package org.domain; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlAccessorType(XmlAccessType.FIELD) 10 | @XmlType(namespace = "http://schema.domain.org/integration/1.0", 11 | name = "someOtherImportItem", 12 | propOrder = {"someWeirdIdentifier"}) 13 | @XmlRootElement(namespace = "http://schema.domain.org/integration/1.0", 14 | name = "someOtherImportItem") 15 | public class SomeOtherImportItemDTO extends ImportItemDTO { 16 | 17 | @XmlElement(name = "someWeirdIdentifier", required = true) 18 | private String someWeirdIdentifier; 19 | 20 | public String getSomeIdentifier() { 21 | return someWeirdIdentifier; 22 | } 23 | 24 | public void setSomeIdentifier(String id) { 25 | this.someWeirdIdentifier = id; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/it/mjaxb-80/src/main/java/org/domain/jaxb.index: -------------------------------------------------------------------------------- 1 | ImportItemsDTO 2 | ImportItemDTO 3 | SomeImportItemDTO 4 | SomeOtherImportItemDTO -------------------------------------------------------------------------------- /src/it/mjaxb-80/src/main/java/org/domain/package-info.java: -------------------------------------------------------------------------------- 1 | @XmlSchema(xmlns = { 2 | @XmlNs(prefix = "smoothIntegration", namespaceURI = "http://schema.domain.org/integration/1.0")}) 3 | @XmlAccessorType(XmlAccessType.FIELD) 4 | package org.domain; 5 | 6 | import jakarta.xml.bind.annotation.XmlAccessType; 7 | import jakarta.xml.bind.annotation.XmlAccessorType; 8 | import jakarta.xml.bind.annotation.XmlNs; 9 | import jakarta.xml.bind.annotation.XmlSchema; 10 | 11 | -------------------------------------------------------------------------------- /src/it/mjaxb-81/src/main/java/org/acme/FooBar.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlType; 7 | 8 | @XmlType( name = "BarType", namespace="##default" ) 9 | @XmlAccessorType( XmlAccessType.FIELD ) 10 | public class FooBar 11 | { 12 | @XmlElement( required = false ) 13 | private FooBaz bazElement; 14 | } 15 | -------------------------------------------------------------------------------- /src/it/mjaxb-81/src/main/java/org/acme/FooBaz.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | @XmlType( name = "BazType", namespace = "##default", propOrder = { "requiredElement", "requiredAttribute" } ) 10 | @XmlAccessorType( XmlAccessType.FIELD ) 11 | public class FooBaz 12 | { 13 | @XmlElement( required = true, defaultValue = "requiredElementValue" ) 14 | private String requiredElement; 15 | 16 | @XmlAttribute( required = true ) 17 | private String requiredAttribute; 18 | } 19 | -------------------------------------------------------------------------------- /src/it/mjaxb-81/src/main/java/org/acme/package-info.java: -------------------------------------------------------------------------------- 1 | @jakarta.xml.bind.annotation.XmlSchema( elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED, namespace="http://www.someuri" ) 2 | package org.acme; 3 | -------------------------------------------------------------------------------- /src/it/mjaxb-81/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | import groovy.xml.XmlSlurper 20 | 21 | File schema = new File( basedir,'target/generated-resources/schemagen/some.xsd' ) 22 | assert schema.exists() 23 | 24 | // Validate content as reported in issue MJAXB-81 25 | def xml = new XmlSlurper(true, true).parse(schema) 26 | def baz = xml.complexType.findAll{ it.@name.text().equals('BarType') } 27 | assert 'som:BazType' == baz[0].sequence[0].element[0].@type.text() 28 | -------------------------------------------------------------------------------- /src/it/schemagen-custom-converter/converters/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 23 | 4.0.0 24 | 25 | org.codehaus.mojo.jaxb2.its 26 | schemagen-custom-converter-converters 27 | 1.0-SNAPSHOT 28 | 29 | Purpose: Validate that a custom StringConverter can be used for filtering. 30 | 31 | 32 | UTF-8 33 | 34 | 35 | 36 | 37 | org.codehaus.mojo 38 | jaxb2-maven-plugin 39 | @project.version@ 40 | 41 | 42 | 43 | jakarta.xml.bind 44 | jakarta.xml.bind-api 45 | 3.0.0 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-compiler-plugin 55 | 2.5.1 56 | 57 | 1.8 58 | 1.8 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/it/schemagen-custom-converter/converters/src/main/java/se/west/converter/FileNameConverter.java: -------------------------------------------------------------------------------- 1 | package se.west.converter; 2 | 3 | import org.codehaus.mojo.jaxb2.shared.filters.pattern.StringConverter; 4 | 5 | import java.io.File; 6 | 7 | public class FileNameConverter implements StringConverter { 8 | 9 | @Override 10 | public String convert(final File toConvert) { 11 | return toConvert.getName(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/it/schemagen-custom-converter/invoker.properties: -------------------------------------------------------------------------------- 1 | # A comma or space separated list of goals/phases to execute, may 2 | # specify an empty list to execute the default goal of the IT project 3 | invoker.goals = clean install -------------------------------------------------------------------------------- /src/it/schemagen-custom-converter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 23 | 4.0.0 24 | 25 | org.codehaus.mojo.jaxb2.its 26 | schemagen-custom-converter 27 | 1.0-SNAPSHOT 28 | pom 29 | 30 | Purpose: Validate that a custom StringConverter can be used for filtering. 31 | 32 | 33 | UTF-8 34 | 35 | 36 | 37 | converters 38 | some_project 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/it/schemagen-custom-converter/some_project/src/main/java/se/west/gnat/Bar.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Bar { 8 | 9 | // Internal state 10 | private String gnus; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-custom-converter/some_project/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-encoding-utf8/src/main/java/se/west/shauqra/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.shauqra; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlType; 7 | 8 | @XmlType(namespace = "test") 9 | @XmlAccessorType(XmlAccessType.FIELD) 10 | public class Foo { 11 | @XmlElement(name = "utf8-name_äöüÄÖÜáéúàèù") 12 | private String name; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/it/schemagen-encoding-utf8/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import groovy.xml.XmlSlurper 21 | 22 | // Assemble 23 | final File outputDir = new File(basedir, 'target/generated-resources/schemagen'); 24 | final File vanillaSchema = new File(basedir, 'target/schemagen-work/compile_scope/schema1.xsd'); 25 | final File processedSchema = new File(outputDir, 'transform-test.xsd'); 26 | 27 | assert vanillaSchema.exists(), "Expected file [" + vanillaSchema.getAbsolutePath() + "] not found." 28 | assert processedSchema.exists(), "Expected file [" + processedSchema.getAbsolutePath() + "] not found." 29 | 30 | // Act 31 | def schemaElement = new XmlSlurper().parse(processedSchema) 32 | 33 | // Assert 34 | println "\nValidating schema content" 35 | println "===================================" 36 | 37 | assert schemaElement.complexType.sequence.element.@name == "utf8-name_äöüÄÖÜáéúàèù" 38 | println "1. Got correct name (utf8-name_äöüÄÖÜáéúàèù) for foo element child." 39 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-enums/src/main/java/se/west/gnat/AmericanCoin.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlEnum; 6 | import jakarta.xml.bind.annotation.XmlEnumValue; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * Simple enumeration example defining standard US coins. 11 | * 12 | * @author Lennart Jörelid, jGuru Europe AB 13 | */ 14 | @XmlType(namespace = "http://gnat.west.se/foods") 15 | @XmlEnum(Integer.class) 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public enum AmericanCoin { 18 | 19 | /** 20 | * The penny is worth of 1 cent. 21 | */ 22 | @XmlEnumValue("1") PENNY(1), 23 | 24 | /** 25 | * The nickel is worth of 5 cents. 26 | */ 27 | @XmlEnumValue("5") NICKEL(5), 28 | 29 | /** 30 | * The dime is worth of 10 cents. 31 | */ 32 | @XmlEnumValue("10") DIME(10), 33 | 34 | /** 35 | * The quarter is worth of 25 cents. 36 | */ 37 | @XmlEnumValue("25") QUARTER(25); 38 | 39 | // Internal state 40 | private int value; 41 | 42 | AmericanCoin(final int value) { 43 | this.value = value; 44 | } 45 | 46 | /** 47 | * The value - in cents - of this coin. 48 | * 49 | * @return the value - in cents - of this coin. 50 | */ 51 | public int getValue() { 52 | return value; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-enums/src/main/java/se/west/gnat/FoodPreference.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlEnum; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * Simple enumeration example defining some Food preferences. 11 | * 12 | * @author Lennart Jörelid, jGuru Europe AB 13 | */ 14 | @XmlType(namespace = "http://gnat.west.se/foods") 15 | @XmlEnum(String.class) 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public enum FoodPreference { 18 | 19 | /** 20 | * No special food preferences; eats everything. 21 | */ 22 | NONE(true, true), 23 | 24 | /** 25 | * Vegetarian who will not eat meats, but drinks milk. 26 | */ 27 | LACTO_VEGETARIAN(false, true), 28 | 29 | /** 30 | * Vegan who will neither eat meats nor drink milk. 31 | */ 32 | VEGAN(false, false); 33 | 34 | /** 35 | * Boolean value indicating if this {@link FoodPreference} eats meats. 36 | */ 37 | @XmlAttribute 38 | private boolean meatEater; 39 | 40 | /** 41 | * Boolean value indicating if this {@link FoodPreference} drinks milk. 42 | */ 43 | @XmlAttribute 44 | boolean milkDrinker; 45 | 46 | private FoodPreference(final boolean meatEater, final boolean milkDrinker) { 47 | this.meatEater = meatEater; 48 | this.milkDrinker = milkDrinker; 49 | } 50 | 51 | public boolean isMeatEater() { 52 | return meatEater; 53 | } 54 | 55 | public boolean isMilkDrinker() { 56 | return milkDrinker; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-enums/src/main/java/se/west/gnat/FoodPreferences.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Trivial transport object type for enumerations. 15 | * 16 | * @author Lennart Jörelid, jGuru Europe AB 17 | */ 18 | @XmlRootElement(namespace = "http://gnat.west.se/foods") 19 | @XmlType(namespace = "http://gnat.west.se/foods", propOrder = {"preferences", "coins"}) 20 | @XmlAccessorType(XmlAccessType.FIELD) 21 | public class FoodPreferences implements Serializable { 22 | 23 | /** 24 | * A List of {@link FoodPreference} instances. 25 | */ 26 | @XmlElementWrapper 27 | @XmlElement(name = "preference") 28 | private List preferences; 29 | 30 | /** 31 | * A List of {@link FoodPreference} instances. 32 | */ 33 | @XmlElementWrapper 34 | @XmlElement(name = "coin") 35 | private List coins; 36 | 37 | public FoodPreferences() { 38 | preferences = new ArrayList(); 39 | coins = new ArrayList(); 40 | } 41 | 42 | public List getPreferences() { 43 | return preferences; 44 | } 45 | 46 | public List getCoins() { 47 | return coins; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-package-info/src/main/java/org/testing/xml/MyType.java: -------------------------------------------------------------------------------- 1 | package org.testing.xml; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * This is a class-level comment. 10 | */ 11 | @XmlRootElement 12 | @XmlAccessorType(XmlAccessType.FIELD) 13 | public class MyType { 14 | 15 | /** 16 | * This is a field-level comment. 17 | */ 18 | @XmlElement(required = true) 19 | private String name; 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | } -------------------------------------------------------------------------------- /src/it/schemagen-handles-package-info/src/main/java/org/testing/xml/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a package-level comment. 3 | */ 4 | @XmlSchema(namespace = "example", elementFormDefault = XmlNsForm.QUALIFIED) 5 | package org.testing.xml; 6 | 7 | import jakarta.xml.bind.annotation.XmlSchema; 8 | import jakarta.xml.bind.annotation.XmlNsForm; 9 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-spaces in paths/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/schemagen-handles-spaces in paths/src/main/java/se/west/SomeType.java: -------------------------------------------------------------------------------- 1 | package se.west; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlRootElement; 6 | import jakarta.xml.bind.annotation.XmlType; 7 | 8 | /** 9 | * @author Lennart Jörelid, jGuru Europe AB 10 | */ 11 | @XmlRootElement(name = "someType", namespace = "http://mojohaus.org/whitespacetest") 12 | @XmlType(name = "someType", namespace = "http://mojohaus.org/whitespacetest") 13 | @XmlAccessorType(XmlAccessType.FIELD) 14 | public class SomeType { 15 | 16 | private String name; 17 | 18 | public SomeType() { 19 | } 20 | 21 | public SomeType(final String name) { 22 | this.name = name; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-xmlwrappers/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/wrappers/ExampleXmlWrapperUsingFieldAccess.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | import java.util.TreeSet; 14 | 15 | /** 16 | * A really trivial transport object type for collections, demonstrating that 17 | * the jaxb2-maven-plugin's schemagen goal correctly can extract XSD documentation 18 | * annotations when using @XmlElementWrapper annotations placed on Fields. 19 | * 20 | * This requires use of the @XmlAccessorType(XmlAccessType.FIELD) on the class in question, 21 | * or - alternatively - on a package-info.java file containing the equivalent annotation. 22 | */ 23 | @XmlRootElement(namespace = "http://jaxb.mojohaus.org/wrappers") 24 | @XmlType(namespace = "http://jaxb.mojohaus.org/wrappers", propOrder = {"strings", "integerSet"}) 25 | @XmlAccessorType(XmlAccessType.FIELD) 26 | public class ExampleXmlWrapperUsingFieldAccess implements Serializable { 27 | 28 | /** 29 | * List containing some strings. 30 | */ 31 | @XmlElementWrapper(name = "foobar") 32 | @XmlElement(name = "aString") 33 | private List strings; 34 | 35 | /** 36 | * SortedSet containing Integers. 37 | */ 38 | @XmlElementWrapper 39 | @XmlElement(name = "anInteger") 40 | private SortedSet integerSet; 41 | 42 | 43 | public ExampleXmlWrapperUsingFieldAccess() { 44 | 45 | this.strings = new ArrayList(); 46 | this.integerSet = new TreeSet(); 47 | } 48 | 49 | public List getStrings() { 50 | return strings; 51 | } 52 | 53 | public SortedSet getIntegerSet() { 54 | return integerSet; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/it/schemagen-handles-xmlwrappers/src/main/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/wrappers/ExampleXmlWrapperUsingMethodAccess.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | import java.util.TreeSet; 14 | 15 | /** 16 | * Another trivial transport object type for collections, demonstrating that 17 | * the jaxb2-maven-plugin's schemagen goal correctly can extract XSD documentation 18 | * annotations when using @XmlElementWrapper annotations placed on Method accessors 19 | * (which is the default for SchemaGen). 20 | */ 21 | @XmlRootElement(namespace = "http://jaxb.mojohaus.org/wrappers") 22 | @XmlType(namespace = "http://jaxb.mojohaus.org/wrappers", propOrder = {"methodStrings", "methodIntegerSet"}) 23 | @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 24 | public class ExampleXmlWrapperUsingMethodAccess implements Serializable { 25 | 26 | private List methodStrings; 27 | 28 | private SortedSet methodIntegerSet; 29 | 30 | 31 | public ExampleXmlWrapperUsingMethodAccess() { 32 | 33 | this.methodStrings = new ArrayList(); 34 | this.methodIntegerSet = new TreeSet(); 35 | } 36 | 37 | /** 38 | * JavaBean getter method containing some method strings. 39 | * 40 | * @return some method strings. 41 | */ 42 | @XmlElementWrapper(name = "foobar") 43 | @XmlElement(name = "aString") 44 | public List getMethodStrings() { 45 | return methodStrings; 46 | } 47 | 48 | /** 49 | * JavaBean getter method returning Integers. 50 | * 51 | * @return a Set of integers. 52 | * @see #getMethodStrings() 53 | */ 54 | @XmlElementWrapper 55 | @XmlElement(name = "anInteger") 56 | public SortedSet getMethodIntegerSet() { 57 | return methodIntegerSet; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/it/schemagen-include-sources/src/main/java/se/west/ANonAnnotatedClass.java: -------------------------------------------------------------------------------- 1 | package se.west; 2 | 3 | public class ANonAnnotatedClass { 4 | 5 | // Internal state 6 | private String shouldNotBeIncluded; 7 | } -------------------------------------------------------------------------------- /src/it/schemagen-include-sources/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-include-test-sources/src/test/java/se/west/ANonAnnotatedClass.java: -------------------------------------------------------------------------------- 1 | package se.west; 2 | 3 | public class ANonAnnotatedClass { 4 | 5 | // Internal state 6 | private String shouldNotBeIncluded; 7 | } -------------------------------------------------------------------------------- /src/it/schemagen-include-test-sources/src/test/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-jaxb-errors/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/schemagen-jaxb-errors/src/main/java/se/west/gnat/IncorrectJaxbAnnotationClass.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | 7 | @XmlAccessorType(XmlAccessType.FIELD) 8 | public class IncorrectJaxbAnnotationClass { 9 | 10 | // Internal state 11 | private String bar; 12 | 13 | @XmlElement(required = true) 14 | private String getBar() { 15 | return bar; 16 | } 17 | } -------------------------------------------------------------------------------- /src/it/schemagen-jaxb-errors/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | // Assemble 21 | def validateExistingFile(final File aFile, final int index) { 22 | final String path = aFile.getCanonicalPath(); 23 | assert aFile.exists() && aFile.isFile(), "Missing required file [" + path + "]"; 24 | println "" + index + ". Expected file exists correctly. [" + path + "]"; 25 | } 26 | 27 | def validateNonexistentFile(final File aFile, final int index) { 28 | final String path = aFile.getCanonicalPath(); 29 | assert !aFile.exists(), "File should not exist: [" + path + "]"; 30 | println "" + index + ". File correctly non-existent. [" + path + "]"; 31 | } 32 | 33 | def validateNonexistentDirectory(final File aDirectory, final int index) { 34 | final String path = aDirectory.getCanonicalPath(); 35 | assert !aDirectory.exists(), "Directory should not exist: [" + path + "]"; 36 | println "" + index + ". Directory correctly non-existent. [" + path + "]"; 37 | } 38 | 39 | final File workDir = new File(basedir, 'target/schemagen-work/compile_scope') 40 | 41 | // Validate that no schemas was produced by this invocation. 42 | def normalResult = new File(workDir, 'schema1.xsd'); 43 | validateNonexistentFile(normalResult, 1); 44 | 45 | // Validate that the expected JAXB error message is stashed in the log 46 | def expectedErrorMessage = 'Class has two properties of the same name "bar"'; 47 | List lines = new File(basedir, 'build.log').readLines(); 48 | 49 | boolean foundExpectedErrorMessage = false; 50 | 51 | for(line in lines) { 52 | if(line.trim().startsWith(expectedErrorMessage)) { 53 | foundExpectedErrorMessage = true; 54 | } 55 | } 56 | 57 | assert foundExpectedErrorMessage, "Expected JAXB error message not found." -------------------------------------------------------------------------------- /src/it/schemagen-main/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-multimodule-project/first/src/main/java/se/west/first/NonAnnotatedFirst.java: -------------------------------------------------------------------------------- 1 | package se.west; 2 | 3 | public class NonAnnotatedFirst { 4 | 5 | // Internal state 6 | private String shouldNotBeIncluded; 7 | } -------------------------------------------------------------------------------- /src/it/schemagen-multimodule-project/first/src/main/java/se/west/first/gnat/FirstFoo.java: -------------------------------------------------------------------------------- 1 | package se.west.first.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class FirstFoo { 8 | 9 | // Internal state 10 | private String firstBar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-multimodule-project/second/src/main/java/se/west/second/gnat/SecondFoo.java: -------------------------------------------------------------------------------- 1 | package se.west.second.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class SecondFoo { 8 | 9 | // Internal state 10 | private String secondBar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-multimodule-project/third/src/main/java/se/west/ShouldNotBeIncluded.java: -------------------------------------------------------------------------------- 1 | package se.west; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class ShouldNotBeIncluded { 8 | 9 | // Internal state 10 | private String someInternalState; 11 | } -------------------------------------------------------------------------------- /src/it/schemagen-multimodule-project/third/src/main/java/se/west/third/gnat/ExplicitlyExcluded.java: -------------------------------------------------------------------------------- 1 | package se.west.third.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class ExplicitlyExcluded { 8 | 9 | // Internal state 10 | private String thirdExcludedBar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-multimodule-project/third/src/main/java/se/west/third/gnat/ThirdFoo.java: -------------------------------------------------------------------------------- 1 | package se.west.third.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class ThirdFoo { 8 | 9 | // Internal state 10 | private String thirdBar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-platform-encoding/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 23 | 4.0.0 24 | 25 | org.codehaus.mojo.jaxb2.its 26 | schemagen-platform-encoding 27 | 1.0-SNAPSHOT 28 | 29 | Test of basic usage when platform encoding is used (no encoding specified) 30 | 31 | 32 | 33 | jakarta.xml.bind 34 | jakarta.xml.bind-api 35 | 3.0.0 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-compiler-plugin 45 | 2.5.1 46 | 47 | 1.8 48 | 1.8 49 | 50 | 51 | 52 | 53 | 54 | 55 | org.codehaus.mojo 56 | jaxb2-maven-plugin 57 | @project.version@ 58 | 59 | 60 | schemagen 61 | 62 | schemagen 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/it/schemagen-platform-encoding/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-rename-type/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlType; 7 | 8 | @XmlType(name="RenamedFoo") 9 | @XmlAccessorType(XmlAccessType.FIELD) 10 | public class Foo { 11 | 12 | /** 13 | * This is a Bar. 14 | */ 15 | @XmlAttribute(name = "renamedBar") 16 | private String bar; 17 | } 18 | -------------------------------------------------------------------------------- /src/it/schemagen-test/src/test/java/se/west/blah/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.blah; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-test/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | // java.lang.AssertionError: Expected file [/Users/lenjor/Development/Projects/Mojohaus/jaxb2-maven-plugin/target/ 21 | // it/schemagen-test/target/generated-test-resources/schemagen/META-INF/sun-jaxb.episode] not found.. 22 | // Expression: testEpisode.exists() 23 | import groovy.xml.XmlSlurper 24 | 25 | def testSchema = new File(basedir, 'target/generated-test-resources/schemagen/schema1.xsd'); 26 | def testEpisode = new File(basedir, 'target/generated-test-resources/schemagen/META-INF' + 27 | '/JAXB/episode_schemagen-test.xjb'); 28 | 29 | assert testSchema.exists(), "Expected file [" + testSchema.getAbsolutePath() + "] not found." 30 | assert testEpisode.exists(), "Expected file [" + testEpisode.getAbsolutePath() + "] not found." 31 | 32 | // Validate content 33 | def xml = new XmlSlurper().parse(testSchema) 34 | assert 1 == xml.complexType.size() 35 | assert 'foo' == xml.complexType[0].@name.text() 36 | 37 | File mainSchemagen = new File(basedir, 'target/generated-resources/schemagen/') 38 | assert !mainSchemagen.exists(), "Found unexpected generated Resources [" + mainSchemagen.getAbsolutePath() + "]"; 39 | -------------------------------------------------------------------------------- /src/it/schemagen-with-explicit-locale/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-without-episode/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-work-directory/src/main/java/se/west/gnat/Foo.java: -------------------------------------------------------------------------------- 1 | package se.west.gnat; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | 6 | @XmlAccessorType(XmlAccessType.FIELD) 7 | public class Foo { 8 | 9 | // Internal state 10 | private String bar; 11 | } 12 | -------------------------------------------------------------------------------- /src/it/schemagen-work-directory/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | import groovy.xml.XmlSlurper 20 | 21 | final File generatedSchema = new File(basedir, 'target/generated-resources/schemagen/schema1.xsd') 22 | final File generatedEpisode = new File(basedir, 'target/classes/META-INF/JAXB/episode_schemagen.xjb') 23 | 24 | assert generatedSchema.exists(), "Expected file [" + generatedSchema.getAbsolutePath() + "] not found." 25 | assert generatedEpisode.exists(), "Expected file [" + generatedEpisode.getAbsolutePath() + "] not found." 26 | 27 | // Validate content 28 | def xml = new XmlSlurper().parse(generatedSchema) 29 | assert 1 == xml.complexType.size() 30 | assert 'foo' == xml.complexType[0].@name.text() 31 | 32 | final File testSchemagen = new File(basedir, 'target/generated-test-resources/schemagen/') 33 | assert !testSchemagen.exists(), "Found unexpected generated TestResources [" + testSchemagen.getAbsolutePath() + "]"; 34 | -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 | 16 | 17 | it-repo 18 | 19 | true 20 | 21 | 22 | 23 | local.central 24 | @localRepositoryUrl@ 25 | 26 | true 27 | 28 | 29 | true 30 | 31 | 32 | 33 | apache.snapshots 34 | Apache Snapshot Repository 35 | http://people.apache.org/repo/m2-snapshot-repository 36 | 37 | 38 | false 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 47 | local.central 48 | @localRepositoryUrl@ 49 | 50 | true 51 | 52 | 53 | true 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/xjc-exclude-file-patterns/src/main/foo/gnat.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-exclude-file-patterns/src/main/someOtherXsds/another_schema.foo: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/it/xjc-exclude-file-patterns/src/main/someOtherXsds/fooSchema.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/it/xjc-exclude-file-patterns/src/main/someOtherXsds/some_schema.bar: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/it/xjc-exclude-file-patterns/src/main/someOtherXsds/thisShouldBeIgnored.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-handles-spaces-in-filenames/src/main/xjb/spaced filename.xjb: -------------------------------------------------------------------------------- 1 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/xjc-handles-spaces-in-filenames/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-include-xsds-in-artifact/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-include-xsds-in-artifact/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | File outputSchema = new File(basedir, 'target/classes/xsd/address.xsd') 21 | assert outputSchema.exists() 22 | -------------------------------------------------------------------------------- /src/it/xjc-main/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-main/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | File addressTypeSource = new File( basedir,'target/generated-sources/jaxb/com/example/myschema/AddressType.java' ) 21 | assert addressTypeSource.exists() 22 | 23 | File testSources = new File( basedir,'target/generated-test-sources/jaxb/' ) 24 | assert !testSources.exists() 25 | 26 | File addressTypeCompiled = new File( basedir,'target/classes/com/example/myschema/AddressType.class' ) 27 | assert addressTypeCompiled.exists() 28 | 29 | File addressTypeCopiedSource = new File( basedir,'target/classes/com/example/myschema/AddressType.java' ) 30 | assert !addressTypeCopiedSource.exists() 31 | -------------------------------------------------------------------------------- /src/it/xjc-mark-generated/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-mark-generated/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | File addressType = new File(basedir, 'target/generated-sources/jaxb/com/example/myschema/AddressType.java') 21 | assert addressType.exists() 22 | 23 | File testSources = new File(basedir, 'target/generated-test-sources/jaxb/') 24 | assert !testSources.exists() 25 | 26 | File addressTypeCompiled = new File(basedir, 'target/classes/com/example/myschema/AddressType.class') 27 | assert addressTypeCompiled.exists() 28 | 29 | // Validate that the @Generated annotations are injected into the source file. 30 | int hitCount = 0; 31 | List lines = addressType.readLines(); 32 | for (line in lines) { 33 | 34 | String trimmedLine = line.trim() 35 | if (trimmedLine.isEmpty()) { 36 | continue 37 | }; 38 | 39 | if (trimmedLine.startsWith("@Generated(value = \"com.sun.tools.xjc.Driver\"")) { 40 | hitCount++; 41 | } 42 | } 43 | 44 | assert 19 == hitCount, "Found [" + hitCount + "] @Generated annotations. (Expected 19)."; 45 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-executions/src/main/xsd/a.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-executions/src/main/xsd/b.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-executions/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | File aType = new File( basedir,'target/generated-sources/jaxb/com/example/schema/a/AType.java' ) 21 | assert aType.exists() 22 | 23 | File bType = new File( basedir,'target/generated-sources/jaxb/com/example/schema/b/BType.java' ) 24 | assert bType.exists() 25 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-xsd-specified/src/main/xsd/a.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-xsd-specified/src/main/xsd/b.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-xsd-specified/src/main/xsd/c.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-xsd-specified/src/main/xsd/d.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/it/xjc-multiple-xsd-specified/verify.bsh: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.util.jar.*; 4 | 5 | try 6 | { 7 | File jaxbDir = new File( basedir, "target/generated-sources/jaxb" ); 8 | if ( !jaxbDir.exists() || !jaxbDir.isDirectory() ) 9 | { 10 | System.err.println( "Could not find directory for JAXB generated sources: " + jaxbDir ); 11 | return false; 12 | } 13 | 14 | File file; 15 | file = new File( jaxbDir, "com/example/myschema/AType.java" ); 16 | if ( !file.exists() || file.isDirectory() ) 17 | { 18 | System.err.println( "Could not find file: " + file ); 19 | return false; 20 | } 21 | file = new File( jaxbDir, "com/example/myschema/BType.java" ); 22 | if ( !file.exists() || file.isDirectory() ) 23 | { 24 | System.err.println( "Could not find file: " + file ); 25 | return false; 26 | } 27 | file = new File( jaxbDir, "com/example/myschema/CType.java" ); 28 | if ( !file.exists() || file.isDirectory() ) 29 | { 30 | System.err.println( "Could not find file: " + file ); 31 | return false; 32 | } 33 | file = new File( jaxbDir, "com/example/myschema/DType.java" ); 34 | if ( file.exists() ) 35 | { 36 | System.err.println( "File '" + file + "' found, which shouldn't exist" ); 37 | return false; 38 | } 39 | } 40 | catch( Throwable t ) 41 | { 42 | t.printStackTrace(); 43 | return false; 44 | } 45 | 46 | return true; 47 | -------------------------------------------------------------------------------- /src/it/xjc-platform-encoding/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-plugins/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/xjc-plugins/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 23 | 4.0.0 24 | 25 | org.codehaus.mojo.jaxb2.its 26 | xjc-test 27 | 1.0-SNAPSHOT 28 | 29 | Test of basic usage of the testXjc mojo. 30 | 31 | 32 | UTF-8 33 | 34 | 35 | 36 | 37 | jakarta.xml.bind 38 | jakarta.xml.bind-api 39 | 3.0.0 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-compiler-plugin 49 | 2.5.1 50 | 51 | 1.8 52 | 1.8 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.codehaus.mojo 60 | jaxb2-maven-plugin 61 | @project.version@ 62 | 63 | 64 | xjc-test 65 | 66 | testXjc 67 | 68 | 69 | 70 | 71 | com.example.myschema 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/it/xjc-test/src/test/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-test/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | File addressType = new File( basedir,'target/generated-test-sources/jaxb/com/example/myschema/AddressType.java' ) 21 | assert addressType.exists() 22 | 23 | File mainSources = new File( basedir,'target/generated-sources/jaxb/' ) 24 | assert !mainSources.exists() 25 | 26 | File addressTypeCompiled = new File( basedir,'target/test-classes/com/example/myschema/AddressType.class' ) 27 | assert addressTypeCompiled.exists() 28 | -------------------------------------------------------------------------------- /src/it/xjc-with-explicit-locale/src/main/xsd/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/it/xjc-with-explicit-locale/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | File addressType = new File(basedir, 'target/generated-sources/jaxb/com/example/myschema/AddressType.java') 21 | assert addressType.exists() 22 | 23 | File testSources = new File(basedir, 'target/generated-test-sources/jaxb/') 24 | assert !testSources.exists() 25 | 26 | File addressTypeCompiled = new File(basedir, 'target/classes/com/example/myschema/AddressType.class') 27 | assert addressTypeCompiled.exists() 28 | 29 | // Validate that XJC ran with French locale. 30 | int hitCount = 0; 31 | List lines = addressType.readLines(); 32 | for (line in lines) { 33 | 34 | String trimmedLine = line.trim() 35 | if (trimmedLine.isEmpty()) { 36 | continue 37 | }; 38 | 39 | if (trimmedLine.endsWith("Classe Java pour AddressType complex type.")) { 40 | hitCount++; 41 | } 42 | } 43 | 44 | assert 1 == hitCount, "Found [" + hitCount + "] . (Expected 1)."; 45 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/NoSchemasException.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * @author olamy 24 | * @version $Id$ 25 | */ 26 | public class NoSchemasException extends Exception { 27 | // Do Nothing 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/javageneration/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

The jaxb2-maven-plugin wraps and adapts the JAXB reference implementation 3 | * to be useful within the Maven build process.

4 | *

The javageneration package (including subpackages) contains Mojos for generating Java files from 5 | * XSDs or DTDs.

6 | * 7 | * @author Lennart Jörelid 8 | * @see The JAXB Reference Implementation 9 | */ 10 | package org.codehaus.mojo.jaxb2.javageneration; 11 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

The jaxb2-maven-plugin wraps and adapts the JAXB reference implementation 3 | * to be useful within the Maven build process.

4 | *

The plugin's code is divided into 3 main blocks, each placed within a separate package structure:

5 | * 6 | *
    7 | *
  1. javageneration. Contains code involved in creating java code from XSD or DTDs. 8 | * This package structure adapts the plugin to using the XJC ("Xml-to-Java-Compiler") from the 9 | * JAXB reference implementation.
  2. 10 | *
  3. schemageneration. Contains code involved in creating XSDs from annotated Java classes. 11 | * This package structure adapts the plugin to using the schemagen tool from the JDK. (Typically found in the 12 | * bin directory of the java installation).
  4. 13 | *
  5. shared. Contains shared utility classes used by both the java- and xsd-generation 14 | * structure classes.
  6. 15 | *
16 | * 17 | * @author Lennart Jörelid 18 | * @see The JAXB Reference Implementation 19 | */ 20 | package org.codehaus.mojo.jaxb2; 21 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/schemageneration/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

The jaxb2-maven-plugin wraps and adapts the JAXB reference implementation 3 | * to be useful within the Maven build process.

4 | *

The schemageneneration package (including subpackages) contains Mojos for generating XSD files from 5 | * annotated Java classes. It also contains subpackages for post-processing the results of the schemagen tool, 6 | * to create XSDs with better usability than the XSDs generated by default.

7 | * 8 | * @author Lennart Jörelid 9 | * @see The JAXB Reference Implementation 10 | */ 11 | package org.codehaus.mojo.jaxb2.schemageneration; 12 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/NodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.w3c.dom.Node; 23 | 24 | /** 25 | * Processor/visitor pattern specification for DOM Nodes. 26 | * 27 | * @author Lennart Jörelid 28 | * @since 1.4 29 | */ 30 | public interface NodeProcessor { 31 | 32 | /** 33 | * Defines if this visitor should process the provided node. 34 | * 35 | * @param aNode The DOM node to process. 36 | * @return true if the provided Node should be processed by this NodeProcessor. 37 | */ 38 | boolean accept(Node aNode); 39 | 40 | /** 41 | * Processes the provided DOM Node. 42 | * 43 | * @param aNode The DOM Node to process. 44 | */ 45 | void process(Node aNode); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/NoAuthorJavaDocRenderer.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | *

Default JavaDocRenderer implementation which provides a plain JavaDocData rendering, while skipping 24 | * output from the {@code author} tag, on the form:

25 | *
26 |  *     [JavaDoc comment]
27 |  *     (tag1): [tag1 value]
28 |  *     (tag2): [tag2 value]
29 |  * 
30 | * 31 | * @author Lennart Jörelid, jGuru Europe AB 32 | * @since 2.3 33 | */ 34 | public class NoAuthorJavaDocRenderer extends DefaultJavaDocRenderer { 35 | 36 | /** 37 | * The author key. 38 | */ 39 | private static final String AUTHOR_KEY = "author"; 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | @Override 45 | protected String renderJavaDocTag(final String name, final String value, final SortableLocation location) { 46 | 47 | // Don't render the author 48 | if (AUTHOR_KEY.equalsIgnoreCase(name)) { 49 | return ""; 50 | } 51 | 52 | // Delegate. 53 | return super.renderJavaDocTag(name, value, location); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/SortableLocation.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jakarta.xml.bind.annotation.XmlAttribute; 23 | import jakarta.xml.bind.annotation.XmlElement; 24 | import jakarta.xml.bind.annotation.XmlType; 25 | 26 | /** 27 | * Common specification for a JavaDoc location which can be compared and sorted. 28 | * JavaDoc locations must be comparable and also convert-able to unique strings. 29 | * 30 | * @author Lennart Jörelid, jGuru Europe AB 31 | * @since 2.0 32 | */ 33 | public interface SortableLocation extends Comparable { 34 | 35 | /** 36 | * Validates if the supplied path is equal to this SortableLocation. 37 | * 38 | * @param path The non-null path to compare to this SortableLocation. 39 | * @return {@code true} if this SortableLocation is equal to the supplied path. 40 | */ 41 | boolean isEqualToPath(final String path); 42 | 43 | /** 44 | * Retrieves the path of this SortableLocation. The path must uniquely correspond to each unique SortableLocation, 45 | * implying that SortableLocations could be sorted and compared for equality using the path property. 46 | * 47 | * @return the path of this SortableLocation. Never null. 48 | */ 49 | String getPath(); 50 | 51 | /** 52 | * Retrieves the value of the name attribute provided by a JAXB annotation, implying that 53 | * the XSD type should use another name than the default. 54 | * 55 | * @return the value of the name attribute provided by a JAXB annotation relevant to this {@link SortableLocation}. 56 | * @see XmlElement#name() 57 | * @see XmlAttribute#name() 58 | * @see XmlType#name() 59 | */ 60 | String getAnnotationRenamedTo(); 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/JavaVersion.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Helper to extract the runtime Java version from the System.properties. 24 | * 25 | * @author Lennart Jörelid 26 | * @since 2.4 27 | */ 28 | public final class JavaVersion { 29 | 30 | private static final String JAVA_VERSION_PROPERTY = "java.specification.version"; 31 | 32 | /** 33 | * Retrieves the major java runtime version as an integer. 34 | * 35 | * @return the major java runtime version as an integer. 36 | */ 37 | public static int getJavaMajorVersion() { 38 | 39 | final String[] versionElements = 40 | System.getProperty(JAVA_VERSION_PROPERTY).split("\\."); 41 | final int[] versionNumbers = new int[versionElements.length]; 42 | 43 | for (int i = 0; i < versionElements.length; i++) { 44 | try { 45 | versionNumbers[i] = Integer.parseInt(versionElements[i]); 46 | } catch (NumberFormatException e) { 47 | versionNumbers[i] = 0; 48 | } 49 | } 50 | 51 | /* 52 | Java versions 1 - 8 (i.e. jdk 1.1 through 1.8) yields the structure 1.8 53 | Java versions 9 - yields the structure 10 54 | 55 | JDK 10 56 | ====== 57 | [java.specification.version]: 10 58 | 59 | JDK 8 60 | ===== 61 | [java.specification.version]: 1.8 62 | 63 | JDK 7 64 | ===== 65 | [java.specification.version]: 1.7 66 | */ 67 | return versionNumbers[0] == 1 ? versionNumbers[1] : versionNumbers[0]; 68 | } 69 | 70 | /** 71 | * Checks if the runtime java version is JDK 8 or lower. 72 | * 73 | * @return true if the runtime java version is JDK 8 or lower. 74 | */ 75 | public static boolean isJdk8OrLower() { 76 | return getJavaMajorVersion() <= 8; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/environment/AbstractLogAwareFacet.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.environment; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.apache.maven.plugin.logging.Log; 23 | import org.codehaus.mojo.jaxb2.shared.Validate; 24 | 25 | /** 26 | * Abstract EnvironmentFacet which sports a non-null Maven Log for use by subclasses. 27 | * 28 | * @author Lennart Jörelid, jGuru Europe AB 29 | * @since 2.1 30 | */ 31 | public abstract class AbstractLogAwareFacet implements EnvironmentFacet { 32 | 33 | // Internal state 34 | protected Log log; 35 | 36 | /** 37 | * Creates an AbstractLogAwareFacet wrapping the supplied, non-null Log. 38 | * 39 | * @param log The active Maven Log. 40 | */ 41 | public AbstractLogAwareFacet(final Log log) { 42 | 43 | // Check sanity 44 | Validate.notNull(log, "log"); 45 | 46 | // Assign internal state 47 | this.log = log; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/environment/EnvironmentFacet.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.environment; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | *

Specification for an Environment controller, which can infer a temporary and reversible change 24 | * to the environment of an executing task. Any changes performed by this Environment 25 | * must be reversible, and should be restored to their original values in the {@code restore()} method.

26 | *

EnvironmentFacets are required since the JDK tools (XJC, SchemaGen, JXC) expect certain configuration 27 | * or setup to be present during their execution. For improved usability within the JAXB2-Maven-Plugin, we 28 | * would like to supply all configuration to the plugin, and delegate the setting of various system-, thread-, 29 | * logging- or environment properties to explicit EnvironmentFacet implementations.

30 | * 31 | * @author Lennart Jörelid, jGuru Europe AB 32 | * @since 2.1 33 | */ 34 | public interface EnvironmentFacet { 35 | 36 | /** 37 | * Sets up this Environment, inferring temporary changes to environment variables or conditions. 38 | * The changes must be reversible, and should be restored to their original values in the {@code restore()} method. 39 | */ 40 | void setup(); 41 | 42 | /** 43 | * Restores the original Environment, implying that the change performed in {@code setup()} 44 | * method are restored to the state before the setup method was called. 45 | */ 46 | void restore(); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/environment/classloading/ThreadContextClassLoaderHolder.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.environment.classloading; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | *

Specification for how to restore the original ThreadContext ClassLoader to a Thread. 24 | * When we support JDK 1.7, this should really be an extension of AutoCloseable instead, 25 | * to support the try-with-resources pattern. Typical use:

26 | *
27 |  *     
28 |  *         // Create and set the ThreadContext ClassLoader
29 |  *         ThreadContextClassLoaderHolder holder = null;
30 |  *
31 |  *         try {
32 |  *
33 |  *          holder = ThreadContextClassLoaderBuilder.createFor(getClass())
34 |  *              .addPath("some/path")
35 |  *              .addURL(someURL)
36 |  *              .addPaths(aPathList)
37 |  *              .buildAndSet();
38 |  *
39 |  *          // ... perform operations using the newly set ThreadContext ClassLoader...
40 |  *
41 |  *         } finally {
42 |  *          // Restore the original ClassLoader
43 |  *          holder.restoreClassLoaderAndReleaseThread();
44 |  *         }
45 |  *     
46 |  * 
47 | * 48 | * @author Lennart Jörelid, jGuru Europe AB 49 | * @since 2.0 50 | */ 51 | public interface ThreadContextClassLoaderHolder { 52 | 53 | /** 54 | * Restores the original ThreadContext ClassLoader, and nullifies 55 | * any references to the Thread which had its ThreadContext 56 | * ClassLoader altered. 57 | */ 58 | void restoreClassLoaderAndReleaseThread(); 59 | 60 | /** 61 | * Retrieves the ClassPath held by this ThreadContextClassLoaderHolder as a 62 | * {@code File.pathSeparatorChar}-separated string. This is directly usable as a String argument by 63 | * any external process. 64 | * 65 | * @return the ClassPath as an argument to external processes such as XJC. 66 | */ 67 | String getClassPathAsArgument(); 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/environment/sysprops/SystemPropertySaveEnvironmentFacet.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.environment.sysprops; 2 | 3 | import org.apache.maven.plugin.logging.Log; 4 | import org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet; 5 | 6 | /** 7 | * EnvironmentFacet which saves the value of a system property for the duration 8 | * of executing a tool. This may be required for tools (such as the XJC tool) which 9 | * may overwrite property values for its own purpose. 10 | * 11 | * Unlike {@link SystemPropertyChangeEnvironmentFacet}, this does not a set a new 12 | * property value itself, just saves the old value and later restores or clears it. 13 | * 14 | * This facet accepts the key of the property to save. 15 | * 16 | * @author Svein Elgstøen 17 | * @since 2.5 18 | */ 19 | public final class SystemPropertySaveEnvironmentFacet extends AbstractLogAwareFacet { 20 | private final String key; 21 | private final String originalValue; 22 | 23 | /** 24 | * Creates a SystemPropertySave which will remember the original value of the 25 | * supplied system property for the duration of this SystemPropertySave. 26 | * 27 | * @param key A non-null key. 28 | * @param log The active Maven Log. 29 | */ 30 | public SystemPropertySaveEnvironmentFacet(final String key, final Log log) { 31 | // Delegate 32 | super(log); 33 | 34 | // Assign internal state 35 | this.key = key; 36 | this.originalValue = System.getProperty(key); 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | @Override 43 | public void restore() { 44 | if (originalValue != null) { 45 | System.setProperty(key, originalValue); 46 | } else { 47 | System.clearProperty(key); 48 | } 49 | 50 | if (log.isDebugEnabled()) { 51 | log.debug("Restored " + toString()); 52 | } 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public void setup() { 60 | // Do nothing, value is saved in constructor 61 | 62 | if (log.isDebugEnabled()) { 63 | log.debug("Setup " + toString()); 64 | } 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return "SysProp key [" + key + "], saved value: [" + originalValue + "]"; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/filters/Filter.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.apache.maven.plugin.logging.Log; 23 | 24 | /** 25 | * Generic Filter specification, whose implementations define if candidate objects should be accepted or not. 26 | * 27 | * @author Lennart Jörelid, jGuru Europe AB 28 | * @since 2.0 29 | */ 30 | public interface Filter { 31 | 32 | /** 33 | * Initializes this Filter, and assigns the supplied Log for use by this Filter. 34 | * 35 | * @param log The non-null Log which should be used by this Filter to emit log messages. 36 | */ 37 | void initialize(Log log); 38 | 39 | /** 40 | * @return {@code true} if this Filter has been properly initialized (by a call to the {@code initialize} method). 41 | */ 42 | boolean isInitialized(); 43 | 44 | /** 45 | *

Method that is invoked to determine if a candidate instance should be accepted or not. 46 | * Implementing classes should be prepared to handle {@code null} candidate objects.

47 | * 48 | * @param candidate The candidate that should be tested for acceptance by this Filter. 49 | * @return {@code true} if the candidate is accepted by this Filter and {@code false} otherwise. 50 | * @throws java.lang.IllegalStateException if this Filter is not initialized by a call to the 51 | * initialize method before calling this matchAtLeastOnce method. 52 | */ 53 | boolean accept(T candidate) throws IllegalStateException; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/filters/pattern/FileFilterAdapter.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters.pattern; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.io.File; 23 | import java.io.FileFilter; 24 | 25 | import org.codehaus.mojo.jaxb2.shared.Validate; 26 | import org.codehaus.mojo.jaxb2.shared.filters.AbstractFilter; 27 | import org.codehaus.mojo.jaxb2.shared.filters.Filter; 28 | 29 | /** 30 | * Filter implementation adapting a FileFilter instance to the Filter interface. 31 | * Delegates the {@link #onCandidate(File)} call to the supplied {@link FileFilter} delegate. 32 | * 33 | * @author Lennart Jörelid, jGuru Europe AB 34 | * @since 2.3 35 | */ 36 | public class FileFilterAdapter extends AbstractFilter implements Filter, FileFilter { 37 | 38 | // Internal state 39 | private FileFilter delegate; 40 | 41 | /** 42 | * Compound constructor, creating a FileFilterAdapter using the supplied {@link FileFilter} to determine if 43 | * candidate Files should be accepted. 44 | * 45 | * @param delegate The delegate FileFilter. 46 | */ 47 | public FileFilterAdapter(final FileFilter delegate) { 48 | setDelegate(delegate); 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | @Override 55 | public boolean isInitialized() { 56 | return super.isInitialized() && delegate != null; 57 | } 58 | 59 | /** 60 | * Assigns the supplied FileFilter delegate. 61 | * 62 | * @param delegate A non-null FileFilter instance. 63 | */ 64 | public void setDelegate(final FileFilter delegate) { 65 | 66 | // Check sanity 67 | Validate.notNull(delegate, "delegate"); 68 | 69 | // Assign internal state 70 | this.delegate = delegate; 71 | } 72 | 73 | /** 74 | * {@inheritDoc} 75 | */ 76 | @Override 77 | protected boolean onCandidate(final File nonNullCandidate) { 78 | return delegate.accept(nonNullCandidate); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/filters/pattern/StringConverter.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters.pattern; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Specification for a converter rendering a T object as a String. 24 | * 25 | * @author Lennart Jörelid, jGuru Europe AB 26 | * @since 2.0 27 | */ 28 | public interface StringConverter { 29 | 30 | /** 31 | * Converts the supplied T object to a String. 32 | * 33 | * @param toConvert The T object to convert to a string. Not {@code null}. 34 | * @return The string form of the toConvert object. 35 | */ 36 | String convert(T toConvert); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/filters/pattern/ToStringConverter.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters.pattern; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Trivial converter using the {@code toString()} method to convert a T object to a String. 24 | * 25 | * @author Lennart Jörelid, jGuru Europe AB 26 | * @since 2.0 27 | */ 28 | public class ToStringConverter implements StringConverter { 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | @Override 34 | public String convert(final T toConvert) { 35 | return toConvert.toString(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/jaxb2/shared/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

The jaxb2-maven-plugin wraps and adapts the JAXB reference implementation 3 | * to be useful within the Maven build process.

4 | *

The shared package (including subpackages) contains utility classes used by both the java- and 5 | * xsd-generation Mojos.

6 | * 7 | * @author Lennart Jörelid 8 | * @see The JAXB Reference Implementation 9 | */ 10 | package org.codehaus.mojo.jaxb2.shared; 11 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xjc 8 | testXjc 9 | 10 | 11 | 12 | 13 | true 14 | true 15 | 16 | 17 | 18 | 19 | 20 | 21 | schemagen 22 | testSchemagen 23 | 24 | 25 | 26 | 27 | true 28 | false 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plexus/components.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | java.util.List 5 | List 6 | java.util.ArrayList 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/site/puml/detailedFilterHierarchy.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | interface Filter { 3 | void initialize(Log log); 4 | boolean isInitialized(); 5 | boolean accept(T candidate); 6 | } 7 | 8 | abstract class AbstractFilter implements Filter { 9 | Log log; 10 | boolean processNullValues; 11 | 12 | + boolean onNullCandidate(); 13 | + boolean accept(T candidate); 14 | # boolean onCandidate(final T nonNullCandidate) 15 | } 16 | note left of AbstractFilter: Provides standard lifecycle\nimplementation and null awareness 17 | 18 | abstract class AbstractPatternFilter extends AbstractFilter { 19 | boolean acceptCandidateOnPatternMatch; 20 | StringConverter converter; 21 | List patterns; 22 | 23 | # boolean onCandidate(final T nonNullCandidate) 24 | } 25 | note left of AbstractPatternFilter: Provides property setters for\nMaven plugin configuration 26 | 27 | class PatternFileFilter extends AbstractPatternFilter implements java.io.FileFilter { 28 | } 29 | note left of PatternFileFilter: Provides defaults for\nMaven plugin configuration 30 | 31 | class PatternURLFilter extends AbstractPatternFilter { 32 | } 33 | @enduml -------------------------------------------------------------------------------- /src/site/puml/postProcessing.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | |SchemaGenerator| 3 | start 4 | :Execute SchemaGenerator; 5 | |#AntiqueWhite|Post-Processing| 6 | :**XsdAnnotationProcessor** 7 | Add XSD annotations containing JavaDoc from source files; 8 | :**ChangeNamespacePrefixProcessor** 9 | Change schemagen-generated XML namespace prefixes ("ns1", "ns2", ...); 10 | :**ChangeFilenameProcessor** 11 | Change schemagen-generated file names ("schema1.xsd", "schema2.xsd", ...); 12 | stop 13 | @enduml -------------------------------------------------------------------------------- /src/site/puml/sourceAndExcludeFilter.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | |Find Source Files| 3 | start 4 | while (for each source) 5 | :Add all source files; 6 | endwhile 7 | 8 | note left 9 | **Sources** configuration may 10 | contain several directories and/or 11 | explicit files, such as: 12 | 13 | 14 | src/main/xsd 15 | src/main/foobar 16 | src/someExplicit.myFile 17 | 18 | end note 19 | 20 | |#AntiqueWhite|Filter Found Source Files| 21 | 22 | while (exclude filters remaining?) 23 | 24 | :Remove file if matched by an **exclude Filter**; 25 | 26 | note right 27 | **Exclude Filters** configuration may 28 | contain several directories and/or 29 | explicit files, such as: 30 | 31 | 32 | 33 | 34 | \.xsd 35 | \.foo 36 | 37 | 38 | 39 | end note 40 | endwhile 41 | 42 | :Include file into XJC / JXC compilation; 43 | 44 | stop 45 | @enduml -------------------------------------------------------------------------------- /src/site/resources/images/FilterHierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/jaxb2-maven-plugin/1c941f38fa12714abfbfe6b5b161cb490a846980/src/site/resources/images/FilterHierarchy.png -------------------------------------------------------------------------------- /src/site/resources/images/documentation_hub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/jaxb2-maven-plugin/1c941f38fa12714abfbfe6b5b161cb490a846980/src/site/resources/images/documentation_hub.png -------------------------------------------------------------------------------- /src/site/resources/images/documentation_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/jaxb2-maven-plugin/1c941f38fa12714abfbfe6b5b161cb490a846980/src/site/resources/images/documentation_structure.png -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/PropertyResources.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.io.File; 23 | import java.io.IOException; 24 | 25 | import org.apache.commons.io.FileUtils; 26 | 27 | import static java.nio.charset.StandardCharsets.UTF_8; 28 | 29 | public class PropertyResources { 30 | 31 | public static String readFully(String s) throws IOException { 32 | File file = 33 | new File(PropertyResources.class.getClassLoader().getResource(s).getFile()); 34 | return FileUtils.readFileToString(file, UTF_8); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/DebugNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.w3c.dom.Node; 7 | 8 | /** 9 | * @author Lennart Jörelid 10 | */ 11 | public class DebugNodeProcessor implements NodeProcessor { 12 | 13 | // Internal state 14 | private NodeProcessor delegate; 15 | private List acceptedNodes = new ArrayList(); 16 | 17 | /** 18 | * Creates a new DebugNodeProcessor, delegating all calls to the provided NodeProcessor. 19 | * 20 | * @param delegate The NodeProcessor to which all calls to this NodeProcessor 21 | * will be delegated. 22 | */ 23 | public DebugNodeProcessor(NodeProcessor delegate) { 24 | this.delegate = delegate; 25 | } 26 | 27 | /** 28 | * {@inheritDoc} 29 | */ 30 | public boolean accept(Node aNode) { 31 | final boolean accepted = delegate.accept(aNode); 32 | if (accepted) { 33 | acceptedNodes.add(aNode); 34 | } 35 | 36 | return accepted; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | public void process(Node aNode) { 43 | delegate.process(aNode); 44 | } 45 | 46 | /** 47 | * @return The ordered List of Nodes accepted by the delegate NodeProcessor. 48 | */ 49 | public List getAcceptedNodes() { 50 | return acceptedNodes; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/SemiDocumentedClass.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jakarta.xml.bind.annotation.XmlAccessType; 23 | import jakarta.xml.bind.annotation.XmlAccessorType; 24 | import jakarta.xml.bind.annotation.XmlElement; 25 | import jakarta.xml.bind.annotation.XmlRootElement; 26 | import jakarta.xml.bind.annotation.XmlType; 27 | 28 | /** 29 | * This is a JAXB-annotated class where not all properties are JavaDoc'ed. 30 | * 31 | * @author Lennart Jörelid, jGuru Europe AB 32 | */ 33 | @XmlRootElement 34 | @XmlType( 35 | namespace = SomewhatNamedPerson.NAMESPACE, 36 | propOrder = {"documented", "unDocumented"}) 37 | @XmlAccessorType(XmlAccessType.FIELD) 38 | public class SemiDocumentedClass { 39 | 40 | /** 41 | * The XML namespace of this SomewhatNamedPerson. 42 | */ 43 | public static final String NAMESPACE = "http://some/namespace"; 44 | 45 | /** 46 | * This is a documented property. 47 | */ 48 | @XmlElement(nillable = true, required = false) 49 | private String documented; 50 | 51 | @XmlElement(nillable = false, required = true) 52 | private String unDocumented; 53 | 54 | /** 55 | * JAXB-friendly constructor. 56 | */ 57 | public SemiDocumentedClass() {} 58 | 59 | public String getDocumented() { 60 | return documented; 61 | } 62 | 63 | public String getUnDocumented() { 64 | return unDocumented; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/XsdAnnotationProcessorSemiDocumentedTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.junit.jupiter.api.Test; 7 | import org.w3c.dom.Document; 8 | import org.w3c.dom.Node; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertTrue; 11 | 12 | /** 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | class XsdAnnotationProcessorSemiDocumentedTest extends AbstractSourceCodeAwareNodeProcessingTest { 16 | 17 | // Shared state 18 | private JavaDocRenderer renderer = new DefaultJavaDocRenderer(); 19 | 20 | @Test 21 | void validateProcessingNodesInVanillaXSD() throws Exception { 22 | 23 | // Assemble 24 | final String path = "testdata/schemageneration/javadoc/expectedSemiDocumentedClass.xml"; 25 | final String expected = readFully(path); 26 | final Document document = namespace2DocumentMap.get(SomewhatNamedPerson.NAMESPACE); 27 | final Node rootNode = document.getFirstChild(); 28 | 29 | final XsdAnnotationProcessor unitUnderTest = new XsdAnnotationProcessor(docs, renderer); 30 | 31 | // Act 32 | process(rootNode, true, unitUnderTest); 33 | 34 | // Assert 35 | final String processed = printDocument(document); 36 | // System.out.println("Got: " + processed); 37 | 38 | assertTrue(compareXmlIgnoringWhitespace(expected, processed).identical()); 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | @Override 45 | protected List> getJaxbAnnotatedClassesForJaxbContext() { 46 | return Arrays.>asList(SemiDocumentedClass.class); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/XsdAnnotationProcessorTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers.ExampleXmlWrapper; 7 | import org.junit.jupiter.api.Test; 8 | import org.w3c.dom.Document; 9 | import org.w3c.dom.Node; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | 13 | /** 14 | * @author Lennart Jörelid, jGuru Europe AB 15 | */ 16 | class XsdAnnotationProcessorTest extends AbstractSourceCodeAwareNodeProcessingTest { 17 | 18 | // Shared state 19 | private JavaDocRenderer renderer = new DefaultJavaDocRenderer(); 20 | 21 | @Test 22 | void validateProcessingNodesInVanillaXSD() throws Exception { 23 | 24 | // Assemble 25 | final String path = "testdata/schemageneration/javadoc/expectedTransformedSomewhatNamedPerson.xml"; 26 | final String expected = readFully(path); 27 | final Document document = namespace2DocumentMap.get(SomewhatNamedPerson.NAMESPACE); 28 | final Node rootNode = document.getFirstChild(); 29 | 30 | final XsdAnnotationProcessor unitUnderTest = new XsdAnnotationProcessor(docs, renderer); 31 | 32 | // Act 33 | process(rootNode, true, unitUnderTest); 34 | 35 | // Assert 36 | final String processed = printDocument(document); 37 | // System.out.println("Got: " + processed); 38 | 39 | assertTrue(compareXmlIgnoringWhitespace(expected, processed).identical()); 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | @Override 46 | protected List> getJaxbAnnotatedClassesForJaxbContext() { 47 | return Arrays.>asList(SomewhatNamedPerson.class, ExampleXmlWrapper.class); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/XsdEnumerationAnnotationProcessorTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums.AmericanCoin; 7 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums.ExampleEnumHolder; 8 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums.FoodPreference; 9 | import org.junit.jupiter.api.Test; 10 | import org.w3c.dom.Document; 11 | import org.w3c.dom.Node; 12 | 13 | import static org.junit.jupiter.api.Assertions.assertTrue; 14 | 15 | /** 16 | * @author Lennart Jörelid, jGuru Europe AB 17 | */ 18 | class XsdEnumerationAnnotationProcessorTest extends AbstractSourceCodeAwareNodeProcessingTest { 19 | 20 | // Shared state 21 | private JavaDocRenderer renderer = new DefaultJavaDocRenderer(); 22 | 23 | @Test 24 | void validateProcessingNodesInVanillaXSD() throws Exception { 25 | 26 | // Assemble 27 | final String path = "testdata/schemageneration/javadoc/enums/expectedTransformedExampleEnumHolder.xsd"; 28 | final String expected = readFully(path); 29 | 30 | final Document xsdGeneratedFromClassesInMethod = namespace2DocumentMap.get(SomewhatNamedPerson.NAMESPACE); 31 | final Node rootNode = xsdGeneratedFromClassesInMethod.getFirstChild(); 32 | 33 | final XsdEnumerationAnnotationProcessor unitUnderTest = new XsdEnumerationAnnotationProcessor(docs, renderer); 34 | 35 | // Act 36 | process(rootNode, true, unitUnderTest); 37 | 38 | // Assert 39 | final String processed = printDocument(xsdGeneratedFromClassesInMethod); 40 | // System.out.println("Got: " + processed); 41 | 42 | assertTrue(compareXmlIgnoringWhitespace(expected, processed).identical()); 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | protected List> getJaxbAnnotatedClassesForJaxbContext() { 50 | return Arrays.>asList(ExampleEnumHolder.class, AmericanCoin.class, FoodPreference.class); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/enums/AmericanCoin.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlEnum; 6 | import jakarta.xml.bind.annotation.XmlEnumValue; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.SomewhatNamedPerson; 9 | 10 | /** 11 | * Simple enumeration example defining standard US coins. 12 | * 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | @XmlType(namespace = SomewhatNamedPerson.NAMESPACE) 16 | @XmlEnum(Integer.class) 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public enum AmericanCoin { 19 | 20 | /** 21 | * A Penny, worth 1 cent. 22 | */ 23 | @XmlEnumValue("1") 24 | PENNY(1), 25 | 26 | /** 27 | * A Nickel, worth 5 cents. 28 | */ 29 | @XmlEnumValue("5") 30 | NICKEL(5), 31 | 32 | /** 33 | * A Nickel, worth 5 cents. 34 | */ 35 | @XmlEnumValue("10") 36 | DIME(10), 37 | @XmlEnumValue("25") 38 | QUARTER(25); 39 | 40 | // Internal state 41 | private int value; 42 | 43 | AmericanCoin(final int value) { 44 | this.value = value; 45 | } 46 | 47 | /** 48 | * The value - in cents - of this coin. 49 | * 50 | * @return the value - in cents - of this coin. 51 | */ 52 | public int getValue() { 53 | return value; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/enums/ExampleEnumHolder.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.SortedSet; 7 | import java.util.TreeSet; 8 | 9 | import jakarta.xml.bind.annotation.XmlAccessType; 10 | import jakarta.xml.bind.annotation.XmlAccessorType; 11 | import jakarta.xml.bind.annotation.XmlElement; 12 | import jakarta.xml.bind.annotation.XmlElementWrapper; 13 | import jakarta.xml.bind.annotation.XmlRootElement; 14 | import jakarta.xml.bind.annotation.XmlType; 15 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.SomewhatNamedPerson; 16 | 17 | /** 18 | * Trivial transport object type for Enums with different representations. 19 | * 20 | * @author Lennart Jörelid, jGuru Europe AB 21 | */ 22 | @XmlRootElement(namespace = SomewhatNamedPerson.NAMESPACE) 23 | @XmlType( 24 | namespace = SomewhatNamedPerson.NAMESPACE, 25 | propOrder = {"coins", "foodPreferences"}) 26 | @XmlAccessorType(XmlAccessType.FIELD) 27 | public class ExampleEnumHolder implements Serializable { 28 | 29 | /** 30 | * List containing all AmericanCoin objects. 31 | */ 32 | @XmlElementWrapper 33 | @XmlElement(name = "coin") 34 | private List coins; 35 | 36 | /** 37 | * SortedSet containing the FoodPreference objects collected. 38 | */ 39 | @XmlElementWrapper 40 | @XmlElement(name = "preference") 41 | private SortedSet foodPreferences; 42 | 43 | public ExampleEnumHolder() { 44 | 45 | this.coins = new ArrayList(); 46 | this.foodPreferences = new TreeSet(); 47 | } 48 | 49 | public List getCoins() { 50 | return coins; 51 | } 52 | 53 | public SortedSet getFoodPreferences() { 54 | return foodPreferences; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/enums/FoodPreference.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlEnum; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.SomewhatNamedPerson; 9 | 10 | /** 11 | * Simple enumeration example defining some Food preferences. 12 | * 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | @XmlType(namespace = SomewhatNamedPerson.NAMESPACE) 16 | @XmlEnum(String.class) 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public enum FoodPreference { 19 | 20 | /** 21 | * No special food preferences; eats everything. 22 | */ 23 | NONE(true, true), 24 | 25 | /** 26 | * Vegetarian who will not eat meats, but drinks milk. 27 | */ 28 | LACTO_VEGETARIAN(false, true), 29 | 30 | /** 31 | * Vegan who will neither eat meats nor drink milk. 32 | */ 33 | VEGAN(false, false); 34 | 35 | /** 36 | * Boolean value indicating if this {@link FoodPreference} eats meats. 37 | */ 38 | @XmlAttribute 39 | private boolean meatEater; 40 | 41 | /** 42 | * Boolean value indicating if this {@link FoodPreference} drinks milk. 43 | */ 44 | @XmlAttribute 45 | boolean milkDrinker; 46 | 47 | private FoodPreference(final boolean meatEater, final boolean milkDrinker) { 48 | this.meatEater = meatEater; 49 | this.milkDrinker = milkDrinker; 50 | } 51 | 52 | public boolean isMeatEater() { 53 | return meatEater; 54 | } 55 | 56 | public boolean isMilkDrinker() { 57 | return milkDrinker; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/enums/Regions.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.enums; 2 | 3 | import java.util.Set; 4 | import java.util.TreeSet; 5 | 6 | import jakarta.xml.bind.annotation.XmlAccessType; 7 | import jakarta.xml.bind.annotation.XmlAccessorType; 8 | import jakarta.xml.bind.annotation.XmlElement; 9 | import jakarta.xml.bind.annotation.XmlElementWrapper; 10 | import jakarta.xml.bind.annotation.XmlRootElement; 11 | import jakarta.xml.bind.annotation.XmlType; 12 | import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.SomewhatNamedPerson; 13 | 14 | /** 15 | * @author Lennart Jörelid, jGuru Europe AB 16 | */ 17 | @XmlRootElement(namespace = SomewhatNamedPerson.NAMESPACE) 18 | @XmlType( 19 | namespace = SomewhatNamedPerson.NAMESPACE, 20 | propOrder = {"counties", "municipalities"}) 21 | @XmlAccessorType(XmlAccessType.FIELD) 22 | public class Regions { 23 | 24 | @XmlElementWrapper 25 | @XmlElement(name = "county") 26 | private Set counties; 27 | 28 | @XmlElementWrapper 29 | @XmlElement(name = "municipality") 30 | private Set municipalities; 31 | 32 | public Regions() { 33 | this.counties = new TreeSet(); 34 | this.municipalities = new TreeSet(); 35 | } 36 | 37 | public Set getCounties() { 38 | return counties; 39 | } 40 | 41 | public Set getMunicipalities() { 42 | return municipalities; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/wrappers/ExampleXmlWapperUsingJavaBeanAccessors.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.SortedSet; 7 | import java.util.TreeSet; 8 | 9 | import jakarta.xml.bind.annotation.XmlElement; 10 | import jakarta.xml.bind.annotation.XmlElementWrapper; 11 | 12 | /** 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | public class ExampleXmlWapperUsingJavaBeanAccessors implements Serializable { 16 | 17 | private List strings; 18 | private SortedSet integerSet; 19 | 20 | public ExampleXmlWapperUsingJavaBeanAccessors() { 21 | 22 | this.strings = new ArrayList(); 23 | this.integerSet = new TreeSet(); 24 | } 25 | 26 | /** 27 | * JavaBean getter for a List containing some strings. 28 | */ 29 | @XmlElementWrapper(name = "foobar") 30 | @XmlElement(name = "aString") 31 | public List getStrings() { 32 | return strings; 33 | } 34 | 35 | /** 36 | * JavaBean getter for a SortedSet containing Integers. 37 | */ 38 | @XmlElementWrapper 39 | @XmlElement(name = "anInteger") 40 | public SortedSet getIntegerSet() { 41 | return integerSet; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/javadoc/wrappers/ExampleXmlWrapper.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.SortedSet; 7 | import java.util.TreeSet; 8 | 9 | import jakarta.xml.bind.annotation.XmlAccessType; 10 | import jakarta.xml.bind.annotation.XmlAccessorType; 11 | import jakarta.xml.bind.annotation.XmlElement; 12 | import jakarta.xml.bind.annotation.XmlElementWrapper; 13 | import jakarta.xml.bind.annotation.XmlRootElement; 14 | import jakarta.xml.bind.annotation.XmlType; 15 | 16 | /** 17 | * Trivial transport object type for collections. 18 | * 19 | * @author Lennart Jörelid, jGuru Europe AB 20 | */ 21 | @XmlRootElement(namespace = "http://jaxb.mojohaus.org/wrappers") 22 | @XmlType( 23 | namespace = "http://jaxb.mojohaus.org/wrappers", 24 | propOrder = {"strings", "integerSet"}) 25 | @XmlAccessorType(XmlAccessType.FIELD) 26 | public class ExampleXmlWrapper implements Serializable { 27 | 28 | /** 29 | * List containing some strings. 30 | */ 31 | @XmlElementWrapper(name = "foobar") 32 | @XmlElement(name = "aString") 33 | private List strings; 34 | 35 | /** 36 | * SortedSet containing Integers. 37 | */ 38 | @XmlElementWrapper 39 | @XmlElement(name = "anInteger") 40 | private SortedSet integerSet; 41 | 42 | public ExampleXmlWrapper() { 43 | 44 | this.strings = new ArrayList(); 45 | this.integerSet = new TreeSet(); 46 | } 47 | 48 | public List getStrings() { 49 | return strings; 50 | } 51 | 52 | public SortedSet getIntegerSet() { 53 | return integerSet; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/schemaenhancement/TransformSchemaTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertThrows; 6 | 7 | /** 8 | * @author Lennart Jörelid 9 | */ 10 | class TransformSchemaTest { 11 | 12 | // Shared state 13 | private static final String URI = "http://www.mithlond.se/foo/bar"; 14 | private static final String PREFIX = "bar"; 15 | private static final String FILENAME = "mithlondBar"; 16 | private static final TransformSchema unitUnderTest = new TransformSchema(URI, PREFIX, FILENAME); 17 | 18 | @Test 19 | void validateExceptionOnEmptyToFileArgument() { 20 | assertThrows(IllegalArgumentException.class, () -> { 21 | 22 | // Act & Assert 23 | unitUnderTest.setToFile(""); 24 | }); 25 | } 26 | 27 | @Test 28 | void validateExceptionOnEmptyToPrefixArgument() { 29 | assertThrows(IllegalArgumentException.class, () -> { 30 | 31 | // Act & Assert 32 | unitUnderTest.setToPrefix(""); 33 | }); 34 | } 35 | 36 | @Test 37 | void validateExceptionOnEmptyUriArgument() { 38 | assertThrows(IllegalArgumentException.class, () -> { 39 | 40 | // Act & Assert 41 | unitUnderTest.setUri(""); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/schemageneration/postprocessing/schemaenhancement/XmlNameAnnotatedClassWithFieldAccess.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | 10 | /** 11 | * This is a XmlType and name-switched class using Field access. 12 | * 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | @XmlRootElement 16 | @XmlType(name = "AnnotatedXmlNameAnnotatedClassWithFieldAccessTypeName") 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public class XmlNameAnnotatedClassWithFieldAccess { 19 | 20 | /** 21 | * This is a string field. 22 | */ 23 | @XmlElement(name = "annotatedStringField") 24 | private String stringField; 25 | 26 | /** 27 | * This is an integer field. 28 | */ 29 | @XmlAttribute(name = "annotatedIntegerField") 30 | private Integer integerField; 31 | 32 | public XmlNameAnnotatedClassWithFieldAccess() {} 33 | 34 | public XmlNameAnnotatedClassWithFieldAccess(final String stringField, final Integer integerField) { 35 | this.stringField = stringField; 36 | this.integerField = integerField; 37 | } 38 | 39 | public String getStringField() { 40 | return stringField; 41 | } 42 | 43 | public Integer getIntegerField() { 44 | return integerField; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/shared/ValidateTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | import static org.junit.jupiter.api.Assertions.fail; 7 | 8 | /** 9 | * @author Lennart Jörelid 10 | */ 11 | class ValidateTest { 12 | 13 | @Test 14 | void validateErrorMessageOnSuppliedArgumentName() { 15 | 16 | // Assemble 17 | final String argumentName = "fooBar"; 18 | final String expectedMsg = "Cannot handle empty 'fooBar' argument."; 19 | 20 | // Act & Assert 21 | try { 22 | Validate.notEmpty("", argumentName); 23 | } catch (IllegalArgumentException expected) { 24 | assertEquals(expectedMsg, expected.getMessage()); 25 | } catch (Exception e) { 26 | fail("Expected IllegalArgumentException, but got " + e); 27 | } 28 | } 29 | 30 | @Test 31 | void validateErrorMessageOnNullArgumentName() { 32 | 33 | // Act & Assert 34 | try { 35 | Validate.notEmpty("", null); 36 | } catch (IllegalArgumentException expected) { 37 | assertEquals("Cannot handle empty argument.", expected.getMessage()); 38 | } catch (Exception e) { 39 | fail("Expected IllegalArgumentException, but got " + e); 40 | } 41 | } 42 | 43 | @Test 44 | void validateErrorMessageOnNullArgument() { 45 | 46 | // Assemble 47 | final String argumentName = "fooBar"; 48 | final String expectedMsg = "Cannot handle null 'fooBar' argument."; 49 | 50 | // Act & Assert 51 | try { 52 | Validate.notNull(null, argumentName); 53 | } catch (NullPointerException expected) { 54 | assertEquals(expectedMsg, expected.getMessage()); 55 | } catch (Exception e) { 56 | fail("Expected IllegalArgumentException, but got " + e); 57 | } 58 | } 59 | 60 | @Test 61 | void validateErrorMessageOnNullArgumentWithNullName() { 62 | 63 | // Act & Assert 64 | try { 65 | Validate.notNull(null, null); 66 | } catch (NullPointerException expected) { 67 | assertEquals("Cannot handle null argument.", expected.getMessage()); 68 | } catch (Exception e) { 69 | fail("Expected IllegalArgumentException, but got " + e); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/shared/filters/DebugFilter.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters; 2 | 3 | import java.util.SortedMap; 4 | import java.util.TreeMap; 5 | 6 | /** 7 | * @author Lennart Jörelid, jGuru Europe AB 8 | */ 9 | public class DebugFilter extends AbstractFilter { 10 | 11 | // Shared state 12 | private final Object lock = new Object(); 13 | public SortedMap invocations = new TreeMap(); 14 | 15 | public DebugFilter(final boolean processNullValues) { 16 | super(); 17 | setProcessNullValues(processNullValues); 18 | } 19 | 20 | @Override 21 | protected boolean onNullCandidate() { 22 | 23 | addInvocation(null); 24 | return super.onNullCandidate(); 25 | } 26 | 27 | @Override 28 | protected boolean onCandidate(final String nonNullCandidate) { 29 | addInvocation(nonNullCandidate); 30 | return false; 31 | } 32 | 33 | // 34 | // Internal state 35 | // 36 | 37 | private void addInvocation(final String candidate) { 38 | 39 | synchronized (lock) { 40 | invocations.put(1 + invocations.size(), candidate); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/shared/filters/T_AbstractFilterTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters; 2 | 3 | import java.util.SortedMap; 4 | 5 | import org.codehaus.mojo.jaxb2.BufferingLog; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | import static org.junit.jupiter.api.Assertions.*; 10 | 11 | /** 12 | * @author Lennart Jörelid, jGuru Europe AB 13 | */ 14 | class T_AbstractFilterTest { 15 | 16 | // Shared state 17 | private BufferingLog log; 18 | 19 | @BeforeEach 20 | void setupSharedState() { 21 | log = new BufferingLog(); 22 | } 23 | 24 | @Test 25 | void validateExceptionOnNotInitializingFilterBeforeFirstCall() { 26 | assertThrows(IllegalStateException.class, () -> { 27 | 28 | // Assemble 29 | final DebugFilter unitUnderTest = new DebugFilter(false); 30 | 31 | // Act & Assert 32 | unitUnderTest.accept("foobar!"); 33 | }); 34 | } 35 | 36 | @Test 37 | void validateCallOrderIfNotProcessingNulls() { 38 | 39 | // Assemble 40 | final DebugFilter unitUnderTest = new DebugFilter(false); 41 | 42 | // Act 43 | unitUnderTest.initialize(log); 44 | unitUnderTest.accept("first"); 45 | unitUnderTest.accept(null); 46 | unitUnderTest.accept("third"); 47 | 48 | // Assert 49 | final SortedMap invocations = unitUnderTest.invocations; 50 | assertEquals(2, invocations.size()); 51 | assertEquals("first", invocations.get(1)); 52 | assertEquals("third", invocations.get(2)); 53 | } 54 | 55 | @Test 56 | void validateCallOrderIfProcessingNulls() { 57 | 58 | // Assemble 59 | final DebugFilter unitUnderTest = new DebugFilter(true); 60 | 61 | // Act 62 | unitUnderTest.initialize(log); 63 | unitUnderTest.accept("first"); 64 | unitUnderTest.accept(null); 65 | unitUnderTest.accept("third"); 66 | 67 | // Assert 68 | final SortedMap invocations = unitUnderTest.invocations; 69 | assertEquals(3, invocations.size()); 70 | assertEquals("first", invocations.get(1)); 71 | assertNull(invocations.get(2)); 72 | assertEquals("third", invocations.get(3)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/shared/filters/pattern/AbstractPatternFilterTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters.pattern; 2 | 3 | import java.io.File; 4 | import java.net.URL; 5 | import java.util.Map; 6 | import java.util.TreeMap; 7 | 8 | import org.codehaus.mojo.jaxb2.BufferingLog; 9 | import org.codehaus.mojo.jaxb2.shared.FileSystemUtilities; 10 | import org.junit.jupiter.api.BeforeEach; 11 | 12 | import static org.junit.jupiter.api.Assertions.assertTrue; 13 | 14 | /** 15 | * @author Lennart Jörelid, jGuru Europe AB 16 | */ 17 | public abstract class AbstractPatternFilterTest { 18 | 19 | // Shared state 20 | protected File exclusionDirectory; 21 | protected File[] fileList; 22 | protected BufferingLog log; 23 | private String defaultExclusionDirectory; 24 | 25 | public AbstractPatternFilterTest(final String defaultExclusionDirectory) { 26 | this.defaultExclusionDirectory = defaultExclusionDirectory; 27 | } 28 | 29 | public AbstractPatternFilterTest() { 30 | this("testdata/shared/filefilter/exclusion"); 31 | } 32 | 33 | @BeforeEach 34 | @SuppressWarnings("all") 35 | public void setupSharedState() { 36 | 37 | log = new BufferingLog(BufferingLog.LogLevel.DEBUG); 38 | 39 | final URL exclusionDirUrl = getClass().getClassLoader().getResource(defaultExclusionDirectory); 40 | exclusionDirectory = new File(exclusionDirUrl.getPath()); 41 | assertTrue(FileSystemUtilities.EXISTING_DIRECTORY.accept(exclusionDirectory)); 42 | 43 | fileList = exclusionDirectory.listFiles(); 44 | for (File current : fileList) { 45 | assertTrue(FileSystemUtilities.EXISTING_FILE.accept(current)); 46 | } 47 | 48 | // Delegate 49 | onSetup(); 50 | } 51 | 52 | protected void onSetup() { 53 | // Do nothing 54 | } 55 | 56 | protected Map applyFilterAndRetrieveResults( 57 | final AbstractPatternFilter unitUnderTest, final T[] candidates, final StringConverter converter) { 58 | 59 | Map toReturn = new TreeMap(); 60 | 61 | for (T current : candidates) { 62 | toReturn.put(converter.convert(current), unitUnderTest.accept(current)); 63 | } 64 | 65 | return toReturn; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/jaxb2/shared/filters/pattern/DebugPatternFilter.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.shared.filters.pattern; 2 | 3 | import java.util.List; 4 | import java.util.SortedMap; 5 | import java.util.TreeMap; 6 | 7 | /** 8 | * @author Lennart Jörelid, jGuru Europe AB 9 | */ 10 | public class DebugPatternFilter extends AbstractPatternFilter { 11 | 12 | // Shared state 13 | private final Object lock = new Object(); 14 | public SortedMap invocations = new TreeMap(); 15 | 16 | public DebugPatternFilter(final List patterns, final boolean acceptCandidateOnPatternMatch) { 17 | super(); 18 | setPatterns(patterns); 19 | setAcceptCandidateOnPatternMatch(acceptCandidateOnPatternMatch); 20 | } 21 | 22 | public DebugPatternFilter( 23 | final boolean processNullValues, 24 | final List patterns, 25 | final StringConverter converter, 26 | final boolean acceptCandidateOnPatternMatch) { 27 | super(); 28 | setProcessNullValues(processNullValues); 29 | setPatterns(patterns); 30 | setConverter(converter); 31 | setAcceptCandidateOnPatternMatch(acceptCandidateOnPatternMatch); 32 | } 33 | 34 | @Override 35 | protected boolean onCandidate(final String nonNullCandidate) { 36 | boolean toReturn = super.onCandidate(nonNullCandidate); 37 | addInvocation(nonNullCandidate, toReturn); 38 | return toReturn; 39 | } 40 | 41 | // 42 | // Internal state 43 | // 44 | 45 | private void addInvocation(final String candidate, final boolean result) { 46 | 47 | synchronized (lock) { 48 | final String[] resultStruct = new String[2]; 49 | resultStruct[0] = candidate; 50 | resultStruct[1] = "" + result; 51 | 52 | invocations.put(1 + invocations.size(), resultStruct); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/resources/generated/schema/schema1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/test/resources/generated/schema/schema2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test/resources/generated/schema/schema3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | [%c{1}::%M]: %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/jaxb2/helpers/anotherSchema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/jaxb2/helpers/someSchema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/jaxb2/helpers/yetAnotherSchema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/annotated/XmlNameAnnotatedClassWithFieldAccess.java: -------------------------------------------------------------------------------- 1 | package testdata.schemageneration.javadoc.annotated; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | 10 | /** 11 | * This is a XmlType and name-switched class using Field access. 12 | * 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | @XmlRootElement 16 | @XmlType(name = "AnnotatedXmlNameAnnotatedClassWithFieldAccessTypeName") 17 | @XmlAccessorType(XmlAccessType.FIELD) 18 | public class XmlNameAnnotatedClassWithFieldAccess { 19 | 20 | /** 21 | * This is a string field. 22 | */ 23 | @XmlElement(name = "annotatedStringField") 24 | private String stringField; 25 | 26 | /** 27 | * This is an integer field. 28 | */ 29 | @XmlAttribute(name = "annotatedIntegerField") 30 | private Integer integerField; 31 | 32 | public XmlNameAnnotatedClassWithFieldAccess() { 33 | } 34 | 35 | public XmlNameAnnotatedClassWithFieldAccess(final String stringField, final Integer integerField) { 36 | this.stringField = stringField; 37 | this.integerField = integerField; 38 | } 39 | 40 | public String getStringField() { 41 | return stringField; 42 | } 43 | 44 | public Integer getIntegerField() { 45 | return integerField; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/annotated/XmlNameAnnotatedClassWithMethodAccess.java: -------------------------------------------------------------------------------- 1 | package testdata.schemageneration.javadoc.annotated; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlElement; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | 10 | /** 11 | * This is a XmlType and name-switched class using Method access. 12 | * 13 | * @author Lennart Jörelid, jGuru Europe AB 14 | */ 15 | @XmlRootElement 16 | @XmlType(name = "AnnotatedXmlNameAnnotatedClassWithMethodAccessTypeName") 17 | @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 18 | public class XmlNameAnnotatedClassWithMethodAccess { 19 | 20 | private String stringField; 21 | 22 | private Integer integerField; 23 | 24 | public XmlNameAnnotatedClassWithMethodAccess() { 25 | } 26 | 27 | public XmlNameAnnotatedClassWithMethodAccess(final String stringField, final Integer integerField) { 28 | this.stringField = stringField; 29 | this.integerField = integerField; 30 | } 31 | 32 | /** 33 | * Getter for the stringField. 34 | * 35 | * @return the stringField value 36 | */ 37 | @XmlElement(name = "annotatedStringMethod") 38 | public String getStringField() { 39 | return stringField; 40 | } 41 | 42 | /** 43 | * Getter for the integerField. 44 | * 45 | * @return the integerField value 46 | */ 47 | @XmlAttribute(name = "annotatedIntegerMethod") 48 | public Integer getIntegerField() { 49 | return integerField; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/basic/NodeProcessor.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.w3c.dom.Node; 23 | 24 | /** 25 | * Processor/visitor pattern specification for DOM Nodes. 26 | * 27 | * @author Lennart Jörelid 28 | * @author Mr. Foo 29 | * @see org.w3c.dom.Node 30 | */ 31 | public interface NodeProcessor { 32 | 33 | /** 34 | * Defines if this visitor should process the provided node. 35 | * 36 | * @param aNode The DOM node to process. 37 | * @return true if the provided Node should be processed by this NodeProcessor. 38 | */ 39 | boolean accept(Node aNode); 40 | 41 | /** 42 | * Processes the provided DOM Node. 43 | * 44 | * @param aNode The DOM Node to process. 45 | */ 46 | void process(Node aNode); 47 | } -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/enums/AmericanCoin.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlEnum; 6 | import jakarta.xml.bind.annotation.XmlEnumValue; 7 | import jakarta.xml.bind.annotation.XmlType; 8 | 9 | /** 10 | * Simple enumeration example defining standard US coins. 11 | * 12 | * @author Lennart Jörelid, jGuru Europe AB 13 | */ 14 | @XmlType(namespace = "http://gnat.west.se/foods") 15 | @XmlEnum(Integer.class) 16 | @XmlAccessorType(XmlAccessType.FIELD) 17 | public enum AmericanCoin { 18 | 19 | /** 20 | * A Penny, worth 1 cent. 21 | */ 22 | @XmlEnumValue("1") PENNY(1), 23 | 24 | /** 25 | * A Nickel, worth 5 cents. 26 | */ 27 | @XmlEnumValue("5") NICKEL(5), 28 | 29 | /** 30 | * A Dime, worth 10 cents. 31 | */ 32 | @XmlEnumValue("10") DIME(10), 33 | 34 | /** 35 | * A Quarter, worth 25 cents. 36 | */ 37 | @XmlEnumValue("25") QUARTER(25); 38 | 39 | // Internal state 40 | private int value; 41 | 42 | AmericanCoin(final int value) { 43 | this.value = value; 44 | } 45 | 46 | /** 47 | * The value - in cents - of this coin. 48 | * 49 | * @return the value - in cents - of this coin. 50 | */ 51 | public int getValue() { 52 | return value; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/enums/ExampleEnumHolder.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | import java.util.TreeSet; 14 | 15 | /** 16 | * Trivial transport object type for Enums with different representations. 17 | * 18 | * @author Lennart Jörelid, jGuru Europe AB 19 | */ 20 | @XmlRootElement(namespace = "http://gnat.west.se/foods") 21 | @XmlType(namespace = "http://gnat.west.se/foods", propOrder = {"coins", "foodPreferences"}) 22 | @XmlAccessorType(XmlAccessType.FIELD) 23 | public class ExampleEnumHolder implements Serializable { 24 | 25 | /** 26 | * List containing all AmericanCoin objects. 27 | */ 28 | @XmlElementWrapper 29 | @XmlElement(name = "coin") 30 | private List coins; 31 | 32 | /** 33 | * SortedSet containing the FoodPreference objects collected. 34 | */ 35 | @XmlElementWrapper 36 | @XmlElement(name = "preference") 37 | private SortedSet foodPreferences; 38 | 39 | 40 | public ExampleEnumHolder() { 41 | 42 | this.coins = new ArrayList(); 43 | this.foodPreferences = new TreeSet(); 44 | } 45 | 46 | public List getCoins() { 47 | return coins; 48 | } 49 | 50 | public SortedSet getFoodPreferences() { 51 | return foodPreferences; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/enums/FoodPreference.java: -------------------------------------------------------------------------------- 1 | package enums; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlAttribute; 6 | import jakarta.xml.bind.annotation.XmlEnum; 7 | 8 | /** 9 | * Simple enumeration example defining some Food preferences. 10 | * 11 | * @author Lennart Jörelid, jGuru Europe AB 12 | */ 13 | @XmlEnum(String.class) 14 | @XmlAccessorType(XmlAccessType.FIELD) 15 | public enum FoodPreference { 16 | 17 | /** 18 | * No special food preferences; eats everything. 19 | */ 20 | NONE(true, true), 21 | 22 | /** 23 | * Vegetarian who will not eat meats, but drinks milk. 24 | */ 25 | LACTO_VEGETARIAN(false, true), 26 | 27 | /** 28 | * Vegan who will neither eat meats nor drink milk. 29 | */ 30 | VEGAN(false, false); 31 | 32 | /** 33 | * Boolean value indicating if this {@link FoodPreference} eats meats. 34 | */ 35 | @XmlAttribute 36 | private boolean meatEater; 37 | 38 | /** 39 | * Boolean value indicating if this {@link FoodPreference} drinks milk. 40 | */ 41 | @XmlAttribute 42 | boolean milkDrinker; 43 | 44 | private FoodPreference(final boolean meatEater, final boolean milkDrinker) { 45 | this.meatEater = meatEater; 46 | this.milkDrinker = milkDrinker; 47 | } 48 | 49 | public boolean isMeatEater() { 50 | return meatEater; 51 | } 52 | 53 | public boolean isMilkDrinker() { 54 | return milkDrinker; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/enums/rawEnumSchema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/expectedRawExampleEnumHolder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 5 6 | 10 7 | 25 8 | 9 | 10 | NONE 11 | LACTO_VEGETARIAN 12 | VEGAN 13 | 14 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/expectedSemiDocumentedClass.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lennart Jörelid, jGuru Europe AB]]> 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/expectedTransformedSomewhatNamedPerson.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lennart Jörelid, jGuru Europe AB 8 | (since): Some version.]]> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/methodbased/ExampleXmlWrapperUsingMethodAccess.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | import java.util.TreeSet; 14 | 15 | /** 16 | * Another trivial transport object type for collections. 17 | * 18 | * @author Lennart Jörelid, jGuru Europe AB 19 | */ 20 | @XmlRootElement(namespace = "http://jaxb.mojohaus.org/wrappers") 21 | @XmlType(namespace = "http://jaxb.mojohaus.org/wrappers", propOrder = {"strings", "integerSet"}) 22 | public class ExampleXmlWrapperUsingMethodAccess implements Serializable { 23 | 24 | private List strings2; 25 | 26 | private SortedSet integerSet2; 27 | 28 | 29 | public ExampleXmlWrapperUsingMethodAccess() { 30 | 31 | this.strings2 = new ArrayList(); 32 | this.integerSet2 = new TreeSet(); 33 | } 34 | 35 | /** 36 | * List containing some strings. 37 | */ 38 | @XmlElementWrapper(name = "foobar") 39 | @XmlElement(name = "aString") 40 | public List getStrings() { 41 | return strings; 42 | } 43 | 44 | /** 45 | * SortedSet containing Integers. 46 | */ 47 | @XmlElementWrapper 48 | @XmlElement(name = "anInteger") 49 | public SortedSet getIntegerSet() { 50 | return integerSet; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/xmlwrappers/ExampleXmlWrapperUsingFieldAccess.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | import java.util.TreeSet; 14 | 15 | /** 16 | * Trivial transport object type for collections. 17 | * 18 | * @author Lennart Jörelid, jGuru Europe AB 19 | */ 20 | @XmlRootElement(namespace = "http://jaxb.mojohaus.org/wrappers") 21 | @XmlType(namespace = "http://jaxb.mojohaus.org/wrappers", propOrder = {"strings", "integerSet"}) 22 | @XmlAccessorType(XmlAccessType.FIELD) 23 | public class ExampleXmlWrapperUsingFieldAccess implements Serializable { 24 | 25 | /** 26 | * List containing some strings. 27 | */ 28 | @XmlElementWrapper(name = "foobar") 29 | @XmlElement(name = "aString") 30 | private List strings; 31 | 32 | /** 33 | * SortedSet containing Integers. 34 | */ 35 | @XmlElementWrapper 36 | @XmlElement(name = "anInteger") 37 | private SortedSet integerSet; 38 | 39 | 40 | public ExampleXmlWrapperUsingFieldAccess() { 41 | 42 | this.strings = new ArrayList(); 43 | this.integerSet = new TreeSet(); 44 | } 45 | 46 | public List getStrings() { 47 | return strings; 48 | } 49 | 50 | public SortedSet getIntegerSet() { 51 | return integerSet; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/xmlwrappers/ExampleXmlWrapperUsingMethodAccess.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.wrappers; 2 | 3 | import jakarta.xml.bind.annotation.XmlAccessType; 4 | import jakarta.xml.bind.annotation.XmlAccessorType; 5 | import jakarta.xml.bind.annotation.XmlElement; 6 | import jakarta.xml.bind.annotation.XmlElementWrapper; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlType; 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | import java.util.TreeSet; 14 | 15 | /** 16 | * Another trivial transport object type for collections. 17 | * 18 | * @author Lennart Jörelid, jGuru Europe AB 19 | */ 20 | @XmlRootElement(namespace = "http://jaxb.mojohaus.org/wrappers") 21 | @XmlType(namespace = "http://jaxb.mojohaus.org/wrappers", propOrder = {"methodStrings", "methodIntegerSet"}) 22 | public class ExampleXmlWrapperUsingMethodAccess implements Serializable { 23 | 24 | private List methodStrings; 25 | 26 | private SortedSet methodIntegerSet; 27 | 28 | public ExampleXmlWrapperUsingMethodAccess() { 29 | 30 | this.methodStrings = new ArrayList(); 31 | this.methodIntegerSet = new TreeSet(); 32 | } 33 | 34 | /** 35 | * List containing some methodStrings. 36 | */ 37 | @XmlElementWrapper(name = "foobar") 38 | @XmlElement(name = "aString") 39 | public List getMethodStrings() { 40 | return methodStrings; 41 | } 42 | 43 | /** 44 | * SortedSet containing Integers. 45 | */ 46 | @XmlElementWrapper 47 | @XmlElement(name = "anInteger") 48 | public SortedSet getMethodIntegerSet() { 49 | return methodIntegerSet; 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/test/resources/testdata/schemageneration/javadoc/xmlwrappers/expectedRawXmlWrappers.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/classloader/ImmediateTestResource.txt: -------------------------------------------------------------------------------- 1 | This is a test text. -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/classloader/jarSubDirectory/aJarWithResources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/jaxb2-maven-plugin/1c941f38fa12714abfbfe6b5b161cb490a846980/src/test/resources/testdata/shared/classloader/jarSubDirectory/aJarWithResources.jar -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/classloader/subdirectory/SubdirectoryTestResource.txt: -------------------------------------------------------------------------------- 1 | This is a Subdirectory test text resource. -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/dirwith space/somefile.txt: -------------------------------------------------------------------------------- 1 | This is a resource. -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/filefilter/exclusion/AnXmlFile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | This is a Bar! 4 | -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/filefilter/exclusion/TextFile.txt: -------------------------------------------------------------------------------- 1 | This is a Text File. -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/filesystemutilities/TestFile2.txt: -------------------------------------------------------------------------------- 1 | This is another test file. -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/filesystemutilities/canonicals/TestFile1.txt: -------------------------------------------------------------------------------- 1 | This is a test file. -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/nazgul-tools-validation-aspect-4.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojohaus/jaxb2-maven-plugin/1c941f38fa12714abfbfe6b5b161cb490a846980/src/test/resources/testdata/shared/nazgul-tools-validation-aspect-4.0.1.jar -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/not_a_dependency.properties: -------------------------------------------------------------------------------- 1 | # This is not a correctly formed dependency.properties file ... 2 | foo= -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/standard/exclusions/.hg/someHgFile.txt: -------------------------------------------------------------------------------- 1 | Dont remove this file 2 | -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/standard/exclusions/.svn/someSvnFile.txt: -------------------------------------------------------------------------------- 1 | Dont remove this file 2 | -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/standard/exclusions/CVS/someCvsFile.txt: -------------------------------------------------------------------------------- 1 | Dont remove this file 2 | -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/standard/exclusions/someFile.log: -------------------------------------------------------------------------------- 1 | Dont remove this file 2 | -------------------------------------------------------------------------------- /src/test/resources/testdata/shared/urlhandling/file with spaces.txt: -------------------------------------------------------------------------------- 1 | This is a file with spaces in its name. -------------------------------------------------------------------------------- /src/test/resources/testschemas/address.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/testschemas/address2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/testschemas/address3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/testschemas/address4.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | --------------------------------------------------------------------------------