Skip to content

Commit

Permalink
Merge pull request highsource#282 from highsource/jt-264-basics
Browse files Browse the repository at this point in the history
Merge jaxb basics
  • Loading branch information
mattrpav authored Aug 3, 2023
2 parents 67fd013 + c164f18 commit ecc6839
Show file tree
Hide file tree
Showing 693 changed files with 34,394 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
**/.classpath
**/.project
**/.settings
target
target
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2006-2021, Alexey Valikov.
Copyright (c) 2005-2021, Alexey Valikov.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# JAXB Maven Plugin #

Welcome to the `org.jvnet.jaxb:jaxb-maven-plugin`, the most advanced and feature-full Maven plugin for XML Schema compilation.
Expand Down Expand Up @@ -76,3 +77,42 @@ compiling XML Schemas (as well as WSDL, DTDs, RELAX NG) into Java classes in Mav

> If you are interested in the Mojohaus JAXB2 Maven Plugin (`org.codehaus.mojo:jaxb2-maven-plugin`),
> please follow [this link](https://github.com/mojohaus/jaxb2-maven-plugin) to the corresponding website.
=======
# JAXB2 Basics

JAXB2 Basics is an [open source](https://github.com/highsource/jaxb2-basics/blob/master/LICENSE) project
which provides useful plugins and tools for [JAXB 2.x reference implementation](https://jaxb.java.net/).

# Documentation

Please refer to the [wiki](https://github.com/highsource/jaxb2-basics/wiki) for documentation.

JAXB2 Basics can only be used with JAXB/XJC 2.3.0 and higher. JAXB/XJC versions 2.2.x and earlier are no longer supported.

JAXB2 Basics can only be used with Java 1.8 and above.

## Using JAXB2 Basics

* [Using JAXB2 Basics Plugins](https://github.com/highsource/jaxb2-basics/wiki/Using-JAXB2-Basics-Plugins)

## JAXB2 Basics Plugins
* [SimpleEquals Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-SimpleEquals-Plugin) - generates runtime-free reflection-free `equals(...)` methods.
* [SimpleHashCode Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-SimpleHashCode-Plugin) - generates runtime-free reflection-free `hashCode()` methods.
* Equals Plugin - generates reflection-free strategic `equals(...)` method.
* HashCode Plugin - generates reflection-free strategic `hashCode()` method.
* ToString Plugin - generates reflection-free strategic `toString()` methods.
* Copyable Plugin - generates reflection-free strategic `copy(...)` deep copying.
* Mergeable Plugin - generates reflection-free strategic `merge(...)` methods to merge data from two source objects into the given object.
* Inheritance Plugin - makes schema-derived classes extend certain class or implement certain interfaces.
* Wildcard Plugin - allows you to specify the wildcard mode for the wildcard properties.
* AutoInheritance Plugin - makes classes derived from global elements or complex types extend or implement certain classes or interfaces automatically.
* [Setters Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-Setters-Plugin) - generates setters for collections.
* [Simplify Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-Simplify-Plugin) - simplifies weird properties like `aOrBOrC`.
* [EnumValue Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-EnumValue-Plugin) - makes all the generated enums implement the `EnumValue<T>` interface.
* JAXBIndex Plugin - generated `jaxb.index` files listing schema-derived classes.
* [FixJAXB1058 Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-FixJAXB1058-Plugin) - fixes [JAXB-1058](https://java.net/jira/browse/JAXB-1058).

## Credits ##

* Many thanks to **James Annesley** for his ideas and help with the [SimpleEquals Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-SimpleEquals-Plugin) and the [SimpleHashCode Plugin](https://github.com/highsource/jaxb2-basics/wiki/JAXB2-SimpleHashCode-Plugin).
>>>>>>> jaxb_basics/master
2 changes: 2 additions & 0 deletions basics/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Register a bug with unboxed fields.
* Add `simplelogger.properties` to samples.
5 changes: 5 additions & 0 deletions basics/ant/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/target/
.settings
.project
.classpath

36 changes: 36 additions & 0 deletions basics/ant/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics-ant</artifactId>
<packaging>jar</packaging>
<name>JAXB2 Basics - Ant Task</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
</build>
</project>
38 changes: 38 additions & 0 deletions basics/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jvnet.jaxb2_commons.xjc;

import org.apache.tools.ant.BuildException;

public class XJC2Task extends com.sun.tools.xjc.XJC2Task {

private boolean disableXmlSecurity = true;

public void setDisableXmlSecurity(boolean disableXmlSecurity) {
this.disableXmlSecurity = disableXmlSecurity;
}

private String accessExternalSchema = "all";

public void setAccessExternalSchema(String accessExternalSchema) {
this.accessExternalSchema = accessExternalSchema;
}

private String accessExternalDTD = "all";

public void setAccessExternalDTD(String accessExternalDTD) {
this.accessExternalDTD = accessExternalDTD;
}

@Override
public void execute() throws BuildException {
this.options.disableXmlSecurity = this.disableXmlSecurity;
if (accessExternalSchema != null) {
System.setProperty("javax.xml.accessExternalSchema",
accessExternalSchema);
}
if (accessExternalDTD != null) {
System.setProperty("javax.xml.accessExternalDTD", accessExternalDTD);
}
super.execute();
}

}
4 changes: 4 additions & 0 deletions basics/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target/
.settings
.project
.classpath
109 changes: 109 additions & 0 deletions basics/basic/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics</artifactId>
<packaging>jar</packaging>
<name>JAXB2 Basics - Basic Plugins</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-tools</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.javaparser</groupId>
<artifactId>javaparser</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>only-eclipse</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.felix
</groupId>
<artifactId>
maven-bundle-plugin
</artifactId>
<versionRange>
[2.3.7,)
</versionRange>
<goals>
<goal>manifest</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.jvnet.jaxb2.maven2
</groupId>
<artifactId>
maven-jaxb2-plugin
</artifactId>
<versionRange>
[0.8.1,)
</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
<build>
<defaultGoal>install</defaultGoal>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jvnet.jaxb2_commons.plugin;

import javax.xml.namespace.QName;

public class Customizations {

public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic";

public static QName GENERATED_ELEMENT_NAME = new QName(NAMESPACE_URI,
"generated");

public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
"ignored");

public static QName PROPERTY_ELEMENT_NAME = new QName(NAMESPACE_URI,
"property");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.jvnet.jaxb2_commons.plugin;

import javax.xml.namespace.QName;

import org.jvnet.jaxb2_commons.util.CustomizationUtils;

import com.sun.tools.xjc.model.CClassInfo;
import com.sun.tools.xjc.model.CEnumLeafInfo;
import com.sun.tools.xjc.model.CPropertyInfo;
import com.sun.tools.xjc.outline.ClassOutline;
import com.sun.tools.xjc.outline.EnumOutline;
import com.sun.tools.xjc.outline.FieldOutline;

public class CustomizedIgnoring implements Ignoring {

private final QName[] ignoredCustomizationElementNames;

public CustomizedIgnoring(QName... names) {
this.ignoredCustomizationElementNames = names;
}

public QName[] getIgnoredCustomizationElementNames() {
return ignoredCustomizationElementNames;
}

public boolean isIgnored(ClassOutline classOutline) {
for (QName name : getIgnoredCustomizationElementNames()) {
if (CustomizationUtils.containsCustomization(classOutline, name)) {
return true;
}
}
return false;
}

public boolean isIgnored(EnumOutline enumOutline) {
for (QName name : getIgnoredCustomizationElementNames()) {
if (CustomizationUtils.containsCustomization(enumOutline, name)) {
return true;
}
}
return false;
}

public boolean isIgnored(FieldOutline fieldOutline) {
for (QName name : getIgnoredCustomizationElementNames()) {
if (CustomizationUtils.containsCustomization(fieldOutline, name)) {
return true;
}
}
return false;
}

public boolean isIgnored(CClassInfo classInfo) {
for (QName name : getIgnoredCustomizationElementNames()) {
if (CustomizationUtils.containsCustomization(classInfo, name)) {
return true;
}
}
return false;
}

public boolean isIgnored(CEnumLeafInfo enumLeafInfo) {
for (QName name : getIgnoredCustomizationElementNames()) {
if (CustomizationUtils.containsCustomization(enumLeafInfo, name)) {
return true;
}
}
return false;
}

public boolean isIgnored(CPropertyInfo propertyInfo) {
for (QName name : getIgnoredCustomizationElementNames()) {
if (CustomizationUtils.containsCustomization(propertyInfo, name)) {
return true;
}
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jvnet.jaxb2_commons.plugin;

import com.sun.tools.xjc.model.CClassInfo;
import com.sun.tools.xjc.model.CEnumLeafInfo;
import com.sun.tools.xjc.model.CPropertyInfo;
import com.sun.tools.xjc.outline.ClassOutline;
import com.sun.tools.xjc.outline.EnumOutline;
import com.sun.tools.xjc.outline.FieldOutline;

public interface Ignoring {

public boolean isIgnored(ClassOutline classOutline);

public boolean isIgnored(EnumOutline enumOutline);

public boolean isIgnored(FieldOutline fieldOutline);

public boolean isIgnored(CClassInfo classInfo);

public boolean isIgnored(CEnumLeafInfo enumLeafInfo);

public boolean isIgnored(CPropertyInfo propertyInfo);

}
Loading

0 comments on commit ecc6839

Please sign in to comment.