This is an automated email from the ASF dual-hosted git repository. rec pushed a commit to branch refactoring/430-Resolving-type-system-imports-through-SPIs-slows-things-down-too-much in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 6fda779cc43391101ac93ed15165ee120386a7d8 Author: Richard Eckart de Castilho <[email protected]> AuthorDate: Mon Dec 16 12:11:10 2024 +0100 Issue #430: Resolving type system imports through SPIs slows things down too much - Allow UimaBndPlugin to dive into transitive imports and process them as well --- .../java/org/apache/uima/tools/bnd/UimaBndPlugin.java | 19 ++++++++++++++----- .../uima/fit/maven/GenerateDescriptorsMojo.java | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/uima-bnd-plugin/src/main/java/org/apache/uima/tools/bnd/UimaBndPlugin.java b/uima-bnd-plugin/src/main/java/org/apache/uima/tools/bnd/UimaBndPlugin.java index 3caf4f3b3..91c6daa1b 100644 --- a/uima-bnd-plugin/src/main/java/org/apache/uima/tools/bnd/UimaBndPlugin.java +++ b/uima-bnd-plugin/src/main/java/org/apache/uima/tools/bnd/UimaBndPlugin.java @@ -110,7 +110,7 @@ public class UimaBndPlugin } LOG.warn( - "Found UIMA type system import without name and location - ignoring, please fix your type system description"); + "Found UIMA import without name and location - ignoring, please fix your type system description"); } return importsProcessed; @@ -119,11 +119,11 @@ public class UimaBndPlugin private void handleImportByLocation(Import imp) { LOG.warn( - "Found UIMA type system import by location: {} - ignoring, please only use import-by-name", + "Ignoring UIMA import by location (please only use import-by-name): {}", imp.getLocation()); } - private void handleImportByName(Analyzer analyzer, String path, Import imp) + private void handleImportByName(Analyzer analyzer, String path, Import imp) throws Exception { var tsdPackage = imp.getName(); int lastSeparatorPosition = tsdPackage.lastIndexOf('.'); @@ -132,11 +132,11 @@ public class UimaBndPlugin tsdPackage = tsdPackage.substring(0, lastSeparatorPosition); } - LOG.debug("Found UIMA type system import by name: {}", tsdPackage); + LOG.debug("Found UIMA import by name: {}", tsdPackage); var pack = analyzer.getPackageRef(tsdPackage); if (!QN.matcher(pack.getFQN()).matches()) { - analyzer.warning("Type system import does not seem to refer to a package (%s): %s", + analyzer.warning("Import does not seem to refer to a package (%s): %s", path, pack); } @@ -144,6 +144,15 @@ public class UimaBndPlugin var attrs = new Attrs(); analyzer.getReferred().put(pack, attrs); } + + var importedResourcePath = imp.getName().replace('.', '/')+".xml"; + var importedResource = analyzer.findResource(importedResourcePath); + if (importedResource == null) { + analyzer.warning("Imported resource not found on classpath: {}", importedResourcePath); + return; + } + + analyzeXmlFile(analyzer, importedResourcePath, importedResource); } private List<Import> getImportsFromDescriptor(XMLizable desc) diff --git a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java index 4432cea31..4f9abda5b 100644 --- a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java +++ b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java @@ -149,7 +149,7 @@ public class GenerateDescriptorsMojo extends AbstractMojo { componentLoader = Util.getClassloader(project, includeScope); // List of components that is later written to META-INF/org.apache.uima.fit/components.txt - StringBuilder componentsManifest = new StringBuilder(); + var componentsManifest = new StringBuilder(); int countGenerated = 0; for (String file : files) {
