modello/0001-Fix-ModelloCli-after-moving-from-Plexus-to-JSR330.patch

86 lines
3.2 KiB
Diff

From cc800846da128d795c69142d4ae0c33c0677e943 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba@bluewin.ch>
Date: Sat, 13 Apr 2024 15:14:24 +0200
Subject: [PATCH 1/3] Fix ModelloCli after moving from Plexus to JSR330
---
.../java/org/codehaus/modello/Modello.java | 26 ++++++++++++++-----
.../java/org/codehaus/modello/ModelloCli.java | 3 +--
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/modello-core/src/main/java/org/codehaus/modello/Modello.java b/modello-core/src/main/java/org/codehaus/modello/Modello.java
index 00fb7114..0572fce6 100644
--- a/modello-core/src/main/java/org/codehaus/modello/Modello.java
+++ b/modello-core/src/main/java/org/codehaus/modello/Modello.java
@@ -22,8 +22,6 @@ package org.codehaus.modello;
* SOFTWARE.
*/
-import javax.inject.Inject;
-
import java.io.Reader;
import java.io.Writer;
import java.util.Map;
@@ -31,17 +29,33 @@ import java.util.Map;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.modello.model.Model;
import org.codehaus.modello.model.ModelValidationException;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.DefaultContainerConfiguration;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class Modello {
- private final ModelloCore core;
+ private PlexusContainer container;
+
+ private ModelloCore core;
+
+ public Modello() throws ModelloException {
+ try {
+ ContainerConfiguration configuration = new DefaultContainerConfiguration();
+ configuration.setAutoWiring(true);
+ configuration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
+
+ container = new DefaultPlexusContainer(configuration);
- @Inject
- public Modello(ModelloCore core) {
- this.core = core;
+ core = (ModelloCore) container.lookup(ModelloCore.ROLE);
+ } catch (Exception ex) {
+ throw new ModelloException("Error while starting plexus.", ex);
+ }
}
public void generate(Reader modelReader, String outputType, Map<String, Object> parameters)
diff --git a/modello-core/src/main/java/org/codehaus/modello/ModelloCli.java b/modello-core/src/main/java/org/codehaus/modello/ModelloCli.java
index 1b4cd974..a75e4011 100644
--- a/modello-core/src/main/java/org/codehaus/modello/ModelloCli.java
+++ b/modello-core/src/main/java/org/codehaus/modello/ModelloCli.java
@@ -26,7 +26,6 @@ import java.io.File;
import java.util.HashMap;
import java.util.Map;
-import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.XmlStreamReader;
@@ -41,7 +40,7 @@ public class ModelloCli {
private static Map<String, Object> parameters;
public static void main(String[] args) throws Exception {
- Modello modello = new DefaultPlexusContainer().lookup(Modello.class);
+ Modello modello = new Modello();
parseArgumentsFromCommandLine(args);
--
2.44.0