Skip to content

Commit

Permalink
Added a metaschema-databind module-info module descriptor.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Aug 28, 2023
1 parent 362bfce commit dd454d0
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 9 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,18 @@
requires com.ctc.wstx;
requires com.fasterxml.jackson.annotation;
requires com.fasterxml.jackson.core;
requires transitive com.fasterxml.jackson.databind;
requires transitive inet.ipaddr;
requires nl.talsmasoftware.lazy4j;
requires org.antlr.antlr4.runtime;
requires org.apache.commons.lang3;
requires org.apache.commons.text;
requires org.apache.logging.log4j;
requires org.apache.xmlbeans;
requires transitive org.codehaus.stax2;
requires transitive org.json;
requires org.jsoup;

requires transitive com.fasterxml.jackson.databind;
requires transitive inet.ipaddr;
requires transitive org.codehaus.stax2;

// dependencies without a module descriptor
requires transitive everit.json.schema; // needed for validation details
requires transitive flexmark;
Expand Down Expand Up @@ -95,6 +94,7 @@
exports gov.nist.secauto.metaschema.core.model.validation;
exports gov.nist.secauto.metaschema.core.model.xml;
// exports gov.nist.secauto.metaschema.core.model.xml.xmlbeans;
exports gov.nist.secauto.metaschema.core.resource;
exports gov.nist.secauto.metaschema.core.util;

exports gov.nist.secauto.metaschema.core.datatype.markup.flexmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
package gov.nist.secauto.metaschema.databind.codegen;

import gov.nist.secauto.metaschema.core.model.IMetaschema;
import gov.nist.secauto.metaschema.databind.IBindingContext;
import gov.nist.secauto.metaschema.databind.codegen.config.DefaultBindingConfiguration;
import gov.nist.secauto.metaschema.databind.codegen.config.IBindingConfiguration;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.lang.module.ModuleDescriptor;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
Expand Down Expand Up @@ -159,16 +161,41 @@ private static boolean compile(
DiagnosticCollector<JavaFileObject> diagnostics,
List<JavaFileObject> compilationUnits,
Path classDir) {

String classPath = System.getProperty("java.class.path");
String modulePath = System.getProperty("jdk.module.path");

if (LOGGER.isDebugEnabled()) {
LOGGER.atDebug().log("Using classpath: {}", classPath);
LOGGER.atDebug().log("Using modulepath: {}", modulePath);
}

List<String> options = new LinkedList<>();
// options.add("-verbose");
// options.add("-g");
options.add("-d");
options.add(classDir.toString());
options.add("-classpath");
options.add(System.getProperty("java.class.path"));
if (classPath != null) {
options.add("-classpath");
options.add(classPath);
}
if (modulePath != null) {
options.add("-p");
options.add(modulePath);
}

JavaCompiler.CompilationTask task
= compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits);

Module module = IBindingContext.class.getModule();
if (module != null) {
ModuleDescriptor descriptor = module.getDescriptor();
if (descriptor != null) {
// add the databind module to the task
task.addModules(List.of(descriptor.name()));
}
}

return task.call();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import gov.nist.secauto.metaschema.core.configuration.IConfiguration;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.io.json.JsonFactoryFactory;
import gov.nist.secauto.metaschema.databind.io.yaml.YamlFactoryFactory;
import gov.nist.secauto.metaschema.databind.io.yaml.impl.YamlFactoryFactory;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.IBindingContext;
import gov.nist.secauto.metaschema.databind.io.json.JsonFactoryFactory;
import gov.nist.secauto.metaschema.databind.io.yaml.YamlFactoryFactory;
import gov.nist.secauto.metaschema.databind.io.yaml.impl.YamlFactoryFactory;

import org.codehaus.stax2.XMLEventReader2;
import org.codehaus.stax2.XMLInputFactory2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import gov.nist.secauto.metaschema.databind.io.json.DefaultJsonDeserializer;
import gov.nist.secauto.metaschema.databind.io.yaml.impl.YamlFactoryFactory;
import gov.nist.secauto.metaschema.databind.model.IAssemblyClassBinding;

import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.fasterxml.jackson.core.JsonFactory;

import gov.nist.secauto.metaschema.databind.io.json.DefaultJsonSerializer;
import gov.nist.secauto.metaschema.databind.io.yaml.impl.YamlFactoryFactory;
import gov.nist.secauto.metaschema.databind.model.IAssemblyClassBinding;

import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.
*/

package gov.nist.secauto.metaschema.databind.io.yaml;
package gov.nist.secauto.metaschema.databind.io.yaml.impl;

import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactoryBuilder;
Expand Down
63 changes: 63 additions & 0 deletions databind/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Portions of this software was developed by employees of the National Institute
* of Standards and Technology (NIST), an agency of the Federal Government and is
* being made available as a public service. Pursuant to title 17 United States
* Code Section 105, works of NIST employees are not subject to copyright
* protection in the United States. This software may be subject to foreign
* copyright. Permission in the United States and in foreign countries, to the
* extent that NIST may hold copyright, to use, copy, modify, create derivative
* works, and distribute this software and its documentation without fee is hereby
* granted on a non-exclusive basis, provided that this notice and disclaimer
* of warranty appears in all copies.
*
* THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER
* EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY
* THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM
* INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE
* SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT
* SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT,
* INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM,
* OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY,
* CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR
* PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT
* OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.
*/
module gov.nist.secauto.metaschema.databind {
// requirements
requires java.base;
requires java.compiler;

requires transitive gov.nist.secauto.metaschema.core;

requires com.ctc.wstx;
requires com.fasterxml.jackson.dataformat.yaml;
requires com.fasterxml.jackson.dataformat.xml;
requires com.github.spotbugs.annotations;
requires com.squareup.javapoet;
requires com.sun.xml.bind.core;
requires nl.talsmasoftware.lazy4j;
requires transitive org.apache.commons.lang3;
requires org.apache.logging.log4j;
requires org.apache.xmlbeans;
requires org.yaml.snakeyaml;

requires flexmark.util.sequence;

exports gov.nist.secauto.metaschema.databind;
exports gov.nist.secauto.metaschema.databind.codegen;
exports gov.nist.secauto.metaschema.databind.codegen.config;
exports gov.nist.secauto.metaschema.databind.codegen.typeinfo;
exports gov.nist.secauto.metaschema.databind.io;
exports gov.nist.secauto.metaschema.databind.io.json;
exports gov.nist.secauto.metaschema.databind.io.xml;
exports gov.nist.secauto.metaschema.databind.io.yaml;
exports gov.nist.secauto.metaschema.databind.model;
exports gov.nist.secauto.metaschema.databind.model.info;
exports gov.nist.secauto.metaschema.databind.model.annotations;

// need to allow access to the generated XMLBeans files
opens org.apache.xmlbeans.metadata.system.metaschema.codegen;
opens gov.nist.secauto.metaschema.databind.codegen.xmlbeans;
opens gov.nist.secauto.metaschema.databind.codegen.xmlbeans.impl;
}

0 comments on commit dd454d0

Please sign in to comment.