Skip to content

Commit

Permalink
Fix ModelloCli after moving from Plexus to JSR330
Browse files Browse the repository at this point in the history
  • Loading branch information
fridrich committed Apr 13, 2024
1 parent ef562b0 commit 90352d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 20 additions & 6 deletions modello-core/src/main/java/org/codehaus/modello/Modello.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,40 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.Reader;
import java.io.Writer;
import java.util.Properties;

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, Properties parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.File;
import java.util.Properties;

import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.XmlStreamReader;

Expand All @@ -40,7 +39,7 @@ public class ModelloCli {
private static Properties parameters;

public static void main(String[] args) throws Exception {
Modello modello = new DefaultPlexusContainer().lookup(Modello.class);
Modello modello = new Modello();

parseArgumentsFromCommandLine(args);

Expand Down

0 comments on commit 90352d3

Please sign in to comment.