Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from phax/v016
Browse files Browse the repository at this point in the history
V016
  • Loading branch information
phax authored Feb 1, 2023
2 parents a7b4943 + 178d370 commit abbab66
Show file tree
Hide file tree
Showing 119 changed files with 9,239 additions and 524 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# JAXB Maven Plugin (jvnet)

[![CI](https://github.com/evolvedbinary/maven-jaxb2-plugin/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/evolvedbinary/jvnet-jaxb-maven-plugin/actions/workflows/ci.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.evolvedbinary.maven.jvnet/jaxb-maven-plugin-project.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.evolvedbinary.maven.jvnet%22%20AND%20a:%22jaxb-maven-plugin-project%22)
[![Maven Central](https://img.shields.io/maven-central/v/com.helger.maven/jaxb-maven-plugin-project.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.helger.maven%22%20AND%20a:%22jaxb-maven-plugin-project%22)
[![License](https://img.shields.io/badge/license-BSD%202-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)

* **Supports JAXB 2, JAXB 3 and JAXB 4.**
Expand Down Expand Up @@ -47,7 +47,7 @@ compiling XML Schemas (as well as WSDL, DTDs, RELAX NG) into Java classes in Mav
<plugins>
...
<plugin>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb40-maven-plugin</artifactId>
<version>0.16.0</version>
<executions>
Expand Down Expand Up @@ -75,11 +75,11 @@ Use: `<artifactId>jaxb2-maven-plugin</artifactId>` instead.

If you need a specific JAXB version, you can explicitly use one of the following variants:

* `com.evolvedbinary.maven.jvnet:jaxb40-maven-plugin` - JAXB 4.0.
* `com.evolvedbinary.maven.jvnet:jaxb30-maven-plugin` - JAXB 3.0.
* `com.evolvedbinary.maven.jvnet:jaxb23-maven-plugin` - JAXB 2.3.
* `com.evolvedbinary.maven.jvnet:jaxb22-maven-plugin` - JAXB 2.2.
* `com.evolvedbinary.maven.jvnet:jaxb2-maven-plugin` - "latest 2.x version"; at the moment this is same as `com.evolvedbinary.maven.jvnet:jaxb23-maven-plugin`.
* `com.helger.maven:jaxb40-maven-plugin` - JAXB 4.0.
* `com.helger.maven:jaxb30-maven-plugin` - JAXB 3.0.
* `com.helger.maven:jaxb23-maven-plugin` - JAXB 2.3.
* `com.helger.maven:jaxb22-maven-plugin` - JAXB 2.2.
* `com.helger.maven:jaxb2-maven-plugin` - "latest 2.x version"; at the moment this is same as `com.helger.maven:jaxb23-maven-plugin`.

### Java versions

Expand Down
2 changes: 1 addition & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb-maven-plugin-project</artifactId>
<version>0.16.0-SNAPSHOT</version>
</parent>
Expand Down
4 changes: 2 additions & 2 deletions plugin-2.2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb-maven-plugin-project</artifactId>
<version>0.16.0-SNAPSHOT</version>
<version>0.16.2-SNAPSHOT</version>
</parent>

<artifactId>jaxb22-maven-plugin</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions plugin-2.3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb-maven-plugin-project</artifactId>
<version>0.16.0-SNAPSHOT</version>
<version>0.16.2-SNAPSHOT</version>
</parent>

<artifactId>jaxb23-maven-plugin</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions plugin-3.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb-maven-plugin-project</artifactId>
<version>0.16.0-SNAPSHOT</version>
<version>0.16.2-SNAPSHOT</version>
</parent>

<artifactId>jaxb30-maven-plugin</artifactId>
Expand Down Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>txw2</artifactId>
<version>${jaxb30.version}</version>
<version>${jaxb30.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>

<dependency>
Expand Down
16 changes: 9 additions & 7 deletions plugin-3.0/src/main/java/org/jvnet/mjiip/v_3_0/XJC30Mojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
* @author Aleksei Valikov (valikov@gmx.net)
*/
@Mojo (name = "generate",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true)
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
threadSafe = true)
public class XJC30Mojo extends RawXJC3Mojo<Options>
{

Expand All @@ -53,12 +53,11 @@ public void doExecute (final Options options) throws MojoExecutionException
final Model model = loadModel (options);
final Outline outline = generateCode (model);
writeCode (outline);

}

protected Model loadModel (final Options options) throws MojoExecutionException
{
if (getVerbose ())
if (getLog ().isDebugEnabled ())
{
final InputSource [] aGrammars = options.getGrammars ();
getLog ().debug ("Parsing " + aGrammars.length + " input schema(s)...");
Expand All @@ -83,11 +82,14 @@ protected Model loadModel (final Options options) throws MojoExecutionException
{
// Fake check
final InputSource [] schemas = options.getGrammars ();
getLog ().debug ("Starting SchemaConstraintChecker");
if (getLog ().isDebugEnabled ())
getLog ().debug ("Starting SchemaConstraintChecker");

if (!SchemaConstraintChecker.check (schemas, er, getEntityResolver (), false))
getLog ().error ("SchemaConstraintChecker failed");
else
getLog ().debug ("SchemaConstraintChecker finished successfully");
if (getLog ().isDebugEnabled ())
getLog ().debug ("SchemaConstraintChecker finished successfully");
}

final Model model = ModelLoader.load (options, new JCodeModel (), er);
Expand Down
6 changes: 3 additions & 3 deletions plugin-4.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb-maven-plugin-project</artifactId>
<version>0.16.0-SNAPSHOT</version>
<version>0.16.2-SNAPSHOT</version>
</parent>

<artifactId>jaxb40-maven-plugin</artifactId>
Expand Down Expand Up @@ -36,7 +36,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>txw2</artifactId>
<version>${jaxb40.version}</version>
<version>${jaxb40.version}</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
Expand Down
91 changes: 91 additions & 0 deletions plugin-4.0/src/test/java/org/jvnet/mjiip/v_4_0/MainDummyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.jvnet.mjiip.v_4_0;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.jvnet.jaxb2.maven2.IDependencyResourceResolver;
import org.jvnet.jaxb2.maven2.resolver.CatalogManager;
import org.jvnet.jaxb2.maven2.resolver.tools.MavenCatalogResolver;
import org.jvnet.jaxb2.maven2.resolver.tools.ReResolvingEntityResolverWrapper;

import com.sun.codemodel.JCodeModel;
import com.sun.tools.xjc.Language;
import com.sun.tools.xjc.ModelLoader;
import com.sun.tools.xjc.Options;
import com.sun.tools.xjc.model.Model;

public class MainDummyTest
{
public static void main (final String [] args) throws Exception
{
final Log log = new SystemStreamLog ()
{
@Override
public boolean isDebugEnabled ()
{
return true;
}
};

final LoggingErrorReceiver er = new LoggingErrorReceiver ("Error while parsing schema(s).", log, true);
final Options options = new Options ();
options.setSchemaLanguage (Language.XMLSCHEMA);
options.strictCheck = false;
options.compatibilityMode = Options.EXTENSION;
final MavenCatalogResolver catalogResolver;
{
final CatalogManager catalogManager = new CatalogManager ();
catalogManager.setIgnoreMissingProperties (true);
catalogManager.setUseStaticCatalog (false);
catalogManager.setVerbosity (Integer.MAX_VALUE);
final IDependencyResourceResolver dependencyResourceResolver = dependencyResource -> {
if (false)
System.err.println ("TODO " + dependencyResource);
try
{
final String sVersion = dependencyResource.getVersion () != null ? dependencyResource.getVersion ()
: dependencyResource.getArtifactId ()
.startsWith ("ph-xsds-") ? "3.0.0"
: "6.7.1-SNAPSHOT";
final String sUrl = "jar:file:/C:/Users/phili/.m2/repository/" +
dependencyResource.getGroupId ().replace ('.', '/') +
"/" +
dependencyResource.getArtifactId () +
"/" +
sVersion +
"/" +
dependencyResource.getArtifactId () +
"-" +
sVersion +
".jar!/" +
dependencyResource.getResource ();
System.err.println ("Resolved to " + sUrl);
return new URL (sUrl);
}
catch (final MalformedURLException ex)
{
throw new IllegalStateException ("Invalid URL", ex);
}
};
catalogResolver = new MavenCatalogResolver (catalogManager, dependencyResourceResolver, log);
options.entityResolver = new ReResolvingEntityResolverWrapper (catalogResolver, log);
}

// Parse catalog
final File fCat = new File ("C:\\dev\\git\\ph-ubl\\ph-ubltr\\src\\main\\jaxb\\catalog-ubltr.txt");
catalogResolver.getCatalog ().parseCatalog (fCat.toURI ().toURL ());

// Don't add catalog

// After the rest
final String sPath = "C:\\dev\\git\\ph-ubl\\ph-ubltr\\src\\main\\resources\\schemas\\ubltr";
options.addGrammar (new File (sPath, "Envelope/Package_1_2.xsd"));
options.addGrammar (new File (sPath, "HRXML/UserAccount.xsd"));
options.addBindFile (new File ("C:\\dev\\git\\ph-ubl\\ph-ubltr\\src\\main\\jaxb\\bindings-ubltr.xjb"));

final Model model = ModelLoader.load (options, new JCodeModel (), er);
}
}
13 changes: 8 additions & 5 deletions plugin-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.evolvedbinary.maven.jvnet</groupId>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb-maven-plugin-project</artifactId>
<version>0.16.0-SNAPSHOT</version>
<version>0.16.2-SNAPSHOT</version>
</parent>

<artifactId>jaxb-maven-plugin-core</artifactId>
Expand Down Expand Up @@ -35,11 +35,14 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>resolver-1.2</artifactId>
<version>RELEASE160</version>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<version>1.2</version>
</dependency>
-->

<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>txw2</artifactId>
Expand Down
Loading

0 comments on commit abbab66

Please sign in to comment.